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:

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/ /storage`
Options[server.disk]: nopercent,growright,gauge,noinfo, nobanner
#MaxBytes[server.disk]: 8423
MaxBytes[server.disk]: 340381988
YLegend[server.disk]: Bytes
ShortLegend[server.disk]: B
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.


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:

DATA=`$PING -c1 -s500 $ADDR -q `
LOSS=`echo $DATA | awk ‘{print $18 }’ | tr -d %`
echo $LOSS
if [ $LOSS = 100 ];
then echo 0
echo $DATA | awk -F/ ‘{print $5 }’

And MRTG config:

Title[localgw]: Pingtest gateway intern
PageTop[localgw]: <H1>Pingtest gateway intern</H1>
Target[localgw]: `/usr/local/bin/`
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

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

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

Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/ line 67 at /usr/share/perl5/ line 608

Leave a Reply

Your email address will not be published. Required fields are marked *