Changing services states on host event handler?

I everyone,

after finding how to disable services check when host is down (thx to Strides). I would like to manually change services states of a host when the host going down or unreachable.

Example :

If Host A is DOWN, services check of this host is disabled and each services of host A change state to UNKNOWN. Then, when host A change state to UP, services check are enabled and services states are changed to OK.

I have check external command, it seems that there is no command to change state and I don’t have access on services macro when passing trough host event handler.

Anyone know a good solution for that ?

Thx in advance.

nagios.org/developerinfo/ext … and_id=114
this should answer your question, as you already know about external commands :slight_smile:

Thx Loose, I don’t know how I didn’t notice this command !lol

Just need to check wish macro available in the host event handler, would give list of of service description for the host. :roll:

Hi Eryas

If you can find the macro to do that, please let us know what it is :slight_smile:

I ended up resorting to using a “wget” statement to get me a list of services for a particular host by grepping and sedding them out of the host’s status.cgi webpage, maybe you can make use of it too…

wget --quiet --output-document=- --http-user=NAGIOSUSER --http-password=NAGIOSPASSWORDhttp://127.0.0.1/nagios/cgi-bin/status.cgi?host=HOSTNAME” | grep “HREF='extinfo.cgi?type=2&host=HOSTNAME&service=”| sed -e :a -e ‘s/<^>]*>//g;/</N;//ba’

it works a treat for me…

[root@localhost ~]# wget --quiet --output-document=- --http-user=******** --http-password=######## "http://127.0.0.1/nagios/cgi-bin/status.cgi?host=localhost" | grep "HREF='extinfo.cgi?type=2&host=localhost&service="| sed -e :a -e 's/<^>]*>//g;/</N;//ba' Current Load Current Users HTTP PING Root Partition SMS3 Processes - smsd SSH Swap Percent Usage Swap Usage Total Processes Var Partition [root@localhost ~]#

HTH

/S

Thx for the solution :slight_smile:

Not a bad solution, but I’ve developed my own PHP interface. So I’m not using CGI anymore.

Need to find other way to get these services description

well if your php interface doesn’t give you a similar view of the status of all services running on a host then that is certainly a show stopper. Another way you could do it would be to script something that would parse status.dat and pull out the services relating to the appropriate host in the “servicestatus {” segments… I tried to do something similar with variable success but finally gave up once I worked out how to wget the same thing in a one-liner…

Yeah, I’ve thought about searching every services for the host in my SQLite database (I have changed status.dat to a sqlite database).

Not the most fast way, but I think it’s the only way !lol