Force an immediate check immediately upon adding HOST

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

Force an immediate check immediately upon adding HOST

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Force an immediate check immediately upon adding HOST

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked