#!/bin/bash # # Written by Dieter Plaetinck # Updated by Bernhard Brunner: output for conky # # Licensed under the GPL V3 # See gnu.org/licenses/gpl-3.0.html # # works for Nagios 2.x or nagios 3.x URL=http://nagiosserver/nagios3/cgi-bin/tac.cgi USERNAME=nagiosadmin PASSWORD= PAGE=$(curl -s -k -u $USERNAME:$PASSWORD $URL) #echo $PAGE HOSTS_DOWN=$( echo -e "$PAGE" | grep "hoststatustypes=4' class='hostHeader'" | awk '{print $5}' | cut -c 20-) HOSTS_UNREACHABLE=$( echo -e "$PAGE" | grep "hoststatustypes=8' class='hostHeader'" | awk '{print $5}' | cut -c 20-) HOSTS_UP=$( echo -e "$PAGE" | grep "hoststatustypes=2' class='hostHeader'" | awk '{print $5}' | cut -c 20-) HOSTS_PENDING=$( echo -e "$PAGE" | grep "hoststatustypes=1' class='hostHeader'" | awk '{print $5}' | cut -c 20-) SERVICES_CRIT=$( echo -e "$PAGE" | grep "servicestatustypes=16' class='serviceHeader'" | awk '{print $5}' | cut -c 23-) SERVICES_WARN=$( echo -e "$PAGE" | grep "servicestatustypes=4' class='serviceHeader'" | awk '{print $5}' | cut -c 23-) SERVICES_UNKNOWN=$( echo -e "$PAGE" | grep "servicestatustypes=8' class='serviceHeader'" | awk '{print $5}' | cut -c 23-) SERVICES_OK=$( echo -e "$PAGE" | grep "servicestatustypes=2' class='serviceHeader'" | awk '{print $5}' | cut -c 23-) SERVICES_PENDING=$( echo -e "$PAGE" | grep "servicestatustypes=1' class='serviceHeader'" | awk '{print $5}' | cut -c 23-) if [[ "$HOSTS_DOWN" == "" ]] then echo '${font Radio Space:size=13}${color red}Nagios:DOWN${color}${font}' else if [[ $(($HOSTS_DOWN + $SERVICES_CRIT)) > 0 ]] then echo '${font Radio Space:size=13}${color red}Nagios:ERROR${color}${font}' else if [[ $SERVICES_WARN > 0 ]] then echo '${font Radio Space:size=12}${color orange}Nagios:Warn${color}${font}' else echo '${font Radio Space:size=11}${color }Nagios:OK${color}${font}' fi fi fi