Above average nerdiness

Monthly Archives: August 2012

SMART monitoring via SNMP

To keep track of the health of the disks in my ix2-200s, I setup SMART monitoring via SNMP using a lot of information from this post by Glen Pitt-Pladdy. However, I made a few changes.

Firstly, I use the output of smartd stored in /var/lib/smartmontools/ rather than the cronjob he uses. The format is quite different, and there’s a few extra bits of logic required to get the right values. Secondly, I tried rewriting it in python as an excuse to practice some python. Unfortunately, python takes much longer to start up than perl does, which means SNMP performance is noticeably affected by using the python version. Thirdly, since the state files don’t contain the device name, I switch to using the drive serial numbers as the index for the SNMP data. This might cause problems when it comes to swapping disks, but at least you can be sure you’re monitoring the right disk.

Lastly, and this is more of a bug than a feature, the format of the smartd state files is such that some raw fields are stored as 48 bit numbers, which makes the bitwise operations I use to extract the raw temperature fail in some situations on 32 bit perl. The proper solution would be to use Math::Int64, but this slows things down and it’s not a problem for my particular disks.

I’ve put it all up on my github for those that are interested.