Page 1 of 1

Viewing Open Problems from the Command Line

Posted: Tue Apr 03, 2012 8:28 pm
by bvinisky
Is there an easy way to view open problems (host and service) via the command line? I've reviewed this list http://old.nagios.org/developerinfo/ext ... ndlist.php but didn't see anything that would dump out any current host and service problems. My end goal is to pipe a list of host and service problems back into ACKNOWLEDGE_SVC_PROBLEM so a filtered number of alerts can be acked from the command line. My issue is getting the <service_description> (of which we have a ton) for any service that's in a hard state.

I'm using NagiosXI and also have the backend API installed, but that doesn't have a list of just the open problems, though there is a massive Current Service Status. I'm trying to avoid having to transform that XML, though it could be used if there's no alternative.

Thanks!

Bryant

Re: Viewing Open Problems from the Command Line

Posted: Wed Apr 04, 2012 12:57 pm
by scottwilkerson
Using the backend API you can append filters to the URL, like adding the following to the getservicestatus call

Code: Select all

&current_state=2
would show all services with current_state of 2

Re: Viewing Open Problems from the Command Line

Posted: Thu Apr 05, 2012 5:21 pm
by bvinisky
Thanks scottwilkerson! That's just what I needed. Posting current_state=2, state_type=1 and problem_acknowledged=0 to the NagiosXI backend API gave me the list I was after. I was then able to filter out the host_name and name (which is the service_description that the external command ACKNOWLEDGE_SVC_PROBLEM requires). This and the other required data was easily posted via NRDP so everything could be acknowledged via the command line. Sweet deal!

Bryant