單用check_snmp_storage.pl監控服務器空間腳本ios
下載check_snmp_storage.plbash
http://nagios-snmp.cvs.sourceforge.net/viewvc/nagios-snmp/plugins服務器
說明:ide
被監控端需安裝snmpd.net
腳本1:ci
#!/bin/bashit
Date=`date +%m%d%y`io
Server="10.0.1.2 10.0.1.3 10.0.1.4"class
for Server in $Serverawk
do
Space=`/usr/local/bin/check_snmp_storage.pl -H $Server -C public -m /home -w 80% -c 90% | awk -F[:" "]+ '{print $4}'`
Space2=`/usr/local/bin/check_snmp_storage.pl -H $Server -C public -m /home -w 80% -c 90% | awk -F[:" "]+ '{print $2}'`
if [ $Space = "WARNING" ] || [ $Space = "CRITICAL" ]
then
touch /log/Size/Home/$Server.log
echo "$Server size status $Space" > /log/Size/Home/$Server.log
echo "$Server use size $Space2" >> /log/Size/Home/$Server.log
/usr/bin/mail -s "$Server size status" zhi.yang@ming.com < /log/Size/Home/$Server.log
fi
done
注:腳本1是按服務器分別發郵件報警
腳本2:
#!/bin/bash
Date=`date +%m%d%y`
Server="10.0.1.2 10.0.1.3 10.0.1.4"
for Server in $Server
do
Home3=`/usr/local/icinga/libexec/check_snmp_storage.pl -H $Server -C public -m /home -w 80% -c 90%`
touch /log/Size/Home/$Date.log
echo "$Server size status $Home3" >> /log/Size/Home/$Date.log
done
/usr/bin/mail -s "Android home size status" zhi.yang@ming.com < /log/Size/Home/$Date.log
/bin/rm /log/Size/Home/$Date.log
注:腳本2是發1個郵件所有列出