Mar 19 2009

Graph Only One Value in MRTG

Published by at 12:02 am under Monitoring




MRTG needs at least 2 values to generate graphs. Thus, Most configurations contain the same OID twice in the target line.
This leads to 2 problems:
– The same data is collected twice which requires more bandwidth, especially when a large number of hosts is monitored

– The value may vary during this very short lap, producing 2 different lines in the graph. This is the case with AS400 cpus for instance.
To graph only one value such as CPU or memory usage, you can write a short script that collects the SNMP field once:

mrtg@snmp-server:~> cat /home/mrtg/get-cpu.sh
#!/bin/sh
IP=$1
COMMUNITY=$2
SNMP_VERSION=$3
CPU_LOAD=`snmpget -c $COMMUNITY -v $SNMP_VERSION $IP .1.3.6.1.2.1.25.3.3.1.2.2 | awk '{print $(NF) }'`
echo $CPU_LOAD
echo $CPU_LOAD

 
MRTG CPU Usage
 
Replace with your own OID, and call the script in your MRTG config file:

Target[cpu]:`/home/mrtg/get-cpu.sh my_ip my_community 1`

Quick and easy!


One response so far

One Response to “Graph Only One Value in MRTG”

  1. shubhamon 13 Jul 2015 at 12:43 pm

    can you share your cfg file

Comments RSS

Leave a Reply