Merge pull request #1586 from computersalat/master
[monitoring-plugins.git] / plugins / t / check_users.t
blob088f3b520ed932c00e3dd403569fa3bd6db1a607
1 #! /usr/bin/perl -w -I ..
3 # Logged in Users Tests via check_users
5 # Trick: This ckeck requires at least 1 user logged in. These commands should
6 # leave a session open forever in the background:
8 # $ ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
9 # $ disown %1
11 use strict;
12 use Test;
13 use NPTest;
15 use vars qw($tests);
16 BEGIN {$tests = 8; plan tests => $tests}
18 my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
19 my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/';
21 my $t;
23 $t += checkCmd( "./check_users 1000 1000", 0, $successOutput );
24 $t += checkCmd( "./check_users 0 0", 2, $failureOutput );
25 $t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput );
26 $t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput );
28 exit(0) if defined($Test::Harness::VERSION);
29 exit($tests - $t);