Page 1 of 2

Nagios API

Posted: Fri Nov 06, 2015 4:17 pm
by gabrotherton
Hello experts,

I'm looking for the appropriate Nagios API topic, and I'm not quite sure what I'm looking for at the moment.

We have a need to send specific messages that Nagios already displays to another server which uses a CORBA interface. (The CORBA interface we can handle, that's not the issue.) Where can I find the proper API that I could use to write a small client to simply listen for Nagios messages? (If that makes sense.)

Thanks,
Gene

Re: Nagios API

Posted: Sun Nov 08, 2015 12:17 am
by tmcdonald
In Nagios XI you can enable outbound checks:

https://assets.nagios.com/downloads/nag ... ith_XI.pdf

However those assume you are talking to another XI system. The best route would be to use the outbound NRDP settings, as that is XML based and not an incredibly difficult protocol. If you go to http://yournagiosxi/nrdp you can see an example message:

Code: Select all

<?xml version='1.0'?> 
<checkresults>
	<checkresult type='host'>
		<hostname>somehost</hostname>
		<state>0</state>
		<output>Everything looks okay!|perfdata</output>
	</checkresult>
	<checkresult type='service'>
		<hostname>somehost</hostname>
		<servicename>someservice</servicename>
		<state>1</state>
		<output>WARNING: Danger Will Robinson!|perfdata</output>
	</checkresult>
</checkresults>


Re: Nagios API

Posted: Sun Nov 08, 2015 10:01 am
by gabrotherton
thanks very much! I'll give this a try when I get in tomorrow morning.

When NRDP is enabled, will every message Nagios displays also be produced with this XML type of message format? So basically I could consume these XML messages and do whatever I need with those.

I tried going down this same path by enabling SNMP forwarding (which works, I can see the Nagios SNMP messages through an instance of snmptrapd running as root). But we are looking for the least complex implementation and SNMP messages/traps seemed quite complex for what we need.

Re: Nagios API

Posted: Mon Nov 09, 2015 10:33 am
by tmcdonald
Just the host and service check results should be forwarded, you won't get things like "User logged into XI" or "Configuration was successfully applied".

Re: Nagios API

Posted: Mon Nov 09, 2015 10:34 am
by gabrotherton
Where is the document that outlines how to enable NRDP correctly?

Under the outbound configuration global settings options I have enabled the outbound transfers. Under the Filters, I am excluding localhost and the IP address (/^localhost/ and /^127\.0\.0\.1/ both separated with a new line).
Under the NRDP settings, I have enabled NRDP output. The target host is 10.0.0.160 (which is the Nagios host's IP address). And the token is set to an alphanumeric string.

The NRDP interface http://10.0.0.160/nrdp/ shows me two options, one for Submit Nagios Command (which I did not try because I didn't know what I was submitting). The other Submit Check Data, which I did try with the token and http method I set under the Outbound settings. This was the default text in the Check Data field:

Code: Select all

<?xml version='1.0'?> 
<checkresults>
	<checkresult type='host'>
		<hostname>somehost</hostname>
		<state>0</state>
		<output>Everything looks okay!|perfdata</output>
	</checkresult>
	<checkresult type='service'>
		<hostname>somehost</hostname>
		<servicename>someservice</servicename>
		<state>1</state>
		<output>WARNING: Danger Will Robinson!|perfdata</output>
	</checkresult>
</checkresults>

The results were this:
<result><status>-1</status><message>BAD TOKEN</message></result>

Which I was not expecting. I re-verified the tokens and I'm still getting these results after submitting check data.

What am I missing?

Once the outbound transfers are working, how should I use the NRDP agent to consume them?

tmcdonald wrote:In Nagios XI you can enable outbound checks:

https://assets.nagios.com/downloads/nag ... ith_XI.pdf

However those assume you are talking to another XI system. The best route would be to use the outbound NRDP settings, as that is XML based and not an incredibly difficult protocol. If you go to http://yournagiosxi/nrdp you can see an example message:

Code: Select all

<?xml version='1.0'?> 
<checkresults>
	<checkresult type='host'>
		<hostname>somehost</hostname>
		<state>0</state>
		<output>Everything looks okay!|perfdata</output>
	</checkresult>
	<checkresult type='service'>
		<hostname>somehost</hostname>
		<servicename>someservice</servicename>
		<state>1</state>
		<output>WARNING: Danger Will Robinson!|perfdata</output>
	</checkresult>
</checkresults>


Re: Nagios API

Posted: Mon Nov 09, 2015 10:55 am
by gabrotherton
I think I'm missing the fact I never configured the NRDP server after installation.

I found /usr/local/nrdp/INSTALL.TXT

and I'm reading through that now.

Re: Nagios API

Posted: Mon Nov 09, 2015 11:40 am
by gabrotherton
Ok, so the Submit Data Check is working now. I got this response after I configured the NRDP server correctly:

Code: Select all

<result><status>0</status><message>OK</message><meta><output>2 checks processed.</output></meta></result>
Question now, how do I consume these kinds of messages? How should I subscribe to the Nagios XI server that to see the NRDP messages? Or where should I point my XML parser to?

Re: Nagios API

Posted: Mon Nov 09, 2015 12:03 pm
by lmiltchev
I am not familiar with the "CORBA" interface but In XI passive checks would show up under the "Unconfigured Objects" (if they haven't been configured already via the "Unconfigured Object Configuration wizard).

https://assets.nagios.com/downloads/nag ... ith_XI.pdf

https://assets.nagios.com/downloads/nag ... ith_XI.pdf

Re: Nagios API

Posted: Mon Nov 09, 2015 12:25 pm
by gabrotherton
Thanks for the reply, however, we are interested in data flowing out from Nagios XI to another app. From what tmcdonald said in his posts, XI should be forwarding host and service messages formatted in XML and I should be able to consume those messages. I just don't know how to subscribe or poll for that information. I need to consume Nagios XI messages.

The CORBA part is on our side and we have in-house expertise for that.

Re: Nagios API

Posted: Mon Nov 09, 2015 12:42 pm
by tmcdonald
Sorry if I implied this instead of saying it outright, but NRDP on the COBRA machine might need to be modified a bit and some "glue" will be needed to make NRDP-formatted messaged work with COBRA. As you can understand, our NDRP format is meant to work with other Nagios machines, and is not a general-purpose solution for third-party integration. Unfortunately this is not something we can assist with from a support perspective, but we do offer custom development if you need something tailored to your organization's needs. I would be happy to get you in touch with the right people for that if you need.