Can I update Nagios active service status using Rest API
Can I update Nagios active service status using Rest API
Hi,
I am using Nagios XI 5.8.1.
I know that we can use rest API to add/update service configuration into Nagios XI. Just wonder is it possible to update defined active service status information using API?
Like set the current_state, output, perfdata etc. of the defined active check service in Nagios XI.
Thanks
Joseph
I am using Nagios XI 5.8.1.
I know that we can use rest API to add/update service configuration into Nagios XI. Just wonder is it possible to update defined active service status information using API?
Like set the current_state, output, perfdata etc. of the defined active check service in Nagios XI.
Thanks
Joseph
Re: Can I update Nagios active service status using Rest API
The only way you can change them would be to submit another result through the API, see here on your XI server:
With these commands:
https://assets.nagios.com/downloads/nag ... ernalcmds/
These specifically:
https://assets.nagios.com/downloads/nag ... and_id=114
https://assets.nagios.com/downloads/nag ... and_id=115
Code: Select all
http://YOURXISERVER/nagiosxi/help/api-system-reference.php#system-core-command
https://assets.nagios.com/downloads/nag ... ernalcmds/
These specifically:
https://assets.nagios.com/downloads/nag ... and_id=114
https://assets.nagios.com/downloads/nag ... and_id=115
Re: Can I update Nagios active service status using Rest API
Hi ssax,
Thank you so much for the info. It works.
One more thing, how do I pass the performance data (perfdata, format or position)?
PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>
The "plugin_output" field contains text output from the service check, along with optional performance data.
Thank you,
Joseph
Thank you so much for the info. It works.
One more thing, how do I pass the performance data (perfdata, format or position)?
PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>
The "plugin_output" field contains text output from the service check, along with optional performance data.
Thank you,
Joseph
Re: Can I update Nagios active service status using Rest API
Go view the service under Home > Service Status and click on the service, then click the + tab and look at the Performance Data column, that would be the perfdata format you would use after a pipe (|) character
Code: Select all
PROCESS_SERVICE_CHECK_RESULT;localhost;SSH;0;SSH OK - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000
Code: Select all
curl -k -L -XPOST "https://X.X.X.X/nagiosxi/api/v1/system/corecommand?apikey=YYYYY" -d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost;SSH;0;SSH OK - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'
Re: Can I update Nagios active service status using Rest API
it worked. Thank you!
Re: Can I update Nagios active service status using Rest API
Great! Let us know when we're okay to lock this up and mark it as resolved.
Re: Can I update Nagios active service status using Rest API
Hi ssax,
One more question:
Is there a rate limit we should consider when posting commands to the the Core Command API?
I have about 10000 services to update using the core command API you mentioned, it took me about 20 minutes to get updated in Nagios. in the rate of 500 posting command per minutes.
Any suggestion to speed up these process? The faster the better.
Let me know if you need more info.
Thanks
Joseph
One more question:
Is there a rate limit we should consider when posting commands to the the Core Command API?
I have about 10000 services to update using the core command API you mentioned, it took me about 20 minutes to get updated in Nagios. in the rate of 500 posting command per minutes.
Any suggestion to speed up these process? The faster the better.
Let me know if you need more info.
Thanks
Joseph
Re: Can I update Nagios active service status using Rest API
Edit: What specifically are you trying to do with this? Are you just submitting results or are you trying to reset the checks or something?
Re: Can I update Nagios active service status using Rest API
No. I am not using the apply configuration at all for this API call. Looks like it is not needed.
Re: Can I update Nagios active service status using Rest API
Sorry, I edited the post after I sent it, this was my next question after realizing you're not applying configuration when submitting results:
What specifically are you trying to do with this? Are you just submitting results or are you trying to reset the checks or something?
I'm trying to see if there's a better way to handle what you're trying to do.
What specifically are you trying to do with this? Are you just submitting results or are you trying to reset the checks or something?
I'm trying to see if there's a better way to handle what you're trying to do.