Ping script failing

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Post Reply
acenet
Posts: 3
Joined: Tue Nov 02, 2004 11:15 am

Ping script failing

Post by acenet »

Hi,

I am running a modified ping script on Win2k. The script runs fine from the command line, but the Cacti log reports the following error:

11/02/2004 08:40:06 AM - CMDPHP: Poller[0] Host[0] CMD: perl C:\Apache2\htdocs\cacti86/scripts/ping3.pl 2 www.apple.com, output: U
11/02/2004 08:40:06 AM - CMDPHP: Poller[0] Host[0] WARNING: Result from CMD not valid. Partial Result: min:50 avg: 55

I have set the Data Input Method to have min and avg as output fields. I do not see where the issue lies.

Cacti 0.8.6a
Perl 5.8
PHP 4.3.7


Thanks,

brian
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Brian,

Note the following:

min:50 avg: 55

Get rid of the space between "avg:" and the result "55" on the script output and you will be all set.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
acenet
Posts: 3
Joined: Tue Nov 02, 2004 11:15 am

Post by acenet »

Thanks for the reply. I have taken a look at that as it displays fine when run from the command line. Here is the script

#!/usr/bin/perl

$host = $ARGV[1];
$pingcount = $ARGV[0];

$ping = `ping -n $pingcount $host`;

# starts some variables

$min;
$max;
$avg;
$loss;

# check for the minimum value

$ping =~ /Minimum = (\d*)/;
$min = $1;

# check for the maximum value

$ping =~ /Maximum = (.*)ms,/;
$max = $1;

# check for the average value

$ping =~ /(Averag|Gemiddeld)e = (.*)ms/;
$avg = $2;

# check for the % sign inside parens and grab it's value
$ping =~ /(\d*)%/;
$loss = $1;

#print the values
print "min:$min avg:$avg";

Thanks for the help!
acenet
Posts: 3
Joined: Tue Nov 02, 2004 11:15 am

It's working now!

Post by acenet »

The Witness,

Thanks again for the pointer. I got a friend of mine to modify the script and now it works fine. I just need to tweak the graphs now.

Cacti is a great program. Keep up the great work!

brian
Droidex

Could you post the modified script?

Post by Droidex »

I am trying to do the same!
Thanx!
edizzle

modified script

Post by edizzle »

You can force that variable into a number to remove the whitespace from the beginning of it, just add a +0 to the $avg line

$ping =~ /(Averag|Gemiddeld)e = (.*)ms/;
$avg = $2+0;

Thanks for posting!
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests