diff options
| author | Sven Nierlein <sven@nierlein.de> | 2021-10-25 17:28:17 +0200 |
|---|---|---|
| committer | Sven Nierlein <sven@nierlein.org> | 2021-11-01 13:35:11 +0100 |
| commit | 282ccd4a8bbaa5d99c7c0cf6eba963ee3c0bff3a (patch) | |
| tree | 0d2ee78512b1872f3673f9175c2617cfa0b7fb23 | |
| parent | 1738d14c0cae83a24927f34e11a673c7e29baa04 (diff) | |
| download | monitoring-plugins-282ccd4a8bbaa5d99c7c0cf6eba963ee3c0bff3a.tar.gz | |
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>
| -rw-r--r-- | configure.ac | 10 | ||||
| -rwxr-xr-x | plugins/tests/check_procs.t | 11 |
2 files changed, 17 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 7c17dcd1..dfc37b5e 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -783,6 +783,16 @@ dnl ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT | |||
| 783 | dnl ac_cv_ps_cols=8 | 783 | dnl ac_cv_ps_cols=8 |
| 784 | dnl AC_MSG_RESULT([$ac_cv_ps_command]) | 784 | dnl AC_MSG_RESULT([$ac_cv_ps_command]) |
| 785 | 785 | ||
| 786 | dnl This one is the exact same test as the next one but includes etime | ||
| 787 | elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ | ||
| 788 | egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null | ||
| 789 | then | ||
| 790 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" | ||
| 791 | ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'" | ||
| 792 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n" | ||
| 793 | ac_cv_ps_cols=10 | ||
| 794 | AC_MSG_RESULT([$ac_cv_ps_command]) | ||
| 795 | |||
| 786 | dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. | 796 | dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. |
| 787 | dnl so test for this first... | 797 | dnl so test for this first... |
| 788 | elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ | 798 | elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ |
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t index 54d43d9b..7f612e8a 100755 --- a/plugins/tests/check_procs.t +++ b/plugins/tests/check_procs.t | |||
| @@ -69,9 +69,13 @@ SKIP: { | |||
| 69 | like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); | 69 | like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); | 72 | SKIP: { |
| 73 | is( $result->return_code, 0, "Checking regexp search of arguments" ); | 73 | skip 'check_procs is compiled with etime format support', 2 if `$command -vvv` =~ m/etime/mx; |
| 74 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); | 74 | |
| 75 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); | ||
| 76 | is( $result->return_code, 0, "Checking regexp search of arguments" ); | ||
| 77 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); | ||
| 78 | } | ||
| 75 | 79 | ||
| 76 | $result = NPTest->testCmd( "$command --vsz 1000000" ); | 80 | $result = NPTest->testCmd( "$command --vsz 1000000" ); |
| 77 | is( $result->return_code, 0, "Checking filter by VSZ" ); | 81 | 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 | |||
| 129 | $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); | 133 | $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); |
| 130 | is( $result->return_code, 0, "Checking no pipe symbol in output" ); | 134 | is( $result->return_code, 0, "Checking no pipe symbol in output" ); |
| 131 | is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); | 135 | is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); |
| 132 | |||
