Removing a host free variable via the API

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
krutaw
Posts: 60
Joined: Wed Jul 31, 2013 6:30 pm

Removing a host free variable via the API

Post by krutaw »

Just thought I'd share a tip, I ran across a need to remove a free variable from a host via the API. I wasn't able to find a good way to do so directly using commands in the API without simply replacing the host. So that's what I did.

In the scripting that we use for interfacing our ChatOps environment with Nagios XI, I already had code to allow for collecting the existing free variables so that it was additive instead when we would run that specific command. To that, I added code to detect when the value of a free variable is set to "-", and if so, eliminate it from the list of free variables. Then I simply add the host again with the list of free variables, hostgroups, etc. and voila. Free variable gone via the API.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Removing a host free variable via the API

Post by tgriep »

Thanks for the tip @krutaw.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked