[Nagiosplug-devel] question on check_procs and shell environment

Frost, Mark {PBC} mark.frost1 at pepsico.com
Fri Mar 26 17:07:26 CET 2010


It seems that the check_procs configuration used on HPUX (and it looks like AIX although I haven't tested that one) doesn't handle command arguments at all, although the command implies that it does.  It uses "/usr/bin/ps -el" as the execution command which does not return arguments.  The end result is that the "command" and "arguments" values are to the same value (i.e. command=sh and arguments=sh) which is pretty useless.  -a and --ereg-arguments-array just match on the command value.

By comparison, on Linux, these values are fully accessible.

While you can run 'ps' on HPUX and get more fields and better sets of arguments, you still don't quite get them all.  There are no variants of 'ps' on HPUX that will give all the fields that the check_procs command allows unless you turn on UNIX95 standards compliance.  Then you can make the HPUX 'ps'  function like Linux 'ps' and specify the fields you want.  However, this means you have to set an environment variable as in

UNIX95= /usr/bin/ps -ex -o 'state uid pid ppid vsz sz pcpu comm args'

I prefer to "really fix it" approach to "mostly fix it".

check_procs calls run_cmd().  The comments in the code seem to indicate that the idea of passing in any environment is not allowed other than the single variable that is hardcoded in run_cmd_open (LC_ALL=C).  I changed the code to also include the "UNIX95=" environment variable and check_procs works as it does on Linux.

The only way I can think of to make this work reasonably is to somehow allow passing in this environment variable via run_cmd() say via a compile time options like the setting of PS_COMMAND, but it's my impression that this is not something that anyone wants to do for security reasons under any circumstances.  I think the spopen() call is the wave of the future for these things, but it works similarly in that it doesn't allow environment arguments to be passed in.

Is this idea of passing in environment just something that is an impassible barrier?

(I realize I could probably just make a little shell script that runs this flavor of the 'ps' command and compile the plugins with that.  I may end up doing that, but that's a solution for me and not a generalized solution for everyone else who wants to run on this platform and use check_procs).

Thanks

Mark





More information about the Devel mailing list