ping.pl madness =D

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
techitch
Posts: 3
Joined: Tue Feb 04, 2003 5:59 pm

ping.pl madness =D

Post by techitch »

wow.. I never thought something so apparently simple could drive me to such madness :)

I have cacti up and running (for the mostpart) and it is fantastic.

I do have an issue with what should be the easiest thing to graph. Im trying to ping several hosts and graph the data.

Now, this DID seem to work then its like all the sudden it stops collecting data.

Here is an example of one not working :
/usr/bin/perl /usr/local/apache/htdocs/cacti/scripts/ping.pl covad.net
/usr/local/rrd/bin/rrdtool update /usr/local/apache/htdocs/cacti/rra/covadnet.rrd --template covadnet N:U

The things is, I have been checking over and over and once in a while I have seen the U change to a value. The scripts also run flawlessly from console. All the other graphs are happily collecting data. If I could get this ping beast conquered I would be a haaaaaaappy man..

OS = FreeBSD 4.7
PHP = 4.3.0

Cron entry - */5 * * * * cd /usr/local/apache/htdocs/cacti; /usr/local/bin/php /usr/local/apache/htdocs/cacti/cmd.php > /dev/null 2>&1

the cron works fine from the console as well.

Help? :)
techitch
Posts: 3
Joined: Tue Feb 04, 2003 5:59 pm

Post by techitch »

UPDATE :

I have found that when I run the scripts manually, the U value gets set to a # so that means it is collecting data.

As soon as it runs as a CRON, the values go right back to U :*(

thoughts?
Fred
Cacti User
Posts: 81
Joined: Fri Jan 03, 2003 11:43 am

Post by Fred »

Sounds like 'ping' and/or 'grep' aren't in the PATH for cron.

You can either edit ping.pl to include full pathnames to these utilities, or edit your crontab to include the proper PATH.
techitch
Posts: 3
Joined: Tue Feb 04, 2003 5:59 pm

Post by techitch »

hot damn fred :) you are good! I read your post and sat here thinking, "please, it cannot be that". I did it, tailed the log and let the cron run and blamo.

Anyone else having problems with the ping script, here is what I had to do on my system to get ping.pl to update when running as a cron :
#!/usr/local/perl

$ping = `/sbin/ping -c 1 $ARGV[0] | /usr/bin/grep icmp_seq`;
$ping =~ s/(.*time=)(.*) (ms|usec)//;

print $2;
Fred
Cacti User
Posts: 81
Joined: Fri Jan 03, 2003 11:43 am

Post by Fred »

techitch wrote:hot damn fred :) you are good!
Not very... I still can't get the 0.8 CVS to install. It's starting to make me angry.

But back on topic...

On my redhat and my mandrake systems, /etc/crontab has a number of lines at the beginning. I'll just quote my entire crontab for you to see it.
/etc/crontab wrote: SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
That PATH line might be important... As I've said, I don't know how this transfers to other systems like *BSD or Solaris.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests