icingaicinga2

icinga2 - where to change client monitoring commands?


system ubuntu 16.04

On master node where icinga2 is installed

#ls /etc/icinga2/repository.d/hosts/WIN-U52321E0BAK/
disk C%3A.conf  disk.conf  icinga.conf  load.conf  ping4.conf  

ping6.conf  procs.conf  swap.conf  users.conf

All conf files have save "dummy" check_command on them for example
#cat load.conf
object Service "load" {
import "satellite-service"
check_command = "dummy"
host_name = "WIN-U52321E0BAK"
zone = "WIN-U52321E0BAK"
}

I cant understand from where dummy command is called and how to customize the checks for warning and critical threshold


Solution

  • The dummy command is defined in /usr/share/icinga2/include/command-plugins.conf, like so:

    144 object CheckCommand "dummy" {
    145     import "plugin-check-command"
    146
    147     command = [ 
    148         PluginDir + "/check_dummy",
    149         "$dummy_state$",
    150         "$dummy_text$"
    151     ]
    152
    153     vars.dummy_state = 0
    154     vars.dummy_text = "Check was successful."
    155 }
    

    In order to modify the warn and crit levels, you set the custom variable at the host or service level. Using the example of ping, we see the default configuration in that same file:

    36 template CheckCommand "ping-common" {
    37     import "plugin-check-command"
    38
    39     command = [ PluginDir + "/check_ping" ]
    40
    41     arguments = {
    42         "-H" = "$ping_address$"
    43         "-w" = "$ping_wrta$,$ping_wpl$%"
    44         "-c" = "$ping_crta$,$ping_cpl$%"
    45         "-p" = "$ping_packets$"
    46         "-t" = "$ping_timeout$"
    47     }
    48
    49     vars.ping_wrta = 100
    50     vars.ping_wpl = 5
    51     vars.ping_crta = 200
    52     vars.ping_cpl = 15
    53 }
    

    Here's the important bit:

    49     vars.ping_wrta = 100
    50     vars.ping_wpl = 5
    51     vars.ping_crta = 200
    52     vars.ping_cpl = 15
    

    So: we go to our host or service definition, thusly (using /etc/icinga2/conf.d/host.conf and the NodeName/localhost definition which everybody has; comments removed):

    18 object Host NodeName {
    20   import "generic-host"
    21
    23   address = "127.0.0.1"
    24   address6 = "::1"
    25
    27   vars.os = "Linux"
    30   vars.http_vhosts["http"] = {
    31     http_uri = "/"
    32   }
    37
    39   vars.disks["disk"] = {
    41   }
    42   vars.disks["disk /"] = {
    43     disk_partitions = "/"
    44   }
    45 }
    

    And we insert before line 45 above to produce:

    18 object Host NodeName {
    20   import "generic-host"
    21
    23   address = "127.0.0.1"
    24   address6 = "::1"
    25
    27   vars.os = "Linux"
    30   vars.http_vhosts["http"] = {
    31     http_uri = "/"
    32   }
    37
    39   vars.disks["disk"] = {
    41   }
    42   vars.disks["disk /"] = {
    43     disk_partitions = "/"
    44   }
    45   vars.ping_wrta = 50
    46   vars.ping_wpl = 3
    47   vars.ping_crta = 10
    48   vars.ping_cpl = 2
    49 }
    

    ...and you have successfully customized the check threshold. You can add those variables to a template or even a hostgroup (I think; better test that, I may be wrong).