10. 10. 2025 Attilio Broglio Icinga Web 2, NetEye, Unified Monitoring

Massive Clean-up of the Icinga custom_var (Services)

During one of my last sessions with a customer I had to deal with a very particular use case, where I couldn’t use the solution presented in my previous blog post (https://www.neteye-blog.com/2025/08/massive-update-of-the-icinga-custom_var-host-services/).

In this new scenario, the customer wanted to clean up a custom_var linked to a service, whose value, inherited from the host, had then been overwritten at the service level.

To overcome this obstacle, I worked directly with Director DB on the icinga_host_var table. At first glance, it may seem strange that in order to remove a custom_var of a service you have to modify the table related to the variables of a host, but this is the way custom_vars are handled in Icinga.

In this example I’ll show you how to clean up a variable foobar1 with an empty array value structured as [“”] (if you have a specific value consider what you want to remove).

To do this, do an UPDATE in the icinga_host_var table. We want to look for all instances of custom_var with the name (varname) equal to “_override_servicevars” and that contain as a value (varvalue) our variable to be removed, i.e. “foobar1”:[“”],

Once an occurrence has been found, we perform a REPLACE action for the unwanted value.

The UPDATE to be launched will therefore be the following:

UPDATE icinga_host_var
SET varvalue=REPLACE (varvalue,'"foobar1":[""],','')
where  
varname="_override_servicevars" and 
varvalue LIKE '%"foobar1":[""],%


Following this query, launch a further update in case this value is at the end of the list.

UPDATE icinga_host_var
SET varvalue=REPLACE (varvalue,'"foobar1":[""]','')
where  
varname="_override_servicevars" and 
varvalue LIKE '%"foobar1":[""]%'

By doing so, all unwanted values will then be cleaned up, bringing our services to the desired states. If you’re not familiar with DB operations, it’s advisable to make a backup of the table in order to have a recovery point.

These Solutions are Engineered by Humans

Did you find this article interesting? Does it match your skill set? Our customers often present us with problems that need customized solutions. In fact, we’re currently hiring for roles just like this and others here at Würth Phoenix.

Attilio Broglio

Attilio Broglio

Author

Attilio Broglio

Leave a Reply

Your email address will not be published. Required fields are marked *

Archive