If you have the hpasmcli command installed on your ProLiant server (available from the HP ProLiant Support Pack), you can display the speed of fans and the temperature of different parts of your server and use collectd to store the values. The following has been tested on a ProLiant ML350 G6 server.
On Debian you can add the following line to eg. /etc/apt/sources.list.d/hp.list and install the hp-health package:
# cat /etc/apt/sources.list.d/hp.list
deb http://downloads.linux.hp.com/SDR/repo/mcp wheezy/current non-free
# apt-get update
# apt-get install hp-health
Example output of running the hpasmcli command directly (to verify that it actually works):
# /sbin/hpasmcli -s "show temp"
Sensor Location Temp Threshold
------ -------- ---- ---------
#1 AMBIENT 26C/78F 42C/107F
#2 CPU#1 40C/104F 82C/179F
#3 CPU#2 - 82C/179F
#4 MEMORY_BD 37C/98F 87C/188F
#5 MEMORY_BD 34C/93F 87C/188F
#6 MEMORY_BD 33C/91F 87C/188F
#7 MEMORY_BD 33C/91F 87C/188F
I have made two small scripts to parse the output of hpasmcli and output it in a format that the collectd exec plugin understands.
This script reads the temperatures:
$ cat /usr/local/bin/hp-asmcli-temp.sh
#!/bin/bash
# This script uses hpasmcli to read ProLiant temperatures.
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
while sleep "$INTERVAL"; do
IFS=$'\n'
for line in $(sudo -n /sbin/hpasmcli -s "show temp" | grep -E '^#[0-9]+'); do
SENSOR=$(echo "$line" | awk '{ split($1, f1, "#"); printf("%02d",f1[2]); }')
LOCATION=$(echo "$line" | awk '{ print $2; }' | sed -e 's/#//' -e 's/\///')
TEMP=$(echo "$line" | awk '{ split($3, f1, "/"); split(f1[1], f2, "C"); print f2[1]; }')
if [[ "$TEMP" != "-" ]]; then
echo "PUTVAL ${HOSTNAME}/temperature-hpasmcli/temperature-${SENSOR}_${LOCATION} interval=$INTERVAL N:${TEMP}"
fi
done
done
This script reads the fan speeds:
$ cat /usr/local/bin/hp-asmcli-fans.sh
#!/bin/bash
# This script uses hpasmcli to read ProLiant fans.
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
while sleep "$INTERVAL"; do
IFS=$'\n'
for line in $(sudo -n /sbin/hpasmcli -s "show fan" | grep -E '^#[0-9]+'); do
FAN=$(echo "$line" | awk '{ split($1, f1, "#"); printf("%02d",f1[2]); }')
LOCATION=$(echo "$line" | awk '{ print $2; }')
SPEED=$(echo "$line" | awk '{ print $4; }')
VALUE=$(echo "$line" | awk '{ split($5, f1, "%"); print f1[1]; }')
if [[ "$SPEED" != "-" ]]; then
echo "PUTVAL ${HOSTNAME}/fans-hpasmcli/percent-${FAN}_${LOCATION} interval=$INTERVAL N:${VALUE}"
fi
done
done
As collectd will not exec scripts as root, you must setup sudo to allow the daemon user (or another user) to execute the script as root. Add the following line to the /etc/sudoers file on your server:
daemon ALL = NOPASSWD: /sbin/hpasmcli
We now have to configure collectd’s exec plugin to call the scripts:
# cat /etc/collectd/conf.d/20-exec-hpasmcli.conf
LoadPlugin exec
<Plugin exec>
Exec "daemon" "/usr/local/bin/hp-asmcli-temp.sh"
Exec "daemon" "/usr/local/bin/hp-asmcli-fans.sh"
</Plugin>
Restart collectd and you should get RRD files with the fan speed and temperatures :)