Simple way to read SMART status from harddisk 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 smartctl.
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 smartmontools 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 smart-sda /bin/sh -c "/usr/sbin/smartctl -H /dev/sda | /bin/sed '1,/===/d;/^$/d'"
# exec smart-sda /bin/sh -c "/usr/sbin/smartctl -H /dev/sda | /bin/sed '/^SMART Health Status:/!d;s/.*: //'" 


  • /etc/init.d/snmpd restart
snmpwalk -v1 -c L0cal localhost .1.3.6.1.4.1.2021.8.1


  • 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     Disk sda health
normal_check_interval   720
check_command           check_snmp_output!rEADoNLY!UCD-SNMP-MIB::extOutput.1!PASSED
        }


/etc/init.d/nagios3 restart