Hi, Again I'm fairly new to Solaris & PHP. But My problem resides with the Ping.pl script returning the vaule that is gathered back to cacti.
I have had help in rewritting the Ping.pl script.
#!/usr/bin/perl -w
require "flush.pl";
$db = "";
if ($ARGV[0] eq "x") {
$db = ":0";
$ARGV[0] = 2;
}
@array = map { (split) [4] }
grep /round/,
qx/ping -s -v $ARGV[1] 56 $ARGV[0]/;
&flush(STDOUT);
@results = split("/",$array[0]);
$response = $results[0];
chomp $response;
print "$response$db";
My problem is If I run the script via command line I get the returned vaule that I'm looking for. But After the cmd.php script is run, & I check he output in either rrd.log or vi "edit data" the output is always U. Can anybody help me in figuring out why the data will not get returned to cacti?
Thanks.
Ping.pl & Solaris 8
Moderators: Developers, Moderators
ping.pl for solaris
One thing I noticed about cacti that was slightly different from MRTG was that if the
value it obtained (whether from snmp or from a script) had a newline character on the
end, cacti wouldn't see the value, but would just get a zero. (shrug) It IS more correct
behaviour to not include a newline tho, so I fixed up my scripts.
Here's the ping.pl I use on Solaris:
#!/usr/bin/perl
if ($ARGV[0]=="x") {
$db = ":0";
$ARGV[0] = 2;
}
$response = `ping -s $ARGV[1] 64 $ARGV[0] |grep round-trip| awk '\{print \$5 \}' | awk -F/ '\{print \$1 \}' | grep -v "Warning"`;
chomp $response;
$response = $response;
print "$response$db";
NOTE!!! That really ugly line that runs ping and awk and alla that is all on ONE LINE
and it's all between back-tick characters so you don't wanna put in \ characters to
split it into multiple lines. Yeah, yeah, there's prob'ly a better way but I had better
things to do than to make it pretty.
Hope this helps
value it obtained (whether from snmp or from a script) had a newline character on the
end, cacti wouldn't see the value, but would just get a zero. (shrug) It IS more correct
behaviour to not include a newline tho, so I fixed up my scripts.
Here's the ping.pl I use on Solaris:
#!/usr/bin/perl
if ($ARGV[0]=="x") {
$db = ":0";
$ARGV[0] = 2;
}
$response = `ping -s $ARGV[1] 64 $ARGV[0] |grep round-trip| awk '\{print \$5 \}' | awk -F/ '\{print \$1 \}' | grep -v "Warning"`;
chomp $response;
$response = $response;
print "$response$db";
NOTE!!! That really ugly line that runs ping and awk and alla that is all on ONE LINE
and it's all between back-tick characters so you don't wanna put in \ characters to
split it into multiple lines. Yeah, yeah, there's prob'ly a better way but I had better
things to do than to make it pretty.
Hope this helps
Who is online
Users browsing this forum: No registered users and 3 guests