mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-06-12 10:10:00 -04:00
check_procs: improve ps args autodetection
one of the first ps commands in the configure.ac is `axwo 'stat comm vsz rss user uid pid ppid args'` which works on most modern linux systems (checked debian 10/11 and centos 7/8). But this test misses the etime argument. Therefore `check_procs --metric=ELAPSED` does not work. To fix this, we simply do the same test including etime before that one. Signed-off-by: Sven Nierlein <sven@nierlein.de>
This commit is contained in:
parent
1738d14c0c
commit
282ccd4a8b
2 changed files with 17 additions and 4 deletions
10
configure.ac
10
configure.ac
|
|
@ -783,6 +783,16 @@ dnl ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT
|
|||
dnl ac_cv_ps_cols=8
|
||||
dnl AC_MSG_RESULT([$ac_cv_ps_command])
|
||||
|
||||
dnl This one is the exact same test as the next one but includes etime
|
||||
elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
|
||||
egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null
|
||||
then
|
||||
ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
|
||||
ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'"
|
||||
ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
|
||||
ac_cv_ps_cols=10
|
||||
AC_MSG_RESULT([$ac_cv_ps_command])
|
||||
|
||||
dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
|
||||
dnl so test for this first...
|
||||
elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
|
||||
|
|
|
|||
|
|
@ -69,9 +69,13 @@ SKIP: {
|
|||
like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
|
||||
};
|
||||
|
||||
$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
|
||||
is( $result->return_code, 0, "Checking regexp search of arguments" );
|
||||
is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
|
||||
SKIP: {
|
||||
skip 'check_procs is compiled with etime format support', 2 if `$command -vvv` =~ m/etime/mx;
|
||||
|
||||
$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
|
||||
is( $result->return_code, 0, "Checking regexp search of arguments" );
|
||||
is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
|
||||
}
|
||||
|
||||
$result = NPTest->testCmd( "$command --vsz 1000000" );
|
||||
is( $result->return_code, 0, "Checking filter by VSZ" );
|
||||
|
|
@ -129,4 +133,3 @@ is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowSe
|
|||
$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
|
||||
is( $result->return_code, 0, "Checking no pipe symbol in output" );
|
||||
is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue