Perform external check based on icinga2 check result

This forum was archived to /woltlab and is now in read-only mode.
  • Hi All,

    In recent past we have issue with increase in process count in few of our servers, hence I'm planning to write a script that will be executed based on the check_procs result when ever it is high.

    By any mean is it possible to read icinga command results of specific hosts at master level?

    Any insight on this will be of much help.

    @Admins. Thanks again for managing this wonderful forum, i'm sure it will be helpful for 1000's of IT admins and dev ops engineers:)


  • Hm, you could use dummy checks and implement a function which evaluates such and returns a specific value. That dummy check could for instance also be a shell script which takes the calculated output via custom attribute command argument, and then i.e. trigger an API request.

    Portions for the runtime object access function can be found here:!/icinga2/latest/doc/module/icinga2/chapter/advanced-topics#access-object-attributes-at-runtime

    Something like

  • Line 11 seems to miss a curly bracket...

    Well, that is great (especially the examples in the parapraph 8.7).

    Very slowly i start to understand what closures can be used for.

    It will still take some time to get used to these possibilities.

  • Thanks, edited. Closures are a different thing - those are used to effectively bind specific variables from the parent scope into the local scope. Take that programmatic example how i generate test config for the Globe 3D module in Icinga Web 2:…ga2/demo/globe_hosts.conf

    In this example I'm iterating over the global constant GeoLocation (should be defined in constants.conf but I was lazy). count inside the for loop just generates a random number which is then used to generate a random number of host objects. So that the demo looks different each time Icinga 2 is restarted. Equal count of hosts is pretty boring ;)

    The important bit is the object definition - inside I'd like to set the custom attribute "geolocation" to the value of the global dictionary in this iteration. Therefore I need to bind all variables into the object's scope using use(k, v)

    For illustration reasons I'm also setting the key (which is the location string) into the "notes" attribute.

    Anonymous lambda functions are short term for specific functions without any arguments passed. Which is why you'll need to call macro() if you want to access specific outside runtime values (or, get_objects() even). You could also write your own global functions and use such. I'm still looking into proper examples for the docs, but there are some portions already inside.

    If you're further interested in Icinga 2 DSL examples, Eduard Güldner talked about such in his Icinga Camp talk last week. Dummy checks which just evaluate existing performance data values from other objects in memory - all done using the Icinga 2 DSL. Video archive is coming soon, just uploaded the slides here:…in-it-platform-monitoring