Is it possible to delete custom macros from the API?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Is it possible to delete custom macros from the API?

Post by eloyd »

Okay, back to APIs for a moment. Let's say I have a host called TESTAPIHOST and I use the API to PUT a config/host/.../_alice=foo custom variable onto the host. Works great. Next day, I decide that _foo was not the correct name and we want to use _bob instead.

There does not seem to be a way from the API to delete a config directive, either from hosts or services, without first deleting the entire host or service and recreating it.

I can change _alice=foo to _alice=bar with the API, and I can add _bob=foo with the API, but I can't remove _alice altogether.

Is this something we can hope will change in the future? Or did I miss something in my RTFMing?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Is it possible to delete custom macros from the API?

Post by eloyd »

@DoubleDoubleA do you care to chime in here? :P
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
gwesterman
Posts: 269
Joined: Wed Aug 23, 2023 11:29 am

Re: Is it possible to delete custom macros from the API?

Post by gwesterman »

Hi @eloyd,

As far as I can see, you correct. There is no good way to just remove a custom variable via the API. Setting the variable to nothing e.g. "_testfree=" nearly works as it appears to be functionally removed from the host but the host still displays having a custom variable in the interface (despite there being none). I have made a feature request.

You can monitor the changelog for any updates.

Thank you!
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Is it possible to delete custom macros from the API?

Post by eloyd »

Thanks!

As long as we're feature-requesting API issues, can you add this to it:

I'd like to be able to either add an entity or modify an existing entity and mark it as "not active" similar to what you can do with the "Active" checkbox in the CCM. As far as I can tell, there is no way to do this with the API. We do a lot of API work with dynamic monitoring and being able to stage things as "in the database" but "inactive" would be a huge boon.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
DoubleDoubleA
Posts: 286
Joined: Thu Feb 09, 2017 5:07 pm

Re: Is it possible to delete custom macros from the API?

Post by DoubleDoubleA »

Eric,

Your additional language has been added to the FR.

Thanks!

Aaron
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Is it possible to delete custom macros from the API?

Post by eloyd »

Any hope for being able to mark hosts/services as "not active" in the API any time soon? That would be a real killer bonus for us when we do massive updates for customers.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
DoubleDoubleA
Posts: 286
Joined: Thu Feb 09, 2017 5:07 pm

Re: Is it possible to delete custom macros from the API?

Post by DoubleDoubleA »

@eloyd I will take a look at what is required on this.
DoubleDoubleA
Posts: 286
Joined: Thu Feb 09, 2017 5:07 pm

Re: Is it possible to delete custom macros from the API?

Post by DoubleDoubleA »

@eloyd,

Can you get more specific on your "mark inactive" use case? Like, this is for an existing XI and you want to temporarily make hosts inactive? Or you set up a new server and you want to get all the hosts and services ready to rock but not monitor just yet? Or something else entirely?

When I look into how it is wired up, clearly no one imagined these use cases, though it makes a ton of sense. Even in the function that does a direct table import we don't support managing the "active" column.

Aaron
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Is it possible to delete custom macros from the API?

Post by eloyd »

PIck your poison for use case, but the two that come up most are similar to what you've described:

1. Staging large deployments where we want to put lots of things in play, but don't want them all happening all at once (mainly to avoid "what the hell are all these notifications" syndrome

2. Correcting mistakes made during previous deployments that we get hired to fix and need to have the ability to run things in parallel until we can turn off the old and go with the new, but still want to be able to easily switch back to the old.

Both of these would benefit greatly from the ability to check/uncheck the "Is Active" button from the API.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
DoubleDoubleA
Posts: 286
Joined: Thu Feb 09, 2017 5:07 pm

Re: Is it possible to delete custom macros from the API?

Post by DoubleDoubleA »

The heart of the challenge is that "active" is not a Core config, it's a column in the table(s), and the API calls get routed through the importFile functionality of the CCM instead of doing a direct table modification, so it doesn't appear to be an easy-peasy add to the existing call, which would be the ideal state.

In the Core Object Definitions we do have "active_checks_enabled" and "passive_checks_enabled" for both hosts and services, and both of those currently have API support. Any chance you could leverage these?
Post Reply