icinga2 - 在哪里更改客户端监控命令?

icinga2 - where to change client monitoring commands?

系统ubuntu16.04

在安装了 icinga2 的主节点上

#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"
}

我无法理解从哪里调用虚拟命令以及如何自定义警告和临界阈值检查

虚拟命令在/usr/share/icinga2/include/command-plugins.conf中定义,像这样:

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 }

为了修改警告和暴击级别,您可以在主机或服务级别设置自定义变量。使用 ping 的例子,我们在同一个文件中看到默认配置:

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 }

这是重要的一点:

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

So:我们转到我们的主机或服务定义,因此(使用 /etc/icinga2/conf.d/host.conf 和每个人都有的 NodeName/localhost 定义;注释已删除):

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 }

然后我们在上面的第 45 行之前插入以产生:

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 }

...您已成功自定义检查阈值。您可以将这些变量添加到模板甚至主机组(我认为;最好测试一下,我可能错了)。