diff options
Diffstat (limited to 'plugins/tests/check_procs.t')
-rwxr-xr-x | plugins/tests/check_procs.t | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t index 54d43d9b..b3a0a301 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 => 54; |
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" ); |
@@ -33,9 +34,13 @@ is( $result->return_code, 0, "Checking no threshold breeched" ); | |||
33 | is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" ); | 34 | is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" ); |
34 | 35 | ||
35 | $result = NPTest->testCmd( "$command -C launchd -c 5" ); | 36 | $result = NPTest->testCmd( "$command -C launchd -c 5" ); |
36 | is( $result->return_code, 2, "Checking processes filtered by command name" ); | 37 | is( $result->return_code, 2, "Checking processes matched by command name" ); |
37 | is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" ); | 38 | is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" ); |
38 | 39 | ||
40 | $result = NPTest->testCmd( "$command -X bash -c 5" ); | ||
41 | is( $result->return_code, 2, "Checking processes excluded by command name" ); | ||
42 | is( $result->output, "PROCS CRITICAL: 95 processes with exclude progs 'bash' | procs=95;;5;0;", "Output correct" ); | ||
43 | |||
39 | SKIP: { | 44 | SKIP: { |
40 | skip 'user with uid 501 required', 4 unless getpwuid(501); | 45 | skip 'user with uid 501 required', 4 unless getpwuid(501); |
41 | 46 | ||
@@ -69,9 +74,21 @@ SKIP: { | |||
69 | like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); | 74 | like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); |
70 | }; | 75 | }; |
71 | 76 | ||
72 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); | 77 | SKIP: { |
73 | is( $result->return_code, 0, "Checking regexp search of arguments" ); | 78 | 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" ); | 79 | |
80 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); | ||
81 | is( $result->return_code, 0, "Checking regexp search of arguments" ); | ||
82 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); | ||
83 | } | ||
84 | |||
85 | SKIP: { | ||
86 | skip 'check_procs is compiled without etime format support', 2 if `$cmd_etime -vvv` !~ m/etime/mx; | ||
87 | |||
88 | $result = NPTest->testCmd( "$cmd_etime -m ELAPSED -C apache2 -w 1000 -c 2000" ); | ||
89 | is( $result->return_code, 2, "Checking elapsed time threshold" ); | ||
90 | 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" ); | ||
91 | } | ||
75 | 92 | ||
76 | $result = NPTest->testCmd( "$command --vsz 1000000" ); | 93 | $result = NPTest->testCmd( "$command --vsz 1000000" ); |
77 | is( $result->return_code, 0, "Checking filter by VSZ" ); | 94 | is( $result->return_code, 0, "Checking filter by VSZ" ); |
@@ -83,7 +100,7 @@ is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;', | |||
83 | 100 | ||
84 | $result = NPTest->testCmd( "$command -s S" ); | 101 | $result = NPTest->testCmd( "$command -s S" ); |
85 | is( $result->return_code, 0, "Checking filter for sleeping processes" ); | 102 | is( $result->return_code, 0, "Checking filter for sleeping processes" ); |
86 | like( $result->output, '/^PROCS OK: 44 processes with STATE = S/', "Output correct" ); | 103 | like( $result->output, '/^PROCS OK: 88 processes with STATE = S/', "Output correct" ); |
87 | 104 | ||
88 | $result = NPTest->testCmd( "$command -s Z" ); | 105 | $result = NPTest->testCmd( "$command -s Z" ); |
89 | is( $result->return_code, 0, "Checking filter for zombies" ); | 106 | is( $result->return_code, 0, "Checking filter for zombies" ); |
@@ -129,4 +146,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)'" ); | 146 | $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); |
130 | is( $result->return_code, 0, "Checking no pipe symbol in output" ); | 147 | 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" ); | 148 | is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); |
132 | |||