summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_users.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:48:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:48:22 +0000
commit7373ce3d6988706388f136e1c06afd20a3e8d5be (patch)
treee9ae5af7d102667e5706187646db45de8238e8c4 /plugins/t/check_users.t
parentInitial commit. (diff)
downloadmonitoring-plugins-upstream.tar.xz
monitoring-plugins-upstream.zip
Adding upstream version 2.3.5.upstream/2.3.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--plugins/t/check_users.t30
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t
new file mode 100644
index 0000000..9ebc2fc
--- /dev/null
+++ b/plugins/t/check_users.t
@@ -0,0 +1,30 @@
+#! /usr/bin/perl -w -I ..
+#
+# Logged in Users Tests via check_users
+#
+# Trick: This check requires at least 1 user logged in. These commands should
+# leave a session open forever in the background:
+#
+# $ ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
+# $ disown %1
+
+use strict;
+use Test;
+use NPTest;
+
+use vars qw($tests);
+BEGIN {$tests = 8; plan tests => $tests}
+
+my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
+my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/';
+
+my $t;
+
+$t += checkCmd( "./check_users 1000 1000", 0, $successOutput );
+$t += checkCmd( "./check_users 0 0", 2, $failureOutput );
+$t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput );
+$t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput );
+
+exit(0) if defined($Test::Harness::VERSION);
+exit($tests - $t);
+