monitoring-plugins/plugins/t/check_swap.t
Peter Bray cdc06cc3e2 [1185704] New Testing Infrastructure.
Complete rewrite of the original testing infrastructure and
all test cases (to use the new infrastructure)
See NPTest.pm and issue 1185704 for more details.


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1207 f882894a-f735-0410-b71e-b25c423dba1c
2005-07-25 01:47:15 +00:00

25 lines
690 B
Perl

#! /usr/bin/perl -w -I ..
#
# Swap Space Tests via check_swap
#
# $Id$
#
use strict;
use Test;
use NPTest;
use vars qw($tests);
BEGIN {$tests = 6; plan tests => $tests}
my $t;
my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
$t += checkCmd( "./check_swap -w 1048576 -c 1048576", 0, $successOutput ); # 1MB free
$t += checkCmd( "./check_swap -w 1\% -c 1\%", 0, $successOutput ); # 1% free
$t += checkCmd( "./check_swap -w 100\% -c 100\%", 2, $failureOutput ); # 100% free (always fails)
exit(0) if defined($Test::Harness::VERSION);
exit($tests - $t);