blog:display_nagios_status_on_the_desktop_using_conky
This is an old revision of the document!
Display nagios status on the desktop using conky
Conky is a lightweight system monitor which displays arbitrary information on the linux desktop. I wanted to display the nagios status not only in the firefox browser (using the recommended! “nagios checker” extension, but also from the desktop. I found a shell script which was written for xfce and adapted it to output conky compatible output.
How to use it:
- copy-paste the code below into a script file, e.g. $HOME/bin/nagiosmon.sh, and make it executable with chmod +x
- add the call to nagiosmon in your .conkyrc file:
${execpi 53 $HOME/bin/nagiosmon.sh}
#!/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=<nagiosadminpassword> 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
Ref:
~~LINKBACK~~
blog/display_nagios_status_on_the_desktop_using_conky.1277273876.txt.gz · Last modified: 2010-06-23 08:17 by brb
Discussion
When I try to view nagiosmon.sh, I get “Permission Denied Sorry, you don't have enough rights to continue. Perhaps you forgot to login? ”
It was a permission problem. Fixed.
Thanks for reporting!