Script only runs when logging in DEVEL-DEBUG mode

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
Tehrasha
Posts: 13
Joined: Sun Mar 13, 2011 6:40 am

Script only runs when logging in DEVEL-DEBUG mode

Post by Tehrasha »

A script which had been running perfectly fine for a couple years, suddenly stopped recording data after returning to 0.8.8h.
(see my thread in the Unstable section for why I had to revert)

I assumed the problem was the poller cache after the transition, so I cleared it.
No joy, still failed to record new data.

Cacti Log showed 'WARNING: Result from CMD not valid. Partial Result: U' for this particular script.
(the script runs fine manually)

So I turned logging up to maximum to see if it would give any hints to the problem.
No errors appeared. Not even the WARNING above.

Turns out that the scripts works fine and records data when the log is set to DEVEL.
If I turn it down from there, it fails with the above warning.
Have toggled it back and forth several times, and it consistently works only in DEVEL.

EDIT::
In DEVEL mode, the logfile exceeds the 10000 line display limit within a single poller cycle, so my temporary fix is to move the logfile to /dev/null to prevent the logfile from becoming insanely large. So my graph is now working, but I cant tell if anything goes wrong elsewhere.
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Script only runs when logging in DEVEL-DEBUG mode

Post by Osiris »

What is the output of the script when you run native? What poller are you running?
Before history, there was a paradise, now dust.
Tehrasha
Posts: 13
Joined: Sun Mar 13, 2011 6:40 am

Re: Script only runs when logging in DEVEL-DEBUG mode

Post by Tehrasha »

Using the cmd.php poller.
It is a simple perl script to grab signal data from a cablemodem.

Code: Select all

#!/usr/bin/perl
use warnings;
use strict;

use LWP::Simple;

my %data;
my @keys = qw(DownFreq DownSNR DownPower UpFreq UpPower);
my $content = LWP::Simple::get("http://192.168.100.1/RgSignal.asp") or die "Couldn't get it!";
#$content =~ s/\ |\n//g;

# regex in html source order
if ($content =~ /<td>Frequency<\/td><td>(.+?) Hz/) { $data{DownFreq} = $1; }
if ($content =~ /<td>Signal To Noise Ratio<\/td><td>(.+?) dB/) { $data{DownSNR} = $1; }
if ($content =~ /<td>Power Level<\/td><td>(.+?) dBmV/) { $data{DownPower} = $1; }
if ($content =~ /<td>Frequency<\/td><td>(.+?) Hz<\/td><\/tr>\s+<tr><td>Power/) { $data{UpFreq} = $1; }
if ($content =~ /<td>Power<\/td><td>(.+?) dBmV/) { $data{UpPower} = $1; }

for (@keys) {
	print "$_:" . $data{$_} . " ";
}
print "\n";
When run from a command line as a normal user or root, the output is normal...

DownFreq:267000000 DownSNR:35.1 DownPower:-3.4 UpFreq:35750000 UpPower:46.5

When it is run from cacti with normal logging on, it returns the "Couldn't get it!" failure response.
When I run cacti with the DEVEL logging option, the script returns a normal response.
Tehrasha
Posts: 13
Joined: Sun Mar 13, 2011 6:40 am

Re: Script only runs when logging in DEVEL-DEBUG mode

Post by Tehrasha »

So while awaiting response on this issue, I began work on a new script to gather more detailed information from the same device.
I wrote the new script in bash, as my knowledge of perl is very limited.

Got it all working manually, then built all of the templates, etc.. in cacti for it, and started graphing.
Everything worked, except for a single value which always came up as -nan-.
When I run the script manually, all of the values are there.

On a hunch, I turned off the DEVEL logging mode, and now the value records correctly.

I just cant win.

So my 'fix' for this situation, was to rewrite the perl script (above) in bash, and make cacti use it instead.
Now both scripts run normally and generate data and graphs at sane logging levels.
Not pretty, and doesnt address the underlying problem, but at least its graphing without generating books worth of log files.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest