Using host macros in static service definition

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Using host macros in static service definition

Post by eloyd »

Just wondering if this was ever opened or resolved?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Using host macros in static service definition

Post by ssax »

I'm not seeing it as being an open or closed issue.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Using host macros in static service definition

Post by eloyd »

I wonder if, you know, like someone should open it as a ticket. :)
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Using host macros in static service definition

Post by tmcdonald »

I don't know if this would be an easy change.

Macros are typically used in commands, such as using $HOSTADDRESS$, because that information changes based on the check being run and is parsed each run-through. In order to have macros work in definitions in other places, you would need to have Nagios parse out the configs in a very specific order. If you try to reference a macro that has not been "built" yet, you will need to parse every other config file and "build" it, then go back and fill it in once the value is know. I might not be explaining this the best, but in my mind configs like contacts are "static" meaning once they are loaded into memory they do not change, and commands are "dynamic" because they change depending on the host/service. Changing Core to make everything dynamic would be a huge undertaking, and there would likely be some heavy performance implications.

I'll have a dev weigh in, and if he says differently I would be happy to file a request.
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Using host macros in static service definition

Post by eloyd »

Yes, but...we're talking about user-defined macros that are indeed included and expanded at other points in the code:
My browse through common/macros.c indicates that _SERVICE and _HOST and _CONTACT variables are all included at the same time, but only in service, host, and contact configurations.
It's just a double-pass compiler parse is all. You can probably do it all with yacc and bison. :)
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
lgroschen
Posts: 384
Joined: Wed Nov 27, 2013 1:17 pm

Re: Using host macros in static service definition

Post by lgroschen »

So the issue was opened on Github by abrist - we should verify it still is in the issue list. I'm sure John Frickson will be able to take a look at it.
/Luke
jfrickson

Re: Using host macros in static service definition

Post by jfrickson »

In this message https://support.nagios.com/forum/viewto ... 74#p108900, abrist asked someone (Eric?) to open an issue in github. I don't see any issues (either open or closed) in either github or tracker.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Using host macros in static service definition

Post by eloyd »

Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Using host macros in static service definition

Post by hsmith »

Thanks for the submission. I let John know you replied here.
Former Nagios Employee.
me.
Locked