Linux – Nagios check_procs returns wrong value when called from NRPE

linuxnagiosnrpeprocess

I have added the following line in nrpe.conf of a monitored server say named myserver:

command[check_mysrv_process]=/usr/lib/nagios/plugins/check_procs -c 1: -C java -a mysrv

which works locally as expected:

myserver> /usr/lib/nagios/plugins/check_procs -c 1: -C java -a mysrv
PROCS OK: 1 process with command name 'java', args 'mysrv'

However when I run the check through nrpe from my nagios server I get a zero output whatever the number of processes with the specific patterns will be (usually 0 or 1):

mynagiosserver>/opt/nagios/libexec/check_nrpe -H myserver -u -c check_mysrv_process
PROCS CRITICAL: 0 processes with command name 'java', args 'mysrv'

More Details:

  • NRPE version = 2.12
  • Nagios Plugins version = 1.4.16
  • OS Type: SLES 11.3
  • The specific process name that contains mysrv is a long one.

EDIT

When doing cat /proc/pid of nrpe/environ I get the following line:

CONSOLE=/dev/consoleSELINUX_INIT=YESROOTFS_FSTYPE=ext3SHELL=/bin/shTERM=linuxROOTFS_FSCK=0crashkernel=256M-:128MLC_ALL=POSIXINIT_VERSION=sysvinit-2.86REDIRECT=/dev/tty1COLUMNS=96PATH=/bin:/sbin:/usr/bin:/usr/sbinvga=0x314DO_CONFIRM=RUNLEVEL=5PWD=/SPLASHCFG=/etc/bootsplash/themes/SLES/config/bootsplash-800×600.cfgPREVLEVEL=NLINES=33HOME=/SHLVL=2splash=silentSPLASH=yesROOTFS_BLKDEV=/dev/sda2_=/sbin/startprocDAEMON=/usr/sbin/nrpe

Best Answer

This makes me think about a reported Bug caused by the COLUMN environment variable.

Here, you have COLUMNS=96.

This means that any process command line that exceeds COLUMN value will be lost.

AS you said that your process name is long, you could be facing this issue.

You can try to increase your COLUMN variable in your command definition in nrpe.cfg :

command[check_myprogram_proc]=COLUMN=256 /usr/lib/nagios/plugins/check_procs ...

Reference : http://christoph-probst.com/article.php/20110718143604605