Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


script or setup error?

 
Post new topic   Reply to topic    Cacti Forum Index -> Help: Linux/Unix Specific
Author Message
shadow



Joined: 10 Dec 2002
Posts: 17

PostPosted: Tue Dec 10, 2002 5:13 am    Post subject: script or setup error? Reply with quote

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?
Back to top
shadow



Joined: 10 Dec 2002
Posts: 17

PostPosted: Wed Dec 11, 2002 5:41 am    Post subject: Reply with quote

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;
Back to top
shadow



Joined: 10 Dec 2002
Posts: 17

PostPosted: Wed Dec 11, 2002 6:07 am    Post subject: found another prob Reply with quote

Now it works fine from the cmd line but returns a value of -1 when run from cron???
Back to top
bulek
Cacti Pro User


Joined: 20 May 2002
Posts: 852
Location: Poland

PostPosted: Wed Dec 11, 2002 11:29 am    Post subject: Reply with quote

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
Back to top
shadow



Joined: 10 Dec 2002
Posts: 17

PostPosted: Wed Dec 11, 2002 11:37 am    Post subject: Reply with quote

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
Back to top
bazzie
Guest





PostPosted: Mon Mar 10, 2003 7:48 pm    Post subject: Worked for me too !! Reply with quote

Thanx !
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Help: Linux/Unix Specific All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group