aboutsummaryrefslogtreecommitdiff
path: root/plugins/tests/check_procs.t
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <Sven.Nierlein@consol.de> 2014-02-18 16:20:11 +0100
committerGravatar Sven Nierlein <Sven.Nierlein@consol.de> 2014-02-18 16:20:11 +0100
commit385340a4ef89e0feac915e2154b7e3d155f42b73 (patch)
treeae077f1a22f9c91cb2e5d1feaa9f276eb8ac5a4c /plugins/tests/check_procs.t
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>
Diffstat (limited to 'plugins/tests/check_procs.t')
-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 06ad9dfc..1ad2c2f1 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" );
is( $result->return_code, 2, "Checking processes filtered by command name" );
is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
-$result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
-is( $result->return_code, 1, "Checking processes filtered by userid" );
-like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
+SKIP: {
+ skip 'user with uid 501 required', 4 unless getpwuid(501);
-$result = NPTest->testCmd( "$command -C launchd -u 501" );
-is( $result->return_code, 0, "Checking processes filtered by command name and userid" );
-like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
+ $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
+ is( $result->return_code, 1, "Checking processes filtered by userid" );
+ like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
+
+ $result = NPTest->testCmd( "$command -C launchd -u 501" );
+ is( $result->return_code, 0, "Checking processes filtered by command name and userid" );
+ like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
+}
$result = NPTest->testCmd( "$command -u -2 -w 2:2" );
is( $result->return_code, 1, "Checking processes with userid=-2" );
@@ -97,9 +101,13 @@ is( $result->return_code, 1, "Checking against metric of CPU > 8" );
is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" );
# TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will.
-$result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
-is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" );
-is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" );
+SKIP: {
+ skip 'user with uid 501 required', 2 unless getpwuid(501);
+
+ $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
+ is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" );
+ is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" );
+};
$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );