Enable\disable host monitoring "on-demand" using an API call or with icingacli

In my company, we have some application on server that are started\required “On-Demand”.
When this kind of server (usually in the public cloud) are requested\turned ON.
Then I need to start to monitoring it.
Usually they are Turned OFF so I cannot use a TimePeriod to reach this goal.
I need something that enable\disable the monitoring for these servers when they are started.

I use RUNDECK as job scheduler - so I’m asking if there is a “command” or a API call I can use to anable\disable the monitoring for this server.

If this is a cloud server you can use the boot time cloud-init execution to send an API call the register with Icinga and start the monitoring.
you can also send an API call and alter the run time attributes to disable the active status



Which you should be able to alter with the API


The server is just registered and configured on ICINGA.
Yes, it is in the cloud but in this case id does not matter, i mean.
But due to the fact that is consumed on demand - I cannot use the Downtime scheduled or Timeperiod to monitor it.
I need something that ENABLE Monitoring at startup, and after DISABLE monitoring at shutdown.

Hi PiCo,

Assaf already had a good idea here. You start with active checks disabled, that is enable_active_checks = false in your config. Later you modify this attribute via the API and enable it:

curl -k -u 'user:password' -H 'Accept: application/json' \
-d '{ "attrs": { "enable_active_checks": true } }' \

All the best,

1 Like

I Try your command with my HOST…
But unfortunately do not work.
I receive error:
{“error”:404.0,“status”:“No objects found.”}
I used this command running from ICINGA server:

curl -k -u ‘MYUSER:MYPSWD’ -H ‘Accept: application/json’ -d ‘{ “attrs”: { “enable_active_checks”: true } }’ ‘https://localhost:5665/v1/objects/hosts?filter=MYHOSTNAME

But give me the error above!

Hi @picoroma,

you can simply filter by host name like this:

curl -k -u 'MYUSER:MYPSWD' -H 'Accept: application/json' -d '{ "attrs": { "enable_active_checks": true } }' https://localhost:5665/v1/objects/hosts?host=MYHOSTNAME

This uses just host=MYHOSTNAME.

Alternatively you can use advanced filters. Have a look into the documentation, if need something more complex: https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#filters


1 Like

I still have error…
I do not undestand why!
Unfortunately I do not know very well curl…
But the commandis quite simple!

Hi @picoroma,

does your hostname have special characters like spaces in it? You need to URL encode those then.
Example: TestHost - 1 => TestHost%20-%201

Just search for “URL encode” in your favorite search engine and you’ll find many web based tools that can help you with that, if needed.

Also keep in mind, that you can’t use wildcard characters in host=. That would need advanced filters.


NO. No spaces into the Hostname.
I use only _ “UnderScore” . Somthing like My_HostName_N1
But do not work the API!

Okay, that should work without encoding then.
One thing you can try:

curl -k -u 'USER:PASSWORD' -H 'Accept: application/json' https://localhost:5665/v1/objects/hosts?pretty=1

That should return all hosts you have configured. If you can’t find that specific host in that list, it’s most likely not configured correctly or your user doesn’t have the right permissions. (https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#permissions)

You can also use the following command to search for your host in the CLI:

# You can also use wildcards like TestHost_* here
icinga2 object list --type host --name TestHost_1 

If you can’t find it with that command, it’s not configured on that Icinga instance.

OK. The host was initially DISABLED and due to this, was not found by curl.
After I ENABLED the monitoring for this host - I was able to find it with curl.
But I’m looking just for something that ENABLE\DISABLE the host&services monitoring…
If curl do not found the host When it is DISABLED - This procedure cannot be used!
Any other ideas ?
My goal is to modify this properties with curl:
Is possible ?


Okay, in that case it’s important to know that you’re using the Director. The way we showed you just disables active checks on a host and doesn’t disable the whole object. That never touched the Director side of things.

What you want can be done using the Director API:

# Disable
curl -X POST -H 'Accept: application/json' -u 'ICINGAWEB2_USER:ICINGAWEB2_PW' -d '{ "disabled": 1 }' 'https://localhost/icingaweb2/director/host?name=TestHost_1' 

# Enable
curl -X POST -H 'Accept: application/json' -u 'ICINGAWEB2_USER:ICINGAWEB2_PW' -d '{ "disabled": 0 }' 'https://localhost/icingaweb2/director/host?name=TestHost_1' 

Another way of disabling a host in the Director is by using the Director CLI:

# Disable
icingacli director host set TestHost_1 --disabled 1

# Enable
icingacli director host set TestHost_1 --disabled 0

I try with curl and xcept for http instead of https (I do not use https) - Seems to work fine!
… But after I need to perform a Deploy. Is there a way to perform a deploy using curl ?
Also with other command (cli) you need to perform a deploy in order to changes take effect

Yes, triggering a deploy via the API is possible:

curl -X POST -H 'Accept: application/json' -u 'ICINGAWEB2_USER:ICINGAWEB2_PW' 'https://localhost/icingaweb2/director/config/deploy' 
1 Like