I've been looking at utilising the API to help with our oncall implementation. I was attempting to use the put contact to update the email address for a contact however when i try i get the following
curl -XPUT "http://[nagios address]/api/v1/config/contact/testcontact?apikey=[secret api key]&pretty=1&email=jsmith"
{
"success": "Updated testcontact in the system. Config imported but not yet applied."
}
When i check why its not restarted it's because it's created a blank command as testcontact instead of updating the already created contact testcontact. When using post or delete it works correctly but put contact doesn't seem to work.
I'm using 5.6.3
Nagios API Put Contact
Re: Nagios API Put Contact
I was able to recreate the issue - there is a typo in one of the files.
Open /usr/local/nagiosxi/html/api/includes/utils-api.inc.php in a text editor, and go to line 387. Replace this:
with this:
Let us know if this helped.
![Sad :(](./images/smilies/icon_e_sad.gif)
Open /usr/local/nagiosxi/html/api/includes/utils-api.inc.php in a text editor, and go to line 387. Replace this:
Code: Select all
api_config_edit_cfg_command
Code: Select all
api_config_edit_cfg_contact
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 32
- Joined: Wed Apr 17, 2019 5:28 am
Re: Nagios API Put Contact
This solved the problem, it updates the contact, I still get "config imported but not applied" when i run the command though
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios API Put Contact
This part is normal, if you want to apply configuration immediately, you would want to add the following to the URL in the curl command
Code: Select all
&applyconfig=1
-
- Posts: 32
- Joined: Wed Apr 17, 2019 5:28 am
Re: Nagios API Put Contact
Thank you for your help. You can lock this if you like
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios API Put Contact
great!infofedsec wrote:Thank you for your help. You can lock this if you like
Locking