0

I am trying to configure icinga2 to monitor my linux server disk space using check_nrpe. my configuraiton is given below

nrpe.cfg:

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

icinga configuration

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%!/"
}

Now the out put i am getting is

 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

The expecting output when I execute from my remote Linux machine is

  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

Could you please guide me how i can pass the third argument (/) ?

Tombart
  • 30,520
  • 16
  • 123
  • 136
devops
  • 173
  • 4
  • 16

1 Answers1

1

The problem with NRPE is that you're writing a command that executes another command. Assuming that the nrpe.cfg includes something like this:

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

you know that the path must be the 3rd argument:

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 = "/" 
}

variable names might be dependent on Icinga version, check the original nrpe command definition on your system, it might be located in:

/usr/share/icinga2/include/command-plugins.conf
Tombart
  • 30,520
  • 16
  • 123
  • 136