I promise I'm not laughing here, but what's wrong with just using SNMP directly 
- IE,

Target[whatever]: hrSystemUptime.0&pseudoZero:[email protected]: / 100
ShortLegend[whatever]: s
Options[whatever]: noo

... if you want it in seconds (since ticks are 1/100 sec), and

Target[whatever]: hrSystemUptime.0&pseudoZero:[email protected]: / 8640000
ShortLegend[whatever]: days
Options[whatever]: noo

... if you want it in days like your script produces (you'll need to set kMG[] 
or routers.cgi*Options[]:fixunit to prevent it from showing milli-days though)

Your script doesn't work as it doesn't return the data in the correct format.  
A MRTG data collection plugin MUST return 4 lines of text (first two containing 
the In and Out numberical values, then next two contain optional text for 
description and uptime) and have a zero exit status.

This would work:
#!/bin/bash
ticks=$(snmpwalk -v 1 -c public 10.0.0.1 hrSystemUptime.0 | awk '{ print $5 }' )
echo "$ticks"
echo "$ticks"
echo ""
echo ""
exit 0

However, it would have problems when the uptime is <1day as it just pulls out 
the 5th field which in this case would not be in days.  The SNMP method above 
would avoid this problem.

Steve


________________________________
From: [email protected] [mailto:[email protected]] On 
Behalf Of Matt Baer
Sent: Friday, 12 February 2010 1:09 p.m.
To: mrtg
Subject: [mrtg] MRTG not populating graphs from script that works on all but 
CentOS

I created a script to monitor uptime on a number of machines.  It's rough, 
ugly, inefficient, and I will get laughed at, but it works.  Here it is:

#!/bin/bash
ticks=$(snmpwalk -v 1 -c public 10.0.0.1 hrSystemUptime.0 | awk '{ print $5 }' )
echo "$ticks"

Now, this script works and populates data for Windows 7, Ubuntu, FreeBSD, etc.  
However, MRTG WILL NOT populate the data returned from this script from a 
CentOS machine.  I have gone through and verified everything I can possibly 
think of.  When run, the script itself returns the proper data.  The config 
files match perfectly with the other working machine with the exception of the 
host data of course.  To my knowledge, all it needs is a number to graph.  The 
script returns a number, why won't it graph?!
_______________________________________________
mrtg mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/mrtg

Reply via email to