<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hello,<BR>
 <BR>
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.<BR>
 <BR>
I passed long time trying to find the answer but I couldn't. Maybe somebody knows why. Here is the script:<BR>
 <BR>
while true ; do<BR>  LAMP=0<BR>  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`<BR>  if (( $RESULT > 0 )) ; then<BR>    # A host has a problem : Red Light<BR>    ./light red<BR>    LAMP=1<BR>    # Light is set<BR>  fi<BR>
  if [[ $LAMP = "0" ]] ; then<BR>    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`<BR>    if (( $RESULT > 0 )) ; then<BR>      # Service is critic: Red Light<BR>      ./light red<BR>      LAMP=1<BR>    fi<BR>  fi<BR>
  if [[ $LAMP = "0" ]] ; then<BR>    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`<BR>    if (( $RESULT > 0 )) ; then<BR>      # Service is warning : Yellow Light<BR>      ./light yellow<BR>      LAMP=1<BR>    fi<BR>  fi<BR>
  if [[ $LAMP = "0" ]] ; then<BR>    # No problem : Green Light<BR>    ./light green<BR>  fi<BR>  sleep 30<BR>  LAMP=0<BR>done<BR>
 <BR>
Regards,<BR>
Jorge<BR><BR><BR><br /><hr />¡Trónchate de risa con los mejores capítulos de South Park en  <a href='http://video.msn.com/?mkt=es-es&vid=42a9e969-45ad-4c31-bff9-57629e71fac8&playlist=videoByUuids:uuids:e1daa69b-331b-4e99-8325-c936aaee9f97%2Cad4cb47a-90a8-4b2c-88da-116d2059f4a2%2Cddaade1e-82b2-4914-8277-35e45198f5c6%2C42860247-e337-4384-94d8-fa444cb4aea7&from=hotmail&tab=s1207179071824' target='_new'>MSN Vídeo!</a></body>
</html>