Reset host vars set via API


I have an Icinga2 setup to monitor the servers and resources of my company. I have previously experimented using the API to change host variables and ran into some problems which were explained in my old thread:

In the end i decided to handle the host vars via the configuration files and just push up new configurations to the Icinga master when the vars needed to be changed.

Unfortunately I still have a few host vars that I set using the API that I cannot revert back to be “unset” by API and then handled by the configuration files. Is there a way to purge old API-changed host vars so that I can continue managing them using pure configuration files?

I’m thinking some database hacking or similar to remove all old revisions set using the API… Have tried to dissect the database schema to understand how something like that can be done but so far without success.

Any ideas would be appreciated.


Is this a tricky one or just nobody who is using the API for configuration update is using configuration files too?

Hello there,
as far as i know, there could be several ways to reset it (not tested, just based on my experience) :

  • /var/lib/icinga2/modified-attributes.conf file on your master, find your modifications there, delete them, check config and restart icinga
  • in the console call the restore_attribute function (not documented), ex :
    get_object(“Host”, “myhost”).restore_attribute(“vars”)

In case you are looking for the old attributes values, you should be able to find them in the original_attributes part of the object.

if you are still wondering from where the config comes from, you can make sure of that with this command line :

icinga2 object list --type Host --name myhost

you should have all attributes known for host and from which config file they are applied / modified.

Hello @phl

Did you get any further with your issue?
We would love to hear back from you :slight_smile:

Have a nice day,

I’m very interested in a solution, too. Unfortunately removing or cleaning /var/lib/icinga2/modified-attributes.conf does not help. removing it and calling
icinga2 daemon --validate && systemctl reload icinga2
does instantly re-create the file with its previous content.

Only way: Stop icinga daemon, remove modified-attributes.conf and restart icinga really reverts to the settings from file.

This can’t be serious, there should be a less intrusive way!

I don’t know how this get_object(“Host”, “myhost”).restore_attribute(“vars”) thing should be entered…