Code

check_smtp: Abort on missing/unexpected greeting
[nagiosplug.git] / plugins / t / check_swap.t
1 #! /usr/bin/perl -w -I ..
2 #
3 # Swap Space Tests via check_swap
4 #
5 #
7 use strict;
8 use Test::More tests => 8;
9 use NPTest;
11 my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
12 my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
13 my $warnOutput    = '/^SWAP WARNING - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
15 my $result;
17 $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" );              # 1 MB free
18 cmp_ok( $result->return_code, "==", 0, "At least 1MB free" );
19 like( $result->output, $successOutput, "Right output" );
21 $result = NPTest->testCmd( "./check_swap -w 1% -c 1%" );                        # 1% free
22 cmp_ok( $result->return_code, "==", 0, 'At least 1% free' );
23 like( $result->output, $successOutput, "Right output" );
25 $result = NPTest->testCmd( "./check_swap -w 100% -c 100%" );                    # 100% (always critical)
26 cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' );
27 like( $result->output, $failureOutput, "Right output" );
29 $result = NPTest->testCmd( "./check_swap -w 100% -c 1%" );                      # 100% (always warn)
30 cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
31 like( $result->output, $warnOutput, "Right output" );