监控HP服务器CPU温度的脚本:
#!/bin/bash
Name=`hostname`
IP=`/sbin/ifconfig eth0 | grep "inet addr" | awk -F[:" "]+ '{print $4}'`
Date=`date +%m%d%y`
Date2=`date +%H:%M`
Num=`/usr/sbin/dmidecode | grep -i 'serial number' | head -n 1`
CPU1=`/sbin/hpasmcli -s "show temp" | grep CPU#2 | awk -F[:" "]+ '{print $3}' | cut -b 1-2`
CPU2=`/sbin/hpasmcli -s "show temp" | grep CPU#3 | awk -F[:" "]+ '{print $3}' | cut -b 1-2`
CPU3=60
if [ $(echo "$CPU1 > $CPU3" | bc) -eq 1 ] || [ $(echo "$CPU2 > $CPU3" | bc) -eq 1 ]
then
/usr/bin/touch /log/CPU/hot.log
/bin/echo "$Name($IP) CPU1 is $CPU1 C and CPU2 is $CPU2 C at $Date2" > /log/CPU/hot.log
/usr/bin/mail -s "$Name($IP) Load is $Load" zhi.yang@ming.com < /log/Load/$Date.log
fi