Set Acknowledgement via API
Posted: Tue Jul 25, 2017 11:33 am
Is it possible to use the REST API to set acknowledgements on a host or service?
Support for Nagios products and services
https://support.nagios.com/forum/
It appears we're able to authenticate via that method, but all we get is this.dwhitfield wrote:Not right now, but the developers have said it is in the roadmap for the future. It can be done via cmd.cgi. This is ***not*** for acknowledgements, but the syntax would be something like the following:
curl -d "cmd_typ=23&cmd_mod=2&host=[THE-HOST]&service=[THE-SERVICE]&btnSubmit=Commit" "http://[NAGIOS-SERVER]/nagios/cgi-bin/cmd.cgi"
Code: Select all
External Command Interface
Last Updated: Tue Jul 25 16:21:26 EDT 2017
Nagios® Core⢠4.2.4 - www.nagios.org
Logged in as ?
Sorry, but you are not authorized to commit the specified command.
Read the section of the documentation that deals with authentication and authorization in the CGIs for more information.Code: Select all
curl -u user:pass -d "cmd_typ=33&cmd_mod=2&host=AAA-TEST-HOST&service=host&btnSubmit=Commit" "http://nagios/nagios/cgi-bin/cmd.cgi"Code: Select all
#!/bin/sh
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;localhost;Total Processes;2;1;1;test;Oh boy\n" $now > $commandfilePM sent, the documentation you linked is what we were looking at.dwhitfield wrote:Here's the documentation (in case you were looking at something else): https://assets.nagios.com/downloads/nag ... t_commands
Can you PM me your Profile so we can take a look to see if there is something else that could be getting in the way? You can download it by going to Admin > System Config > System Profile and click the ***Download Profile*** button towards the top. If for whatever reason you *cannot* download the profile, please put the output of View System Info (5.3.4+, Show Profile if older) in the thread (that will at least get us some info). This will give us access to many of the logs we would otherwise ask for individually. If security is a concern, you can unzip the profile take out what you like, and then zip it up again. We may end up needing something you remove, but we can ask for that specifically.
After you PM the profile, please update this thread. Updating this thread is the only way for it to show back up on our dashboard.
We're trying to integrate our OTRS ticketing system with Nagios using their SystemMonitoring module. We've got everything working but the acknowledgment of issues in Nagios via the ticketing system. So we're trying to acknowledge issues from a remote server at this point. Would your example work for this?lmiltchev wrote:I got the same error as you. I haven't played a lot with the curl command, but why don't you just use the Nagios external commands to ack issues?
Example:Here's the external commands for acknowledging host and service problems:Code: Select all
#!/bin/sh now=`date +%s` commandfile='/usr/local/nagios/var/rw/nagios.cmd' /bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;localhost;Total Processes;2;1;1;test;Oh boy\n" $now > $commandfile
https://old.nagios.org/developerinfo/ex ... mand_id=39
Note: Host name and service description are "hard-coded" in this example, but you could pass them as arguments to the bash script if you wish.
Hope this helps.
https://old.nagios.org/developerinfo/ex ... mand_id=40
Yea we have the logic, what I'm confused about is how OTRS is supposed to trigger it on the XI side.dwhitfield wrote:You'd need to build in the logic for OTRS to kick off the script @lmiltchev provided, but yes, it should work.
There are a number of ways to get things to XI, but my thought is running the script via ssh from the OTRS server: https://www.cyberciti.biz/faq/unix-linu ... using-ssh/Ehamby wrote: That script seems local to XI, how is OTRS supposed to send the command to XI?