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

Matt Baer matt at baerconsult.com
Fri Feb 12 08:35:06 CET 2010

Ahhh yes. Well, I am not that intelligent when it comes to MRTG, it's more of a convenience for me to have everything in one place than a necessity. Being a n00b for MRTG, I assumed that it could only accept integers for its graphing purposes and wasn't quite sure if it would grab that select group of numbers out of all the other stuff that SNMP spews forth. That's why I went in to the script mode. I've been doing ALOT of bash scripting lately and look at every opportunity to do so as a challenge/learning opportunity, which it was. Not to mention I had to create some scripts to do RAM and hard drive usage stats for my Windows 7 machine that doesn't like to play nice with MRTG. 

If using SNMP directly works, awesome, I'll do that. I've tried it before without luck, but that was most likely the wet behind my ears. It still populates without a second value, but the logs fill up quickly :-( 

I actually created two scripts per device that I'm monitoring uptime for. One that does days, and one that does hours...again, probably more for my anal retentive quest to complicate things, but they do show up properly. 

----- Original Message ----- 
From: "Steve Shipway" <s.shipway at auckland.ac.nz> 
To: "Matt Baer" <matt at baerconsult.com>, "mrtg" <mrtg at lists.oetiker.ch> 
Sent: Thursday, February 11, 2010 6:35:15 PM 
Subject: RE: [mrtg] MRTG not populating graphs from script that works on all but CentOS 

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

Target[whatever]: hrSystemUptime.0&pseudoZero:public at / 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 / 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: 

ticks=$(snmpwalk -v 1 -c public 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 5 th field which in this case would not be in days. The SNMP method above would avoid this problem. 


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: 

ticks=$(snmpwalk -v 1 -c public 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/67eb204c/attachment.htm 

More information about the mrtg mailing list