Bài đăng phổ biến

Friday, October 19, 2012

Monitor hardisk HP server sent to zabbix


hp.sh



#!/bin/bash
#Writed by [email protected][dot]com[dot]vn - [email protected][dot]com
#skype: nguyen_si_nhan
#Program'll send alert hdd HP status to zabbix

#check snmpwalk installed
[ ! -f "/usr/bin/snmpwalk" ] && { echo "can not find snmpwalk plz install net-snmp-utils"; exit 1; }

/usr/bin/snmpwalk -v2c -c public localhost 1.3.6.1.4.1.232.3.2.5.1.1.6 >/tmp/hp.tmp
#Line=wc -l </tmp/hp.tmp
#Get value return==status hdd
grep -Eo '.$' /tmp/hp.tmp >/tmp/count.tmp
_file1="/tmp/hp.tmp"
#check empty file
if [ ! -s "$_file1" ]
then
echo "Plz install hp snmp agent"
exit 2
fi
StatusFail=0
while read line; do
#HI=echo $line | awk '{print substr($0,length,1)}'
if [[ "$line" = 3 ]]; then
        ((StatusFail=1))
fi
done < /tmp/count.tmp

echo "StatusFail $StatusFail"

/opt/zabbix/bin/zabbix_sender -c /opt/check.conf -k hddstatus -o $StatusFail

=====================

Notice : Change /opt/check.conf to correct your path zabbix agent

Nguyen Si Nhan - 19/10/2012