Report like:-

Date               Time   Critical  Warning  Unknown  HostUnreachable  Total Hosts
2014-01-15      06:31      3            6          0               0                      103
2014-01-15      06:31      3            6          0               0                      103
2014-01-15      11:38     12           13         0               0                      103

Put this shell script and save it

# vi Report.sh
date=`date +%Y-%m-%d`;
time=`date +%H:%M`;

#Tolal Service CRITICAL WARNING UNKNOWN
wget  –user nagios_user –password 'password' –no-check-certificate -O ./Service_Alerts.html  "http://XXXXXXXX/nagios//cgi-bin/summary.cgi?report=1&displaytype=1&timeperiod=today&hostgroup=all&servicegroup=all&host=all&alerttypes=2&statetypes=2&hoststates=3&servicestates=56" >>/dev/null 2>/dev/null

#Tolal host Unreachable or Down
wget  –user nagios_user –password 'password' –no-check-certificate -O ./Host_Alerts.html  "http://XXXXXXXX/nagios//cgi-bin/summary.cgi?report=1&displaytype=1&timeperiod=today&hostgroup=all&servicegroup=all&host=all&alerttypes=1&statetypes=2&hoststates=3&servicestates=56" >>/dev/null 2>/dev/null

#Total host
wget  –user nagios_user –password 'password' –no-check-certificate -O ./Host_All.html  "http://XXXXXXXX/nagios/cgi-bin/avail.cgi?show_log_entries=&timeperiod=today&host=all&rpttimeperiod=&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringnotrunning=yes&includesoftstates=no&initialassumedhoststate=3&initialassumedservicestate=6&backtrack=4" >>/dev/null 2>/dev/null

echo $date >data
echo $time >>data
cat Service_Alerts.html |grep CRITICAL |wc -l >>data
cat Service_Alerts.html |grep WARNING |wc -l >>data
cat Service_Alerts.html |grep UNKNOWN |wc -l >>data
cat Host_Alerts.html |grep CRITICAL |wc -l >>data
cat Host_All.html |grep host |wc -l >>data

awk -vRS="\n" -vORS="\t" '1' data >>Report.xls
echo "" >>Report.xls
echo "done"

– Now you can set Cron job to scheduel it. smiley

 

Leave a Reply