script or setup error?

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

Moderators: Developers, Moderators

Post Reply
shadow
Posts: 17
Joined: Tue Dec 10, 2002 4:48 am

script or setup error?

Post by shadow »

Hi

Ive installed cacti and have got it graphing using the built in scripts which are all working fine, Ive also got it graph network traffic on our cisco switches and routers alhtough I couldnt get it to graph the cpu utilization.

Problem Im having is that Im wanting to write various scripts that will return a value which I want to graph. As a test Im trying 2 scripts 1 in bash and the other in perl that return values but are not getting graphed.

1st script:
#!/usr/bin/perl
$input=`lynx -dump http://weather.noaa.gov/weather/current/EGLC.html |grep "Relative Humidity" |awk '\{print \$3 \}'|sed 's/%//g'`;
chomp $input;
print $input;

This runs fine from the cmd line as the user that apache runs as
bash-2.05a$ ./gethum.sh
74bash-2.05a$

And in the cacti log there are no errors for it:
12/10/2002 11:15 AM - CMD: /opt/rrdtool/bin/rrdtool update /export/www/cacti.telecom1.com//rra/relative_humidity.rrd --template relative_humidity N:U

Although I do see that its value is unknown, but not always as every now and then I do see a value in there but hasnt been graphed.

2nd script: (based on script from ultra)
#!/bin/bash
ret=`lynx -dump http://weather.noaa.gov/weather/current/$1.html | grep Temperature | sed 's/[a-z|A-Z|()]//g' | sed -e '2,3d' | awk '{ print $2 }'`
echo $ret

The exact same happens with this script

12/10/2002 11:20 AM - CMD: /opt/rrdtool/bin/rrdtool update /export/www/cacti.telecom1.com//rra/temperature.rrd --template temperature N:U

Ive set up the data input similar to the way that the system_procs has been set up and setup the graphs in a similar fashion

Any other info to help?
shadow
Posts: 17
Joined: Tue Dec 10, 2002 4:48 am

Post by shadow »

found the problem
crap was going in after values
added this to script

#!/usr/local/bin/perl
#PATH=$PATH:/usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin
#export PATH

$ret = `lynx -dump http://weather.noaa.gov/weather/current/EGLC.html | grep Temperature | sed 's/[a-z|A-Z|()]//g' | sed -e '2,3d' | awk '\{ print \$2 \}'`;

#my @plop = split //,$ret;
#foreach $a (@plop) {
#print " -- " . ord($a) . " -- \n";
#}


$ret =~ s/ +//;
$ret =~s/\r*//g;
$ret =~s/\n*//g;

#print "---------------------------\n";
#my @plop = split //,$ret;
#foreach $a (@plop) {
#print " -- " . ord($a) . " -- \n";
#}
chomp $ret;
$ret--;
print $ret;
shadow
Posts: 17
Joined: Tue Dec 10, 2002 4:48 am

found another prob

Post by shadow »

Now it works fine from the cmd line but returns a value of -1 when run from cron??? :-?
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

Probably some path or rights issue for cron user. You have standard and error output redirected to /dev/null in crontab I guess. Try to redirect it temporary to some file and look at the contents. Maybe you will find out something more.

- bulek
shadow
Posts: 17
Joined: Tue Dec 10, 2002 4:48 am

Post by shadow »

yeah
My HOME in /etc/cron was set to /
so when the script was calling on lynx to get the values lynx was trying to write a tmp file to /

Changed my HOME in /etc/crontab to /tmp and all works great now
:)
bazzie

Worked for me too !!

Post by bazzie »

Thanx ! :lol:
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests