Hello,
 
I have adapted a bash script to display the overall status of Nagios in a 
Semaphore thanks to NDOutils. The script query the database and depending on 
the results it changes the lights of the semaphore. The script works almost 
good, whenever a host is offline, the semaphore goes red,  but when a service 
is critical, the semaphore stays in green. It worked with another server of 
Nagios, but now I installed Nagios in a new server and as I have said it 
doesn't detect the change of states of services.
 
I passed long time trying to find the answer but I couldn't. Maybe somebody 
knows why. Here is the script:
 
while true ; do  LAMP=0  RESULT=`echo "SELECT instance_id FROM 
nagios_hoststatus WHERE current_state <> 0 AND problem_has_been_acknowledged = 
0;" | mysql --host myhost.domain.xx--user nagios --password=nagios nagios | wc 
-l`  if (( $RESULT > 0 )) ; then    # A host has a problem : Red Light    
./light red    LAMP=1    # Light is set  fi
  if [[ $LAMP = "0" ]] ; then    RESULT=`echo "SELECT 
nagios_servicestatus.service_object_id FROM ((nagios_servicestatus INNER JOIN 
nagios_services ON 
nagios_servicestatus.service_object_id=nagios_services.service_object_id) INNER 
JOIN nagios_hosts ON 
nagios_services.host_object_id=nagios_hosts.host_object_id) INNER JOIN 
nagios_hoststatus ON nagios_hosts.host_id=nagios_hoststatus.hoststatus_id WHERE 
nagios_servicestatus.current_state > 1 AND 
nagios_servicestatus.problem_has_been_acknowledged=0 AND 
nagios_hoststatus.problem_has_been_acknowledged=0;" | mysql --host 
myhost.domain.xx--user nagios --password=nagios nagios | wc -l`    if (( 
$RESULT > 0 )) ; then      # Service is critic: Red Light      ./light red      
LAMP=1    fi  fi
  if [[ $LAMP = "0" ]] ; then    RESULT=`echo " SELECT 
nagios_servicestatus.service_object_id FROM ((nagios_servicestatus INNER JOIN 
nagios_services ON 
nagios_servicestatus.service_object_id=nagios_services.service_object_id) INNER 
JOIN nagios_hosts ON 
nagios_services.host_object_id=nagios_hosts.host_object_id) INNER JOIN 
nagios_hoststatus ON nagios_hosts.host_id=nagios_hoststatus.hoststatus_id WHERE 
nagios_servicestatus.current_state = 1 AND 
nagios_servicestatus.problem_has_been_acknowledged=0 AND 
nagios_hoststatus.problem_has_been_acknowledged=0;" | mysql --host 
myhost.domain.xx --user nagios --password=nagios nagios | wc -l`    if (( 
$RESULT > 0 )) ; then      # Service is warning : Yellow Light      ./light 
yellow      LAMP=1    fi  fi
  if [[ $LAMP = "0" ]] ; then    # No problem : Green Light    ./light green  
fi  sleep 30  LAMP=0done
 
Regards,
Jorge
_________________________________________________________________
¡Entra en el Club oficial de Messenger y te enterarás de todas las novedades! 
http://www.vivelive.com/ilovemessenger
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nagios-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to