Zabbix checks for hpacucli

Short hack to integrate the ouput from hpacucli (the HP tool to query the health of your harddisks and the controller) into some Zabbix checks. Hardware and software in use as following:

The HP Software Delivery Repository

The easy way to install 3rd party software from HP is to use their SDR. They provide a bootstrap script to aide you with the setup.

  1. Download bootstrap.sh
  2. As superuser:"./bootstrap.sh -r 5 -d CentOS ProLiantSupportPack" or something vaguely similar - syntax seems to change from time to time.
  3. yum update && yum install hpacucli

Required system settings

Since you need superuser power to execute hpacucli I've decided to go for sudo instead of a suid-root script. So we need a few modifications to "/etc/sudoers"

  1. Disable the securetty check which is a default in RHEL/CentOS because the zabbix_agentd won't run on a real tty.
  2. Add the following lines to allow the hpacucli execution via sudo:
    ## Allow zabbix some limited usage of the hpacucli tool
    zabbix ALL=NOPASSWD:/usr/sbin/hpacucli ctrl all show status
    zabbix ALL=NOPASSWD:/usr/sbin/hpacucli ctrl slot=0 pd all show
  3. Add the UserParameter to /etc/zabbix/zabbix_agentd.conf:
    UserParameter=hp.cont,/usr/local/sbin/hpcheck.sh -c
    UserParameter=hp.disk,/usr/local/sbin/hpcheck.sh -d

hpcheck.sh

This is the hpcheck.sh script.
If you maintain a collection of common 3rd party scripts you install as a rpm package from central repository you might want to include it there. Otherwise just place it in "/usr/local/sbin/".
The script currently has three options:

It will output a 0 if everything is ok and a 1 if one or more items are not ok. Now you can easily add a new check to your Zabbix setup.

Just in case you wonder what the output of hpacucli looked like I based this script on, here are examples.
If you need some basic cheat sheet for the hpacucli usage take a look at this: http://www.datadisk.co.uk/html_docs/redhat/hpacucli.htm.

Changes

2010-05-13 v0.5:
Move the tempfile creation and cleanup call into the case() selection and only run them where needed.
Thanks to Jose Joaquin Anton Herrerias who noticed that calling hpcheck.sh with -h or unknown options leaves a spurious tempfile behind.