Incorrect output from check_procs


#1

I’m using Nagios 2.5 and 1.4 of the plugins.

Here is my nagios directory structure.
from /etc
– nagios
| |-- cgi.cfg
| |-- sitename
| | |-- checkcommands.cfg
| | |-- contactgroups.cfg
| | |-- contacts.cfg
| | |-- fw
| | |-- printers
| | |-- routers
| | |-- servers
| | | |-- linux
| | | | |-- checkcommands.cfg
| | | | |-- contactgroups.cfg
| | | | |-- hostgroups.cfg
| | | | |-- hosts.cfg
| | | | |-- services.cfg
| | | |-- novell
| | | | |-- checkcommands.cfg
| | | | |-- hostgroups.cfg
| | | | |-- hosts.cfg
| | | | -- services.cfg | | |– windows
| | | |-- checkcommands.cfg.john
| | | |-- contactgroups.cfg.john
| | | |-- hostgroups.cfg
| | | |-- hosts.cfg
| | | -- services.cfg | | |-- switches | |– timeperiods.cfg
| |-- nagios.cfg
| |-- private
| | |-- htpasswd.users
| | `-- resource.cfg

The idea is that each group of admins configures and controls their own
servers (windows novell etc.) That configuration files that apply to the
site are in /etc/nagios or /etc/nagios/sitename, and platform specific
configuration files are under the respective directory. That way the
windows admins would have their own checkcommands.cfg and hosts.cfg etc.

I’ve been working on the linux side. What I’ve done is created a checkcommands.cfg file in /etc/nagios/sitename/servers/linux with specific commands that are not defined in the generic checkcommands.cfg file that comes with Nagios. This is where I have defined check_netbackup command. This is where I get the "“Return code of 127 …” error. What I did then was to copy that command definition to the higher level checkcommand.cfg file in /etc/nagios/sitename. Now that error has gone away. Also in my /etc/nagios/nagios.cfg I’ve defined;cfg_dir=/etc/nagios/sitename

Here is how I have the command defined in /etc/nagios/sitename/checkcommands.cfg.

testing netbackup

‘check_netbackup’ command definition

define command{
command_name    check_netbackup
command_line    $USER1$/check_procs -w 0 -c 0 -C xinetd -a '/var/run/xinetd.pid'
}

Now I no longer get the “Return code of 127 …” In the Nagios console, I get this,

PROCS OK: 0 processes with command name ‘xinetd’, args ‘/var/run/xinetd.pid’

However from the command line I get:

./check_procs -w 1 -c 1 -C xinetd -a '/var/run/xinetd.pid’
OK - 1 processes running with command name xinetd, args /var/run/xinetd.pid

After all this I have two questions I’m trying to figure out.

  1. Why did I get the “Return code of 127 …” error when using the
    /etc/nagios/sitename/servers/linux/checkcommands.cfg file but not when I
    put the command definition in /etc/nagios/sitename/checkcommands.cfg file?

  2. Now the “Return code of 127 …” error is gone, but the output of the command
    in the Nagios console is incorrect, but runs correctly from the command line.

Other information:

$ls -l /etc/nagios/private/resource.cfg
-rw-r----- 1 root nagios 1335 Aug 24 14:42 /etc/nagios/private/resource.cfg

sudo cat /etc/nagios/private/resource.cfg

Sets $USER1$ to be the path to the plugins

$USER1$=/usr/local/nagios/libexec

Sets $USER2$ to be the path to event handlers

#$USER2$=/usr/local/nagios/libexec/eventhandlers

Any idea’s or thoughts you might have would be greatly
appreciated.


#2

Run the command as user nagios by hand, instead of root. See what you get that way.