summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Nierlein <Sven.Nierlein@consol.de>2014-02-18 15:20:11 (GMT)
committerSven Nierlein <Sven.Nierlein@consol.de>2014-02-18 15:20:11 (GMT)
commit385340a4ef89e0feac915e2154b7e3d155f42b73 (patch)
treeae077f1a22f9c91cb2e5d1feaa9f276eb8ac5a4c
parent4f5e20187f1832fce1627c12b9331a05f9dda390 (diff)
downloadmonitoring-plugins-385340a4ef89e0feac915e2154b7e3d155f42b73.tar.gz
check_procs test fails if there is no user with uid 501
thats because check_procs verifys there is a user for a given uid filter. So even we use sample data for this test, we still need a real user. Signed-off-by: Sven Nierlein <Sven.Nierlein@consol.de>
-rwxr-xr-xplugins/tests/check_procs.t26
1 files changed, 17 insertions, 9 deletions
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 06ad9df..1ad2c2f 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -36,13 +36,17 @@ $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" );
37is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "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" ); 39SKIP: {
40is( $result->return_code, 1, "Checking processes filtered by userid" ); 40 skip 'user with uid 501 required', 4 unless getpwuid(501);
41like( $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" );
44is( $result->return_code, 0, "Checking processes filtered by command name and userid" ); 43 is( $result->return_code, 1, "Checking processes filtered by userid" );
45like( $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" );
48is( $result->return_code, 1, "Checking processes with userid=-2" ); 52is( $result->return_code, 1, "Checking processes with userid=-2" );
@@ -97,9 +101,13 @@ is( $result->return_code, 1, "Checking against metric of CPU > 8" );
97is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" ); 101is( $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" ); 104SKIP: {
101is( $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);
102is( $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" );
105is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); 113is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );