0

我正在尝试配置 icinga2 以使用check_nrpe. 我的配置如下

nrpe.cfg

 command[check_root]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$

冰糖配置

object CheckCommand "nrpe-check-2arg" {
  import "plugin-check-command"
  command = [PluginDir + "/check_nrpe" ]
  arguments = {
    "-H" = "$host_name$"
    "-c" = "$check$"
    "-a" = "$loads$"
  }
}

object Service "testing-haproxy-master: / disk space" {
  import "generic-service"
  host_name = "tmahaprx01.verizon.com"
  check_command = "nrpe-check-2arg"
  vars.address = "192.168.1.104"
  vars.check = "check_root"
  vars.loads = "80%!90%!/"
}

现在我得到的输出是

 root@icinga:/etc/icinga2/hosts# /usr/lib/nagios/plugins/check_nrpe -H 192.168.1.104 -c check_root -a '80%C!90%!/'
 DISK OK - free space: /sys/fs/cgroup 0 MB (100% inode=99%); /dev 1457 MB (99%   
 inode=99%); /run 293 MB (99% inode=99%); /run/lock 5 MB (100% inode=99%); 
 /run/shm 1468 MB (100% inode=99%); /run/user 100 MB (100% inode=99%);|   
 /sys/fs/cgroup=0MB;0;0;0;0 /dev=0MB;291;145;0;1457 /run=0MB;58;29;0;293  
 /run/lock=0MB;0;0;0;5 /run/shm=0MB;293;146;0;1468 /run/user=0MB;19;9;0;100

我从远程 Linux 机器执行时的预期输出是

  root@tmahaprx01:~# /usr/lib/nagios/plugins/check_disk -w 80% -c 90% -p /
  DISK OK - free space: / 43144 MB (96% inode=97%);| /=1743MB;9462;4731;0;47314

您能否指导我如何通过第三个参数(/)?

4

1 回答 1

1

NRPE 的问题在于您正在编写一个执行另一个命令的命令。假设nrpe.cfg包括这样的东西:

command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$

你知道路径必须是第三个参数:

object CheckCommand "nrpe-disk" {
  import "nrpe"
  vars.nrpe_arguments = [ "$disk_wfree$%", "$disk_cfree$%", "$disk_partition$" ]
  vars.nrpe_command = "check_disk"    
  //variables should be propagated from host/group definition
  vars.disk_wfree = 20
  vars.disk_cfree = 10
  vars.disk_partition = "/" 
}

变量名称可能取决于 Icinga 版本,请检查nrpe系统上的原始命令定义,它可能位于:

/usr/share/icinga2/include/command-plugins.conf
于 2017-03-01T15:50:20.197 回答