Use the API to change threshold one or more services

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nms
Posts: 222
Joined: Wed Sep 28, 2016 9:35 am

Use the API to change threshold one or more services

Post by nms »

Hi all,

We currently run NagiosXI v5.7.3.

with the API backend it seems you can do lots of interesting things.
At present we sometimes use to apply config, for example:

Code: Select all

curl -XPOST "http://<NagiosxiIP>/nagiosxi/api/v1/system/applyconfig?apikey=XXXXXXXXXXXXX"

{"success":"Apply config command has been sent to the backend."}
Was wondering if the API method can be used to update a threshold for one service or services.

Is that possible and can you supply an example in order to achieve that?

Rgds,
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Use the API to change threshold one or more services

Post by benjaminsmith »

Hi,

You can update the check command using the API. However, the string will be for the entire command, check command plus arguments. Each separate argument needs to be separated by an !.

So a command like this:
/usr/local/nagios/libexec/check_ncpa.py -H 192.168.23.142 -t 'welcome' -P 5693 -M 'disk/logical/|' -w '70' -c '90'
Would look like this using an API call. The exclamation point needs to be escaped and %20 is used for spaces.

Code: Select all

 curl -XPUT "https://192.168.23.113/nagiosxi/api/v1/config/service/192.168.23.142/Disk?apikey=sCWXTQ3rHtm483AgRUUtLi04v5ECCVmktCCGoU8mINpPPflWafJbRKeGO8fGjUh6&pretty=1&check_command=check_xi_ncpa\!-t%20'welcome'%20-P%205693%20-M%20'disk/logical/|'%20-w%20'70'%20-c%20'90'&applyconfig=1" 
If you do not need to do this programmatically, the Bulk Mods Tool is very good at updating individual arguments.

Let us know if you have more questions.
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked