Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Edgar Fuß
> Can anyone point me at the correct syntax get_host(host.vars.neighbour) ___ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 09:53:22, Edgar Fuß wrote: > > Can anyone point me at the correct syntax > > get_host(host.vars.neighbour) [2019-03-18 09:24:55 +] critical/config: Error: Error while evaluating expression: Tried to access undefined script variable 'host' It stops complaining if

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Edgar Fuß
EF> get_host(host.vars.neighbour) > [2019-03-18 09:24:55 +] critical/config: Error: Error while evaluating > expression: Tried to access undefined script variable 'host' What context is that in? Depending on the context (function, Service Object, Host Object) you may need host.vars, vars or

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 14:17:57, Edgar Fuß wrote: > EF> get_host(host.vars.neighbour) > > > [2019-03-18 09:24:55 +] critical/config: Error: Error while > > evaluating expression: Tried to access undefined script variable 'host' > > What context is that in? It's in a NotificationCommand

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Edgar Fuß
> It's in a NotificationCommand object. Ah, I see. I've never done complicated things in those. > I can use things like $host.name$ and $host.display_name$ perfectly okay to > get properties of the machine the notification is about. It's probably a problem of evaluation order, which is, to speak

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Václav Mach
Hi, have you tried debugging this using the icinga2 console? If I'm correct the documentation suggests something like: ICINGA2_API_USERNAME=your_user ICINGA2_API_PASSWORD=your_pass icinga2 console --connect 'https://icingaweb2@localhost:5665/' After connecting you can interact with your run

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 15:57:43, Edgar Fuß wrote: > > It's in a NotificationCommand object. > > Ah, I see. I've never done complicated things in those. I can't really think of anywhere else to put it, since the information is only required to be included in Notifications, and looking it up

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 16:09:27, Václav Mach wrote: > Hi, > > have you tried debugging this using the icinga2 console? Yes. > If I'm correct the documentation suggests something like: > > ICINGA2_API_USERNAME=your_user ICINGA2_API_PASSWORD=your_pass icinga2 > console --connect 'https://ici

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Ivo Kidze
Hi Antony, You can try this: 1. vi /etc/icinga2/functions.conf 2. Paste globals.get_display_name = function(h) { d = get_host(h).display_name if (d) { log(LogInformation, "get_display_name", "Display name found!") return d } log(LogWarning, "get_d

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 19:58:19, Ivo Kidze wrote: > Hi Antony, > > You can try this: ... > 6. use can now use get_display_name("hostname") Hm, interesting solution to the debugging problem - I shall try that tomorrow. Thanks also for the helpful clue regarding what parameters to pass to l

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Václav Mach
Hi, On 3/18/19 4:30 PM, Antony Stone wrote: You can try to start by running 'get_host("your_host")' and then continue with more complex stuff based on properties you get. Yes, I can do everything I want to there: <1> => a=get_host("first.server.com").vars.neighbour null <2> => a "second.ser

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 21:00:45, Václav Mach wrote: > Hi, > > On 3/18/19 4:30 PM, Antony Stone wrote: > >> You can try to start by running 'get_host("your_host")' and then > >> continue with more complex stuff based on properties you get. > > > > Yes, I can do everything I want to there: > >

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 20:30:58, Antony Stone wrote: > On Monday 18 March 2019 at 19:58:19, Ivo Kidze wrote: > > > You can try this: > ... > > > 6. use can now use get_display_name("hostname") > > Hm, interesting solution to the debugging problem - I shall try that > tomorrow. It didn't se

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Václav Mach
On 3/18/19 9:08 PM, Antony Stone wrote: On Monday 18 March 2019 at 21:00:45, Václav Mach wrote: I've not seen a thing that worked on console and not in the actual configuration. What output do you get when you try step by step (like above) while using log function? If I could get the log() fu

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Antony Stone
On Monday 18 March 2019 at 21:39:33, Václav Mach wrote: > On 3/18/19 9:08 PM, Antony Stone wrote: > > On Monday 18 March 2019 at 21:00:45, Václav Mach wrote: > >> I've not seen a thing that worked on console and not in the actual > >> configuration. What output do you get when you try step by step

Re: [icinga-users] Get attributes of a host by reference? RESOLVED!

2019-03-18 Thread Antony Stone
On Sunday 17 March 2019 at 23:01:27, Antony Stone wrote: > Can anyone point me at the correct syntax for de-referencing the variable > host.vars.neighbour so that I can get the display_name attribute for that > object? Thanks to Edgar, Václav and Ivo for all the assistance. I took a step backwar

Re: [icinga-users] Get attributes of a host by reference?

2019-03-18 Thread Václav Mach
On 3/18/19 9:47 PM, Antony Stone wrote: Eh? The code is not "run" when doing "icinga2 daemon -C" - there's no output to /var/log/icinga2/icinga2.log, and there's no output from the log() functon calls on the console - it just reports the number of different types of ConfigItems etc (and any syn