Simple way to read RAID status via SNMP

From Bitbull Wiki
Jump to navigation Jump to search


i really like to monitor my hosts with snmp, because its implemented on every device and on every OS.
sometimes you need to search a pattern in output of a special comand, eg mdadm.
this was my way to solve the problem ... have you a more elegant way ... please let me know!

  • monitor disks on this host
install needed software
apt-get install mdadm snmpd
configure snmpd
vi /etc/snmp/snmpd.conf
---
syscontact      admin@bitbull.ch
rouser          safereader auth
rwuser          safewriter priv

rocommunity     rEADoNLY snmpd.mydomain.com
rocommunity     L0cal localhost

exec raid-md0 /bin/sh -c "/sbin/mdadm --detail /dev/md0 >/dev/null && echo OK"
---
/etc/init.d/snmpd restart
snmpwalk -v1 -c L0cal localhost UCD-SNMP-MIB::extOutput


  • on nagios host
vi /etc/nagios-plugins/config/custom.cfg 
---
# search for pattern in snmp output
define command{
        command_name    check_snmp_output
        command_line    /usr/lib/nagios/plugins/check_snmp -H '$HOSTADDRESS$' -C '$ARG1$' -o '$ARG2$' -r '$ARG3$'
        }
---
vi /etc/nagios3/conf.d/hosts-mydomain.com.cfg
---
define service{
use                     generic-service ; Inherit values from a template
host_name               myserver
service_description     Raid Array md0 health
normal_check_interval   720
check_command           check_snmp_output!r0nly..!UCD-SNMP-MIB::extOutput.1!'OK$'
        }
/etc/init.d/nagios3 restart