summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2014-01-31 18:00:53 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2014-01-31 18:00:53 (GMT)
commitf3078c33f6fd90faba50ebad35acad2df037b450 (patch)
tree1c78c741d74258edb0e5b46a0ec2ea109e79d6d9
parentf45adede7d3f4ef5e7a7d2d136eeb49f372bd500 (diff)
downloadmonitoring-plugins-f3078c33f6fd90faba50ebad35acad2df037b450.tar.gz
Add perfdata in check_proc output tests
-rwxr-xr-xplugins/tests/check_procs.t30
1 files changed, 15 insertions, 15 deletions
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index d71c83a..06ad9df 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -18,23 +18,23 @@ my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin";
18 18
19$result = NPTest->testCmd( "$command" ); 19$result = NPTest->testCmd( "$command" );
20is( $result->return_code, 0, "Run with no options" ); 20is( $result->return_code, 0, "Run with no options" );
21like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); 21is( $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" );
24is( $result->return_code, 1, "Checking > 5 processes" ); 24is( $result->return_code, 1, "Checking > 5 processes" );
25like( $result->output, '/^PROCS WARNING: 95 processes$/', "Output correct" ); 25is( $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" );
28is( $result->return_code, 2, "Checking critical" ); 28is( $result->return_code, 2, "Checking critical" );
29like( $result->output, '/^PROCS CRITICAL: 95 processes$/', "Output correct" ); 29is( $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" );
32is( $result->return_code, 0, "Checking no threshold breeched" ); 32is( $result->return_code, 0, "Checking no threshold breeched" );
33like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); 33is( $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" );
36is( $result->return_code, 2, "Checking processes filtered by command name" ); 36is( $result->return_code, 2, "Checking processes filtered by command name" );
37like( $result->output, '/^PROCS CRITICAL: 6 processes with command name \'launchd\'$/', "Output correct" ); 37is( $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$result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
40is( $result->return_code, 1, "Checking processes filtered by userid" ); 40is( $result->return_code, 1, "Checking processes filtered by userid" );
@@ -62,15 +62,15 @@ like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \
62 62
63$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); 63$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
64is( $result->return_code, 0, "Checking regexp search of arguments" ); 64is( $result->return_code, 0, "Checking regexp search of arguments" );
65is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501'", "Output correct" ); 65is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
66 66
67$result = NPTest->testCmd( "$command --vsz 1000000" ); 67$result = NPTest->testCmd( "$command --vsz 1000000" );
68is( $result->return_code, 0, "Checking filter by VSZ" ); 68is( $result->return_code, 0, "Checking filter by VSZ" );
69like( $result->output, '/^PROCS OK: 24 processes with VSZ >= 1000000$/', "Output correct" ); 69is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" );
70 70
71$result = NPTest->testCmd( "$command --rss 100000" ); 71$result = NPTest->testCmd( "$command --rss 100000" );
72is( $result->return_code, 0, "Checking filter by RSS" ); 72is( $result->return_code, 0, "Checking filter by RSS" );
73like( $result->output, '/^PROCS OK: 3 processes with RSS >= 100000$/', "Output correct" ); 73is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;', "Output correct" );
74 74
75$result = NPTest->testCmd( "$command -s S" ); 75$result = NPTest->testCmd( "$command -s S" );
76is( $result->return_code, 0, "Checking filter for sleeping processes" ); 76is( $result->return_code, 0, "Checking filter for sleeping processes" );
@@ -86,15 +86,15 @@ like( $result->output, '/^PROCS CRITICAL: 39 processes with PPID = 1/', "Output
86 86
87$result = NPTest->testCmd( "$command -P 0.71" ); 87$result = NPTest->testCmd( "$command -P 0.71" );
88is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" ); 88is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" );
89is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71', "Output correct" ); 89is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71 | procs=7;;;0;', "Output correct" );
90 90
91$result = NPTest->testCmd( "$command -P 0.70" ); 91$result = NPTest->testCmd( "$command -P 0.70" );
92is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" ); 92is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" );
93is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70', "Output correct" ); 93is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70 | procs=8;;;0;', "Output correct" );
94 94
95$result = NPTest->testCmd( "$command --metric=CPU -w 8" ); 95$result = NPTest->testCmd( "$command --metric=CPU -w 8" );
96is( $result->return_code, 1, "Checking against metric of CPU > 8" ); 96is( $result->return_code, 1, "Checking against metric of CPU > 8" );
97is( $result->output, 'CPU WARNING: 1 warn out of 95 processes', "Output correct" ); 97is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" );
98 98
99# TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will. 99# 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" ); 100$result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
@@ -103,17 +103,17 @@ is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (to
103 103
104$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); 104$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
105is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); 105is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
106is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); 106is( $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 107
108$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); 108$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
109is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); 109is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
110is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); 110is( $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 111
112$result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" ); 112$result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" );
113is( $result->return_code, 2, "Checking against RSS > 70MB" ); 113is( $result->return_code, 2, "Checking against RSS > 70MB" );
114is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari]', "Output correct" ); 114is( $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 115
116$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); 116$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
117is( $result->return_code, 0, "Checking no pipe symbol in output" ); 117is( $result->return_code, 0, "Checking no pipe symbol in output" );
118is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)'", "Output correct" ); 118is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
119 119