Is there the possibllity to query a service status from shel


#1

Hi dear,
I’ve write a custom perl to manage the incoming trap.
I need to check the number of soft state of a service to avoid to send an email after just 1/4 check.

So my question if can I query nagios to get the number of attempt of a service?

Thanks
Zioalex


#2

Not met a way to do this directly personally but that doesn’t of course mean there isn’t a way !shy You could parse status.dat and work it out based on the values in the servicestatus entry for that service, such as:

servicestatus { host_name= service_description= current_state= current_attempt= max_attempts= ..... ..…but that’s just horrible.
I’d probably look at doing something like a wget (or use libwww-perl etc) of the nagios “…/extinfo.cgii?type=2&host=YOURHOST&service=YOURSERVICE” webpage for the service in question, and then grep the source for the occurance of something like WARNING and SOFT.

HTH

/S


#3

Umh…Thanks Strides
This is possible…but is not so forward!!! If I didn’t find any solution I think I will be do that.

But perhaps there is some way, to count the attempt with a trap/passive service…
I’ve to investigate this.


#4

Wget is straight forward and it deffo works…

[code][root@localhost nagios]# wget --quiet --output-document=- --http-user= --http-password= “http://your.server.com/nagios/cgi-bin/extinfo.cgi?type=2&host=your-host&service=your-service” | grep SOFT

Current Attempt: 1/3 (SOFT state) [root@localhost nagios]# [/code] You could even pipe it through **wc -l** if you'd rather see "1" rather than "<TD CLASS='d...etc"

#5

Hey zioalex,

There is no way to get nagios to pass that info back. It’s simply reading from status.dat. So, follow Strides suggestions, they are good!