New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dev.icinga.com #7564] Access object runtime attributes in custom vars & command arguments #2186
Comments
Updated by mfriedrich on 2014-11-03 20:36:28 +00:00
|
Updated by mfriedrich on 2014-11-03 20:37:32 +00:00 If you really need 'check_cluster' you'd rather want it implemented as Icinga 2 check task, and that goes into the direction of cloning and combining states like discussed with #5938 |
Updated by mfrosch on 2015-01-12 08:17:25 +00:00
Please evaluate for 2.3 We need to find a proper syntax for Icinga2 macros... |
Updated by gbeutner on 2015-01-16 08:39:41 +00:00 Just a quick refresher for the current macro semantics: Icinga 2 generates a list of macro "resolvers" when looking up macros - for example, for a service check the following ordered resolver list is set up: ("host", ) Markus' idea:
Users who are familiar with the existing macro semantics would assume that the "address" attribute for the service "http" (on the same host) is used for case 1. In case 2 the "address" attribute for the service "http" on host "host" is used. My idea:
(1) would substitute the "host" macro resolver in the resolver list with the host "localhost". Also, assuming that the service resolver is set and that the substituted host has a service with the same name it will use the new host's service instead (e.g. if service previously referred to the service "http" on host "oldhost" it will now refer to the "http" service on the host "localhost"; if there's no matching service the service resolver is removed). (2) works similarly to (1) however it substitutes the service resolver with the service "http" on the same host. (3) replaces the host resolver with the "localhost" host and the service resolver with the service "http" on that host. Pros: -This would be fairly extensible (if we care we could also let users override other resolvers, e.g. user, command, etc.). Cons: -The syntax is fairly ugly :P |
Updated by mfrosch on 2015-01-23 09:56:28 +00:00 Ah few thought bringing visible logic, might cause a bit longer macros though:
Still to review: Group Macros (http://docs.icinga.org/latest/en/macros.html#ondemandgroup)
Questions:
|
Updated by mfriedrich on 2015-01-24 13:37:51 +00:00 I have been thinking about this issue and the syntax quite a lot in the past months, independent from the proposals already posted. I generally don't like the approach of parsing macro strings and obfuscating a key value into something which then generates a value. While this is totally reasonable when you just have a string (command line, as Icinga 1.x) it does not really fit into Icinga 2 and its command arguments. Status QuoConsider a check_cluster example from Icinga 1.x:
Which would be written as the following in Icinga 2:
ProposalImho there should be a more elegant way to access object's runtime attributes when executing a command. My idea originates from the newly added functions and expressions in 2.3 whereas it's also possible to access an object (during config parsing stage). If we imagine, that such expression ONDEMAND would be called
which is not evaluated by the config parser, but actually at runtime when the caller (the CheckCommand execute method) says so. Similar to resolving the macro strings. Functions are registered globally as far as I know, so accessing them later at runtime would be a reasonable idea. Maybe it's also similar to how the new 'icinga2 console' cli command works. I'm also going into the "write a function inside the config and execute it at runtime in-memory" direction here. Which obviously comes to mind with the new feature set of 2.3 :-) Possible ProblemsIt might be a problem when passing these functions as command arguments (from the host/service), ensuring that the function expression still exists then on command execution. Something like
Not sure how we could keep this secured, other than allowing a new type for custom attributes (runtime expressions?), which implicitely gets a to_string() function for external interfaces. I'm not sure how this would work out for group macros - even 1.x does some magic calculation here. Though accessing the runtime "state" of "groups" could just be handled with a special functionality (loop over all members). Other ProposalsOne thing against the other proposals - every syntax addition and exception for the macro processor leads to performance decreasements. Further I don't like the square brackets. That's confusing with the Array syntax already available with icinga2. ConclusionGenerally speaking "on-demand macros" is the wrong attempt here - imho it's more like "accessing object attributes at event runtime". We should carefully evaluate which solution fits best. Changing the macro syntax cannot be reverted later on. Neither can the runtime object access. |
Updated by mfriedrich on 2015-01-25 07:29:36 +00:00 One more thing during sleep... Evaluate usage of functionIn #8030 we're discussing where to use functions. One use case already found is the "set_if" attribute for command arguments in #6697.
That requirement is similar to a function accessing the runtime attributes of other objects, in simple assign cases as command argument value. |
Updated by mfriedrich on 2015-01-25 07:30:51 +00:00
|
Updated by mfriedrich on 2015-01-25 07:31:11 +00:00
|
Updated by mfriedrich on 2015-01-26 15:06:37 +00:00
|
Updated by gbeutner on 2015-01-27 09:52:47 +00:00
|
Updated by gbeutner on 2015-01-27 12:44:43 +00:00 TODO:
|
Updated by Anonymous on 2015-01-28 07:37:00 +00:00
Applied in changeset eb2f2dd. |
Updated by mfriedrich on 2015-01-28 09:35:09 +00:00
|
Updated by mwaldmueller on 2015-01-28 14:10:36 +00:00 Here's an example of how On-Demand Macros are actually used with Icinga 1.x:
|
Updated by mfriedrich on 2015-01-28 14:33:59 +00:00
|
Updated by gbeutner on 2015-02-02 10:36:27 +00:00 TODO:
|
Updated by Anonymous on 2015-02-04 13:05:04 +00:00
Applied in changeset 290a5c2. |
Updated by gbeutner on 2015-02-04 13:06:05 +00:00
|
Updated by mfriedrich on 2015-02-09 09:41:08 +00:00
|
Updated by mfriedrich on 2015-02-09 12:18:59 +00:00
|
Updated by mfriedrich on 2015-02-09 12:37:09 +00:00
To-do:
|
Updated by gbeutner on 2015-02-10 13:16:10 +00:00
This needs more testing. Apart from that I'm done here I guess. |
Updated by mfriedrich on 2015-02-10 15:31:58 +00:00
I'd say we need one last thing besides testing - proper usage examples in the current "monitoring basics" documentation. A combination of accessing runtime attributes and getting these objects, but simplified for the reader, next to the runtime macro chapter. |
Updated by Anonymous on 2015-02-11 13:15:03 +00:00
Applied in changeset 46f7397. |
Updated by gvenka008c on 2016-12-06 03:38:01 +00:00 @here, i tried the below to check object CheckCommand "check_cluster" { command = [ "/usr/lib64/nagios/plugins/check_cluster" ] arguments = { ``` #services.conf ``` When I bring down one of the node, it is still showing OK status. Didn't see any Warning message. Any thoughts how to have check_cluster working in icinga2? |
Updated by mfriedrich on 2016-12-06 10:46:34 +00:00 Please ask on the community channels not some old issue already resolved. https://www.icinga.com/community/get-involved/ |
This issue has been migrated from Redmine: https://dev.icinga.com/issues/7564
Created by rcgreenw on 2014-11-03 20:32:19 +00:00
Assignee: gbeutner
Status: Resolved (closed on 2015-02-11 13:15:03 +00:00)
Target Version: 2.3.0
Last Update: 2016-12-06 10:46:34 +00:00 (in Redmine)
Requirement
Find a possibility similar to Icinga 1.x On-Demand Macros for runtime access to object attributes.
Proposal
https://dev.icinga.org/issues/7564#note-6
Implementation
Original Request
Implement On-Demand Macros, or document if they are already implemented. They are needed for check_cluster.
http://docs.icinga.org/latest/en/macros.html#ondemand
Changesets
2015-01-27 12:40:05 +00:00 by (unknown) fb44744
2015-01-28 07:36:17 +00:00 by (unknown) eb2f2dd
2015-01-28 13:14:48 +00:00 by (unknown) 4ad4c31
2015-01-28 13:18:27 +00:00 by (unknown) 235c734
2015-01-28 14:48:08 +00:00 by (unknown) ea3c3e0
2015-01-29 09:09:53 +00:00 by (unknown) 7b4f1e2
2015-01-29 09:30:02 +00:00 by (unknown) dd4a7ab
2015-01-29 15:52:04 +00:00 by (unknown) c01fb97
2015-01-30 08:49:57 +00:00 by (unknown) aeb579d
2015-02-04 10:23:48 +00:00 by (unknown) e3137a7
2015-02-04 10:23:49 +00:00 by (unknown) 290a5c2
2015-02-04 10:23:49 +00:00 by (unknown) d6a01fe
2015-02-04 10:23:49 +00:00 by (unknown) 4082f57
2015-02-04 10:23:49 +00:00 by (unknown) db70fac
2015-02-04 10:23:49 +00:00 by (unknown) f191b12
2015-02-04 10:23:49 +00:00 by (unknown) eca3e4e
2015-02-04 10:23:49 +00:00 by (unknown) f2f99b1
2015-02-04 10:23:49 +00:00 by (unknown) 32cb638
2015-02-09 07:50:17 +00:00 by (unknown) 97fc5bb
2015-02-09 10:04:28 +00:00 by (unknown) 2792933
2015-02-09 11:37:29 +00:00 by (unknown) a8ec777
2015-02-09 12:12:28 +00:00 by (unknown) 5a0fbfd
2015-02-10 09:59:08 +00:00 by (unknown) 2de89fe
2015-02-10 14:21:48 +00:00 by (unknown) 0f39750
2015-02-11 13:10:21 +00:00 by (unknown) 46f7397
Relations:
The text was updated successfully, but these errors were encountered: