diff options
author | Sven Nierlein <sven@nierlein.de> | 2021-10-26 11:34:02 (GMT) |
---|---|---|
committer | Sven Nierlein <sven@nierlein.org> | 2021-11-01 12:35:11 (GMT) |
commit | c3abdb9267567ac9b40ef4a8f3b585c7ab87bac6 (patch) | |
tree | f9b536dbe4870193071e08ad2b49c80462067d5e /plugins/tests/check_procs.t | |
parent | 1fda28f12424be232ac88399e72e95c2bc2d5421 (diff) | |
download | monitoring-plugins-c3abdb9267567ac9b40ef4a8f3b585c7ab87bac6.tar.gz |
check_procs: add test for elapsed time
Diffstat (limited to 'plugins/tests/check_procs.t')
-rwxr-xr-x | plugins/tests/check_procs.t | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t index 7f612e8..fcea404 100755 --- a/plugins/tests/check_procs.t +++ b/plugins/tests/check_procs.t | |||
@@ -8,13 +8,14 @@ use Test::More; | |||
8 | use NPTest; | 8 | use NPTest; |
9 | 9 | ||
10 | if (-x "./check_procs") { | 10 | if (-x "./check_procs") { |
11 | plan tests => 50; | 11 | plan tests => 52; |
12 | } else { | 12 | } else { |
13 | plan skip_all => "No check_procs compiled"; | 13 | plan skip_all => "No check_procs compiled"; |
14 | } | 14 | } |
15 | 15 | ||
16 | my $result; | 16 | my $result; |
17 | my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin"; | 17 | my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin"; |
18 | my $cmd_etime = "./check_procs --input-file=tests/var/ps-axwo.debian"; | ||
18 | 19 | ||
19 | $result = NPTest->testCmd( "$command" ); | 20 | $result = NPTest->testCmd( "$command" ); |
20 | is( $result->return_code, 0, "Run with no options" ); | 21 | is( $result->return_code, 0, "Run with no options" ); |
@@ -77,6 +78,14 @@ SKIP: { | |||
77 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); | 78 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); |
78 | } | 79 | } |
79 | 80 | ||
81 | SKIP: { | ||
82 | skip 'check_procs is compiled without etime format support', 2 if `$cmd_etime -vvv` !~ m/etime/mx; | ||
83 | |||
84 | $result = NPTest->testCmd( "$cmd_etime -m ELAPSED -C apache2 -w 1000 -c 2000" ); | ||
85 | is( $result->return_code, 2, "Checking elapsed time threshold" ); | ||
86 | is( $result->output, "ELAPSED CRITICAL: 10 crit, 0 warn out of 10 processes with command name 'apache2' | procs=10;;;0; procs_warn=0;;;0; procs_crit=10;;;0;", "Output correct" ); | ||
87 | } | ||
88 | |||
80 | $result = NPTest->testCmd( "$command --vsz 1000000" ); | 89 | $result = NPTest->testCmd( "$command --vsz 1000000" ); |
81 | is( $result->return_code, 0, "Checking filter by VSZ" ); | 90 | is( $result->return_code, 0, "Checking filter by VSZ" ); |
82 | is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" ); | 91 | is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" ); |