[mrtg] MRTG not populating graphs from script that works on all but CentOS

Steve Shipway s.shipway at auckland.ac.nz
Fri Feb 12 01:35:15 CET 2010


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

Target[whatever]: hrSystemUptime.0&pseudoZero:public at 10.0.0.1: / 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:public at 10.0.0.1: / 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: mrtg-bounces at lists.oetiker.ch [mailto:mrtg-bounces at lists.oetiker.ch] 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?!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20100212/a930a5de/attachment-0001.htm 


More information about the mrtg mailing list