> On 9. Sep 2017, at 17:27, Antony Stone <antony.st...@icinga.open.source.it> > wrote: > > On Saturday 09 September 2017 at 14:49:14, Tobias Köck wrote: > >> Hi, >> >> I am wondering what is the difference between a macro access with >> >> ... = $host.variable$ >> >> and >> >> ... = macro($host.variable$)? > > I'm not familiar with that latter syntax - can you point me at the > documentation for it?
I’ve got a docs issue open for it. It is not available everywhere thus not a global function. https://github.com/Icinga/icinga2/issues/5060 - “$host.address$” inside a string tells the macro resolver to lookup the “host” object in this scope, and go for the defined attribute. This could also be a dictionary with further keys, as seen with “$host.vars.os$” and similar. - Using macro() inside functions for runtime values in custom attributes was added to fetch specific object attributes. Normally you would need to bind specific variables into the functions scope. That isn’t possible with abbreviated lambda functions, but you’ll know that from creating a function which uses the keyword “use”. for (i in range(10)) { object Host “h” + i use (i) { check_command = “dummy" vars.test = i } } So it looks like this for example: object CheckCommand “abc” { vars.runtime_calculated_attribute = {{ var host_address = macro(“$host.address$") }} Keep in mind that global macro() lookups can be expensive with many objects. Since macro() is called inside a runtime function evaluation, that’s the case when running a check execution. Further usage examples are used inside the object accessor functions e.g. for global cluster checks. Kind regards, Michael _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users