Monitoring Custom Variables

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


    I want to have a host object with specific custom variables and monitor changes of these custom variables.

    This is for Host Objects which are created/modified by API Commands and are not part of the TCP/IP network.

    These Objects are like small NFC Tags and a server logs information about them like ID and lastseen.


    The Server creates the Tags as Host Objects in icinga and modifies the variables. So I want to have rules like,

    If lastseen > 4 days => warn.

    If lastseen > 8 days => Critical.


    The template for these Objects looks like:


    Is something like this possible with icinga2 and how can i monitor the variables of theses Host Objects?


    I hope i could explain my problem properly and to get some nice answers.

    Thank you very much.


    Best regards

    Artur

  • How would the variables change once defined? You can create dummy devices and then use the command pipe to hurl results to it. Icinga can then be set to threshold against those values.


    Code
    1. object Host "Unicorn" {
    2.         import "generic-host"
    3.         check_command = "dummy"
    4.         check_interval = 9000000
    5. }

    Then a script that runs every minute that does this:


    Code
    1. value=$(date +%H%M)
    2. day=$(date +%d)
    3. secs=$(date +$s)
    4. warn=1229
    5. crit=1455
    6. warns=45
    7. crits=59
    8. echo "[`date +%s`] PROCESS_HOST_CHECK_RESULT;Unicorn;0;OK | sightings=$value;$warn;$crit|number=$secs;$warns;$crits;" >> /var/run/icinga2/cmd/icinga2.cmd


    Would that work?




  • se the command pipe to hurl results to it.

    This seems to be the old style. Now adays use the api for that.


    The Server creates the Tags as Host Objects in icinga and modifies the variables


    I would (but never tried to):

    • create the host via the api and modify the vars using the location server.
    • create a service with the desired max_check_attempts check_interval retry_interval values
      • either via the api
      • or via an apply rule (was not there a bug that currently hinders apply rules to re-evaluate for api created hosts until icinga is restarted ?)
    • have that service execute a custom script that - again using the api - queries the host object including the vars dictionary and "does something" with these variables to calculate a return status of that check_command.
  • How would the variables change once defined?


    Via API Calls.


    I tried to create a custom check plugin:

    and run it in a CheckCommand:

    Code
    1. object CheckCommand "puck_check_power" {
    2. command = ["/usr/lib64/nagios/plugins/check_puck_power"]
    3. arguments ={
    4. "$_HOSTpower$" = ""
    5. }
    6. }

    But i cant pass the local variable vars._power to the plugin script... I found something about macros in icinga1 doc, but they don't work.


    Its a simple try out script so it only needs a number as an argument thats stored in the variable vars._power of the Host Object that is calling the check, like

    Code
    1. /usr/lib64/nagios/plugins/check_puck_power 200

    • have that service execute a custom script that - again using the api - queries the host object including the vars dictionary and "does something" with these variables to calculate a return status of that check_command.

    So you think i should get the information from the variable through an api call? But i also need information from the host object for this like object name for the call.

    The post was edited 1 time, last by artur ().