0

系统 ubuntu 16.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"
}

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

4

1 回答 1

4

虚拟命令在 中定义/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

所以:我们去我们的主机或服务定义,因此(使用/etc/icinga2/conf.d/host.confNodeName每个人都有的 /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 }

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

于 2016-11-30T05:01:26.257 回答