Tuesday, December 21, 2010

hard disc monitoring using zabbix

Just a quickie on monitoring SMART data from a hard disc, or temperature in this case.

  • In your /etc/zabbix/zabbix-agentd.conf add a UserParameter at the end. (add one p/hard disc you would like to monitor)
UserParameter=linux.smart, smartctl -A /dev/sda | grep Celsius | cut -d'-' -f2 | sed 's/ //g'

the part after linux.smart (which is your template and keyname), is the commandline. To explain it:

  • This shows (only) vendor specific SMART attributes of the first hard disc (or whatever is /dev/sda)
    smartctl -A /dev/sda
  • Only get/display/echo the line with Celsius in it
    grep Celsius
  • Cut away everything but the second field, using - as delimiter. This will leave you with some empty space and a number.
    cut -d'-' -f2
  • Delete empty space (actually substitute by nothing), so we only have the number left.
    sed 's/  //g'
Now in zabbix you can use my previous article on how to expand your (for example) linux template in zabbix and create an item called smart in there... piece of cake :)

Last thoughts;
Of course you can grab more info from the smartctl command, just run: (notice the lowercase a this time)
  smartctl -a /dev/sda | less
to have a bit of a look at what it all tracks... it's a lot.
I can also advise everybody just to have a look at the smartmontools/smartctl pages and setup frequent hard disc self testing. Smartmon tools can automatically mail you in case things start looking bad.

See you in the next article...

No comments:

Post a Comment