icinga2磁盘空间检查或三个参数

时间:2017-02-10 20:04:31

标签: arguments monitoring icinga2

我正在尝试使用check_nrpe配置icinga2来监控我的linux服务器磁盘空间。我的配置如下:

nrpe.cfg

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

icinga配置

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

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

1 个答案:

答案 0 :(得分: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