burdy's blog

MRTG

by on Jan.29, 2011, under Linux

For years I use MRTG to monitor several kinds of things, like: disksize and temperature, network traffic analysis and availability, cpu and motherboard temp, cpu load, disk-io.

~$ sudo aptitude mrtg snmpd apache2

Everything about setting up mrtg can be found here.

If using debian this will be a quick help


For checking diskspace I use a small script:

#!/bin/sh
df=”/bin/df”
cut=”/usr/bin/cut”
grep=”/bin/grep”
part=$1
line=`$df -m -x nfs| grep “$part”`
available=`echo $line|$cut -d” ” -f 4`
used=`echo $line|$cut -d” ” -f 3`
echo $available
echo $used

Which will be run from MRTG like this:

# Disk Usage Monitoring,
Target[server.disk]: `/usr/local/bin/checkdisk-storage.sh /storage`
Options[server.disk]: nopercent,growright,gauge,noinfo, nobanner
#MaxBytes[server.disk]: 8423
MaxBytes[server.disk]: 340381988
#Unscaled[server.disk]:dwmy
Unscaled[server.disk]:m
kMG[server.disk]:M,G,T,P
YLegend[server.disk]: Bytes
ShortLegend[server.disk]: B
Kilo[server.disk]:1024
Legend1[server.disk]: Space Available
Legend2[server.disk]: Space Used
LegendI[server.disk]: Space Used :
LegendO[server.disk]: Space Available :
Title[server.disk]: Diskspace /storage
PageTop[server.disk]: <H1>Diskspace storage RAID array 1 </H1>

For checking disk temperature on a disk in a RAID 5 array on a 8506 3ware raid-controller, I use this MRTG config:

Target[hdd_temp-raid-disk0]: `/usr/sbin/smartctl -a -d 3ware,0 /dev/twe0 | grep Temp | awk ‘{if($1 == “194″) print $10;print $10;}’`
MaxBytes[hdd_temp-raid-disk0]: 100
Title[hdd_temp-raid-disk0]: 3ware RAID set
PageTop[hdd_temp-raid-disk0]: <h1>3ware RAID5 set, WDC WD5000AAKB-00YSA0, Disk 0</h1>
Options[hdd_temp-raid-disk0]: noinfo, growright, integer,nopercent, gauge, absolute, unknaszero
Factor[hdd_temp-raid-disk0]: 1
YTicsFactor[hdd_temp-raid-disk0]: 1
YLegend[hdd_temp-raid-disk0]: Temperature
ShortLegend[hdd_temp-raid-disk0]: degrees
Legend1[hdd_temp-raid-disk0]: /dev/twe0 Temperature
Legend2[hdd_temp-raid-disk0]: /dev/twe0 Temperature
LegendI[hdd_temp-raid-disk0]: /dev/twe0 Temp.
LegendO[hdd_temp-raid-disk0]: /dev/twe0 Temp.

Notes:

Using Areca:
/usr/sbin/smartctl -a -d areca,1 /dev/sg1

Using 3ware 9500:
/usr/sbin/smartctl -a -d 3ware,0 /dev/twa0

 

For monitoring disk IO I installed the statgrab package,  using it with MRTG config like this:

Title[disk.sda.read_bytes]: Disk sda IO
MaxBytes[disk.sda.read_bytes]: 104857600
YLegend[disk.sda.read_bytes]: IO rate
ShortLegend[disk.sda.read_bytes]: B/s
LegendI[disk.sda.read_bytes]: read
LegendO[disk.sda.read_bytes]: write
kMG[disk.sda.read_bytes]: Ki,Mi,Gi,Ti
Target[disk.sda.read_bytes]: `statgrab -K -m disk.sda.read_bytes disk.sda.write_bytes`
PageTop[disk.sda.read_bytes]: <H1>Disk IO /dev/sda </H1>

Pingtest script:

#!/bin/sh
PING=”/bin/ping”
ADDR=”192.168.200.254″
DATA=`$PING -c1 -s500 $ADDR -q `
LOSS=`echo $DATA | awk ‘{print $18 }’ | tr -d %`
echo $LOSS
if [ $LOSS = 100 ];
then echo 0
else
echo $DATA | awk -F/ ‘{print $5 }’
fi

And MRTG config:

Title[localgw]: Pingtest gateway intern 192.168.0.254
PageTop[localgw]: <H1>Pingtest gateway intern 192.168.0.254</H1>
Target[localgw]: `/usr/local/bin/ping-modem.sh`
MaxBytes[localgw]: 2000
Options[localgw]: growright,unknaszero,nopercent,gauge
LegendI[localgw]: Pkt loss %
LegendO[localgw]: Avg RTT
YLegend[localgw]: RTT (ms)
#XSize[localgw]: 600
#YSize[localgw]: 150

Notes:
Replace “import Socket6;” with “Socket6->import(qw(inet_pton getaddrinfo));” at two different instances in /usr/share/perl5/SNMP_Session.pm. This will prevent these errors:

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67. at /usr/share/perl5/SNMP_Session.pm line 149

and
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67 at /usr/share/perl5/SNMP_Session.pm line 608

:,
No comments for this entry yet...

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...