Page 1 of 1

Force an immediate check immediately upon adding HOST

Posted: Sun Jun 09, 2019 4:33 am
by zaji_nms
Dear Expert

when we adding new HOST with Services, or new SERVICES, specially Status and Bandwidth

its taking to long to check the services, we want some sort of option (feature request) upon adding the Services, please check newly added services to : Force an immediate check by Auto upon user request (user choice).

Regards

Re: Force an immediate check immediately upon adding HOST

Posted: Mon Jun 10, 2019 9:21 am
by lmiltchev
You could use the REST API to add a new host, and then schedule a forced immediate check by submitting a core command. Both commands could be placed in a bash script, for example:

Code: Select all

#!/bin/bash

curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/host?apikey=xxx&pretty=1" -d "host_name=testapihost&address=127.0.0.1&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1"

curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/system/corecommand?apikey=xxx" -d "cmd=SCHEDULE_FORCED_HOST_CHECK;localhost"
Make the script executable:

Code: Select all

chmod +x myscript.sh
and run it:

Code: Select all

./myscript.sh
This will add a host named "testapihost", and will scheduled a forced immediate check on it.