diff options
Diffstat (limited to 'plugins/tests/check_procs.t')
-rwxr-xr-x[-rw-r--r--] | plugins/tests/check_procs.t | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t index d71c83a2..1ad2c2f1 100644..100755 --- a/plugins/tests/check_procs.t +++ b/plugins/tests/check_procs.t | |||
@@ -18,31 +18,35 @@ my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin"; | |||
18 | 18 | ||
19 | $result = NPTest->testCmd( "$command" ); | 19 | $result = NPTest->testCmd( "$command" ); |
20 | is( $result->return_code, 0, "Run with no options" ); | 20 | is( $result->return_code, 0, "Run with no options" ); |
21 | like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); | 21 | is( $result->output, "PROCS OK: 95 processes | procs=95;;;0;", "Output correct" ); |
22 | 22 | ||
23 | $result = NPTest->testCmd( "$command -w 5" ); | 23 | $result = NPTest->testCmd( "$command -w 5" ); |
24 | is( $result->return_code, 1, "Checking > 5 processes" ); | 24 | is( $result->return_code, 1, "Checking > 5 processes" ); |
25 | like( $result->output, '/^PROCS WARNING: 95 processes$/', "Output correct" ); | 25 | is( $result->output, "PROCS WARNING: 95 processes | procs=95;5;;0;", "Output correct" ); |
26 | 26 | ||
27 | $result = NPTest->testCmd( "$command -w 4 -c 44" ); | 27 | $result = NPTest->testCmd( "$command -w 4 -c 44" ); |
28 | is( $result->return_code, 2, "Checking critical" ); | 28 | is( $result->return_code, 2, "Checking critical" ); |
29 | like( $result->output, '/^PROCS CRITICAL: 95 processes$/', "Output correct" ); | 29 | is( $result->output, "PROCS CRITICAL: 95 processes | procs=95;4;44;0;", "Output correct" ); |
30 | 30 | ||
31 | $result = NPTest->testCmd( "$command -w 100 -c 200" ); | 31 | $result = NPTest->testCmd( "$command -w 100 -c 200" ); |
32 | is( $result->return_code, 0, "Checking no threshold breeched" ); | 32 | is( $result->return_code, 0, "Checking no threshold breeched" ); |
33 | like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); | 33 | is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" ); |
34 | 34 | ||
35 | $result = NPTest->testCmd( "$command -C launchd -c 5" ); | 35 | $result = NPTest->testCmd( "$command -C launchd -c 5" ); |
36 | is( $result->return_code, 2, "Checking processes filtered by command name" ); | 36 | is( $result->return_code, 2, "Checking processes filtered by command name" ); |
37 | like( $result->output, '/^PROCS CRITICAL: 6 processes with command name \'launchd\'$/', "Output correct" ); | 37 | is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" ); |
38 | 38 | ||
39 | $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" ); | 39 | SKIP: { |
40 | is( $result->return_code, 1, "Checking processes filtered by userid" ); | 40 | skip 'user with uid 501 required', 4 unless getpwuid(501); |
41 | like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" ); | ||
42 | 41 | ||
43 | $result = NPTest->testCmd( "$command -C launchd -u 501" ); | 42 | $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" ); |
44 | is( $result->return_code, 0, "Checking processes filtered by command name and userid" ); | 43 | is( $result->return_code, 1, "Checking processes filtered by userid" ); |
45 | like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" ); | 44 | like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" ); |
45 | |||
46 | $result = NPTest->testCmd( "$command -C launchd -u 501" ); | ||
47 | is( $result->return_code, 0, "Checking processes filtered by command name and userid" ); | ||
48 | like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" ); | ||
49 | } | ||
46 | 50 | ||
47 | $result = NPTest->testCmd( "$command -u -2 -w 2:2" ); | 51 | $result = NPTest->testCmd( "$command -u -2 -w 2:2" ); |
48 | is( $result->return_code, 1, "Checking processes with userid=-2" ); | 52 | is( $result->return_code, 1, "Checking processes with userid=-2" ); |
@@ -62,15 +66,15 @@ like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \ | |||
62 | 66 | ||
63 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); | 67 | $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); |
64 | is( $result->return_code, 0, "Checking regexp search of arguments" ); | 68 | is( $result->return_code, 0, "Checking regexp search of arguments" ); |
65 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501'", "Output correct" ); | 69 | is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); |
66 | 70 | ||
67 | $result = NPTest->testCmd( "$command --vsz 1000000" ); | 71 | $result = NPTest->testCmd( "$command --vsz 1000000" ); |
68 | is( $result->return_code, 0, "Checking filter by VSZ" ); | 72 | is( $result->return_code, 0, "Checking filter by VSZ" ); |
69 | like( $result->output, '/^PROCS OK: 24 processes with VSZ >= 1000000$/', "Output correct" ); | 73 | is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" ); |
70 | 74 | ||
71 | $result = NPTest->testCmd( "$command --rss 100000" ); | 75 | $result = NPTest->testCmd( "$command --rss 100000" ); |
72 | is( $result->return_code, 0, "Checking filter by RSS" ); | 76 | is( $result->return_code, 0, "Checking filter by RSS" ); |
73 | like( $result->output, '/^PROCS OK: 3 processes with RSS >= 100000$/', "Output correct" ); | 77 | is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;', "Output correct" ); |
74 | 78 | ||
75 | $result = NPTest->testCmd( "$command -s S" ); | 79 | $result = NPTest->testCmd( "$command -s S" ); |
76 | is( $result->return_code, 0, "Checking filter for sleeping processes" ); | 80 | is( $result->return_code, 0, "Checking filter for sleeping processes" ); |
@@ -86,34 +90,38 @@ like( $result->output, '/^PROCS CRITICAL: 39 processes with PPID = 1/', "Output | |||
86 | 90 | ||
87 | $result = NPTest->testCmd( "$command -P 0.71" ); | 91 | $result = NPTest->testCmd( "$command -P 0.71" ); |
88 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" ); | 92 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" ); |
89 | is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71', "Output correct" ); | 93 | is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71 | procs=7;;;0;', "Output correct" ); |
90 | 94 | ||
91 | $result = NPTest->testCmd( "$command -P 0.70" ); | 95 | $result = NPTest->testCmd( "$command -P 0.70" ); |
92 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" ); | 96 | is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" ); |
93 | is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70', "Output correct" ); | 97 | is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70 | procs=8;;;0;', "Output correct" ); |
94 | 98 | ||
95 | $result = NPTest->testCmd( "$command --metric=CPU -w 8" ); | 99 | $result = NPTest->testCmd( "$command --metric=CPU -w 8" ); |
96 | is( $result->return_code, 1, "Checking against metric of CPU > 8" ); | 100 | is( $result->return_code, 1, "Checking against metric of CPU > 8" ); |
97 | is( $result->output, 'CPU WARNING: 1 warn out of 95 processes', "Output correct" ); | 101 | is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" ); |
98 | 102 | ||
99 | # TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will. | 103 | # TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will. |
100 | $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" ); | 104 | SKIP: { |
101 | is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" ); | 105 | skip 'user with uid 501 required', 2 unless getpwuid(501); |
102 | is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" ); | 106 | |
107 | $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" ); | ||
108 | is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" ); | ||
109 | is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" ); | ||
110 | }; | ||
103 | 111 | ||
104 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); | 112 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); |
105 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); | 113 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); |
106 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); | 114 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" ); |
107 | 115 | ||
108 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); | 116 | $result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); |
109 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); | 117 | is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); |
110 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); | 118 | is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" ); |
111 | 119 | ||
112 | $result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" ); | 120 | $result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" ); |
113 | is( $result->return_code, 2, "Checking against RSS > 70MB" ); | 121 | is( $result->return_code, 2, "Checking against RSS > 70MB" ); |
114 | is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari]', "Output correct" ); | 122 | is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari] | procs=95;;;0; procs_warn=0;;;0; procs_crit=5;;;0;', "Output correct" ); |
115 | 123 | ||
116 | $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); | 124 | $result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); |
117 | is( $result->return_code, 0, "Checking no pipe symbol in output" ); | 125 | is( $result->return_code, 0, "Checking no pipe symbol in output" ); |
118 | is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)'", "Output correct" ); | 126 | is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); |
119 | 127 | ||