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 any earlier in the 
process (of raising a Notification) doesn't seem possible because we don't even 
know what the alerting host is until then.

> > 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 politely,
> heavily under-documented, especially wrt. run-time macros.

Yes, I've got as far as I have with the help of some example code in the 
online documentation, but I find the examples show how to do things which 
aren't really explained generically, and the relations between things like 
Host Objects and their (static or run-time) attributes, and the use of 
"macro", and how to pass parameters into functions, seems quite hard to 
understand.

> I don't know a definitive answer, but I would try (combined with logging)

Hm, logging, yes, that would be nice :)

I've checked with "icinga2 feature list" that I have "mainlog" enabled.  (If I 
turn on "debuglog" there is so much continuous output that I can't see what 
I'm looking for when I make something happen.)

https://icinga.com/docs/icinga2/latest/doc/14-features/ tells me that:

"mainlog - Main log (path: /var/log/icinga2/icinga2.log, severity: information 
or higher)"

https://icinga.com/docs/icinga2/latest/doc/18-library-reference/#log tells me:

"function log(severity, facility, value)

Writes a message to the log. severity can be one of LogDebug, LogNotice, 
LogInformation, LogWarning, and LogCritical."

So, what am I supposed to put into a log() call in my code to get whatever's 
being logged to appear in /var/log/icinga2/icinga2.log ?

"severity" is clearly "LogInformation" or higher (and I'm assuming that 
LogDebug is the lowest priority, LogCritical is the highest?)

But what's "facility"?

I'm familiar with that for syslog-style logging, but what should I use here?  
I don't see that mentioned anywhere in the log() function notes :(

> -- get_host(macro("$host.vars.neighbour$"))
> -- call a function (declared with parameter x) on "$host.vars.neighbour$"
> or macro() that returns get_host(x).whatever

Yep, I'm fiddling with various variations on those themes...

> Even better, someone could speak up who really knows.

Nice idea :)

Volunteers, anyone?


Thanks,

Antony.

-- 
"I estimate there's a world market for about five computers."

 - Thomas J Watson, Chairman of IBM

                                                   Please reply to the list;
                                                         please *don't* CC me.
_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to