Friday, March 14, 2008

Hardware Monitoring for HP Prolliant DL360G4p under CentOS 5

Purpose: Send email alert out in the event of hardware failure for HP Proliant server under CentOS 5, especially hard disk failure

steps:
  • edit /etc/redhat-release, change to "Red Hat Enterprise Linux AS release 5" (required by hpasm and hpsmh packages)
  • install net-snmp* rpm packages from CentOS 5
You can use 'yum install net-snmp*'
chkconfig snmpd on
service snmpd start
  • install compat-libstdc* rpms , otherwise the storage controller Smart Array won't appear in Storage section in System Management Homepage
yum install compat-libstdc*
  • download hpasm and hpsmh from
http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=us&prodNameId=3288142&prodTypeId=15351&prodSeriesId=452749&swLang=8&taskId=135&swEnvOID=4006#7832

  • install hpasm and hpsmh
note: hpasm-HP System Health Application and Insight Management Agents for Red Hat Enterprise Linux 5 (x86)
hpsmh ->HP System Management Homepage for Linux (x86)
remember to start snmpd service first before installing rpms
configuring hpasm:
/etc/init.d/hpasm reconfigure
  • access https://serverip:2381
  • configuring /opt/compaq/cma.conf
exclude cpqasm cmhp cmascsid
trapemail /bin/mail -s 'Server1 HP Agents Trap Alarm' root
cmaXSocketBase 87654321
cmaCloseCcissHandle ON

note: we put cmascsid to exclude option to avoid the daemon to startup because it can cause system load to become high(uninterruptible sleep) on Fedora Core 3, you might take it out if your system is not FC3.
note: to stop storage agent: e.g. /opt/compaq/storage/etc/cmastor start/stop cmaeventd

  • allow necessary ports in Firewall settinig
in /etc/sysconfig/iptables, adding the following to enable port 2381
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 2381 -j ACCEPT

  • snmp extension
after configuration, the original /etc/snmp/snmpd.conf will be inserted in the beginning of the file to be like this:

# Following entries were added by HP Insight Management Agents at
# Mon Jun 16 10:39:32 SGT 2008
dlmod cmaX /usr/lib/libcmaX.so
rwcommunity public 127.0.0.1
rocommunity public 127.0.0.1
trapcommunity public
trapsink 1.2.3.4 public
sysname server.domain.com (please add it yourself)
syscontact Root (configure /etc/snmp/snmp.local.conf)
syslocation Unknown (edit /etc/snmp/snmpd.conf)

# ---------------------- END --------------------
note: you need to configure snmptoemail on 1.2.3.4 as follows:
[root@app~]# more /etc/snmp/snmptrapd.conf
traphandle default /usr/bin/perl /usr/bin/traptoemail -s localhost -f hpsnmptrap@domain.com JepheWu@domain.com
traphandle default /usr/bin/perl /usr/bin/traptoemail -s localhost -f hpsnmptrap@domain.com WuATing@domain.com

also, comment out the following requiretty line from /etc/sudoers so that you can send test trap mail from hpsmh webpage
[root@server snmp]# grep -e requiretty -e hpsmh /etc/sudoers
#Defaults requiretty
%hpsmh ALL=NOPASSWD:/etc/init.d/snmpd
%hpsmh ALL=NOPASSWD:/usr/bin/snmptrap
  • snmp email alert
configuring sendmail in dns-less environment to send out email alert
  1. put the following parts to /etc/mail/sendmail.mc
[root@server mail]# grep -e root -e MASQ -e SMART sendmail.mc
define(`SMART_HOST', `mailrelay')dnl
dnl EXPOSED_USER(`root')dnl
MASQUERADE_AS(`domain.com')dnl
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(db.domain.com)dnl
MASQUERADE_DOMAIN(domain.com)dnl


run m4 sendmail.mc > sendmail.cf

2. create file /etc/mail/service.switch and give it right permission (smmsp user can read it )
put 'hosts files' to /etc/mail/service.switch, so it should have permission 640 and owned by root:smmsp

3. put 1.2.3.4 which mail server ip address into /etc/hosts
1.2.3.4 mailrelay

use the following command to find out the path for sendmail.cf and service.switch
strings /usr/sbin/sendmail | grep sendmail.cf
strings /usr/sbin/sendmail | grep service.switch

4. put root alias in /etc/aliases
root: admin1@domain.com,admin2@domain.com

then run newaliases

5. send a test email
# echo testing | /usr/sbin/sendmail -v root