pkg-monitoring-plugins/plugins/t/check_users.t

31 lines
873 B
Perl
Raw Normal View History

2013-11-26 22:53:19 +00:00
#! /usr/bin/perl -w -I ..
#
# Logged in Users Tests via check_users
#
2023-10-18 07:29:37 +00:00
# Trick: This check requires at least 1 user logged in. These commands should
# leave a session open forever in the background:
2013-11-26 22:53:19 +00:00
#
# $ ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
# $ disown %1
2013-11-26 22:53:19 +00:00
use strict;
use Test;
use NPTest;
use vars qw($tests);
2016-11-30 11:36:55 +00:00
BEGIN {$tests = 8; plan tests => $tests}
2013-11-26 22:53:19 +00:00
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 );
2016-11-30 11:36:55 +00:00
$t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput );
$t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput );
2013-11-26 22:53:19 +00:00
exit(0) if defined($Test::Harness::VERSION);
exit($tests - $t);