Marks Blog
  • PowerDNS Admin
  • About
  • Simple Ticket System

HP ProLiant Fan & Temperature Monitoring

February 12, 2015 by mark

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 :)

fans

temperature

Posted in: Linux & Unix Tagged: collectd, fans, monitor, proliant, rrd, temperature

Weather Station

Pages

  • About
  • PowerDNS Admin
  • Simple Ticket System

Affiliates

  • Danish Sensor Engineering
  • Mintr ApS
  • Nellemann Data

Social

  • BitBucket
  • GitHub
  • LinkedIn
  • Mastodon

Categories

  • Android
  • Automobile
  • Blog & Rantings
  • Development & Scripting
  • Grails
  • Linux & Unix
  • Mac OS X
  • Misc
  • No category
  • PowerDNS Admin
  • Puppet
  • Security Related
  • VirtualBox
  • Virtualization
  • VMware
  • Windows

Archives

  • January 2019
  • September 2017
  • January 2016
  • May 2015
  • March 2015
  • February 2015
  • December 2014
  • October 2014
  • September 2014
  • August 2014
  • June 2014
  • January 2014
  • July 2013
  • June 2013
  • February 2013
  • January 2013
  • December 2012
  • August 2012
  • May 2012
  • October 2011
  • April 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • March 2010
  • October 2009
  • September 2009
  • April 2009
  • January 2009
  • March 2008
  • January 2008
  • November 2007
  • January 2007
  • December 2006
  • November 2006
  • August 2006
  • June 2006
  • March 2006
  • October 2005
  • August 2005

Copyright © 2025 Marks Blog.

Mobile WordPress Theme by themehall.com