[mrtg] Re: graphing cpu/hard disk/memory usage with mrtg

Mike Dean mdean at landstar.com
Tue Aug 6 19:53:09 MEST 2002


I wrote this (not pretty, but it works <G>) to get mem utilization.  It will
return the % memory used.   The script linux-memused can be modified to get
disk usage also.  The snmpdf utility (should've come with ucd-snmp package)
returns disk and memory utilization.

Script linux-memused
#!/bin/bash
#linux-memused
#
# 
if [ "$1" = "" ] 
then
    printf "\n%s\n\n" 'Syntax: linux-memused <hostname> <community string>'
    exit -1;
fi

HOST=$1
COMMUNITY=$2
TMPFILE=/tmp/$HOST.mrtg

# Get the info
snmpdf $HOST $COMMUNITY >$TMPFILE

# Parse the info
REAL=`cat $TMPFILE | grep Real | awk '{ printf("%d\n", $6) }'`
SWAP=`cat $TMPFILE | grep Swap | awk '{ printf("%d\n", $6) }'`

# Cleanup and exit
rm $TMPFILE
printf "%d\n%d\n$COMMUNITY\n$HOST\n" $REAL $SWAP
exit 0

# --------------------------

For CPU usage I use the following on the target line:
Target[cpu]:
(1.3.6.1.4.1.2021.11.50.0&1.3.6.1.4.1.2021.11.50.0:comm at host+1.3.6.1.4.1.202
1.11.51.0&1.3.6.1.4.1.2021.11.51.0:comm at host+1.3.6.1.4.1.2021.11.52.0&1.3.6.
1.4.1.2021.11.52.0:comm at host)/4

The /4 should be changed to reflect the number of processors.  If you only
have one processor, remove /<number> from the end of the line.  For two
processors, use /2, etc.  From what I can tell, this does seem to be fairly
accurate.  One other note.  I've found, as I've upgraded ucd-snmp packages
that sometimes the snmpget will fail if you use the names (ssRawCpuNice,
etc) so I've switched to just using the OID numbers.

All suggestions on improving the above are appreciated.

Mike
-----Original Message-----
From: Kevin S. Dome [mailto:icefantum at stic.net]
Sent: Friday, August 02, 2002 1:51 PM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] graphing cpu/hard disk/memory usage with mrtg



I run a server at work, it runs Red hat 7.3 and I currently have 
ucd-snmp (latest version forgot the exact #) and have mrtg graphing 
network traffic. I have been scouring the net for weeks trying to figure 
out how to map cpu/mem/disk usage but have yet to find a decent 
tutorial, does anyone know where I can obtain such a tutorial?

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list