diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-02 13:37:39 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-02 13:37:39 +0100 |
commit | 3faeed07c4825d5c3ceb323e814e703d9262cd82 (patch) | |
tree | b6a61e24ffa0fbb4af5f145c137f1f584aaba1bc /plugins/t/check_swap.t | |
parent | 735b04eff721a28e791714c0da4c8ac5726bfbcf (diff) | |
parent | 6d1d1dac32841d5ca6ee51bb09b30a6c604b17e2 (diff) | |
download | monitoring-plugins-3faeed07c4825d5c3ceb323e814e703d9262cd82.tar.gz |
Merge branch 'master' into check_swap_again
Diffstat (limited to 'plugins/t/check_swap.t')
-rw-r--r-- | plugins/t/check_swap.t | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t index de9e0f05..18780386 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t | |||
@@ -5,7 +5,7 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test::More tests => 8; | 8 | use Test::More tests => 14; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/'; | 11 | my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/'; |
@@ -14,6 +14,10 @@ my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\) | |||
14 | 14 | ||
15 | my $result; | 15 | my $result; |
16 | 16 | ||
17 | $result = NPTest->testCmd( "./check_swap" ); # Always OK | ||
18 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | ||
19 | like( $result->output, $successOutput, "Right output" ); | ||
20 | |||
17 | $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free | 21 | $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free |
18 | cmp_ok( $result->return_code, "==", 0, "At least 1MB free" ); | 22 | cmp_ok( $result->return_code, "==", 0, "At least 1MB free" ); |
19 | like( $result->output, $successOutput, "Right output" ); | 23 | like( $result->output, $successOutput, "Right output" ); |
@@ -29,3 +33,11 @@ like( $result->output, $failureOutput, "Right output" ); | |||
29 | $result = NPTest->testCmd( "./check_swap -w 100% -c 1%" ); # 100% (always warn) | 33 | $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' ); | 34 | cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' ); |
31 | like( $result->output, $warnOutput, "Right output" ); | 35 | like( $result->output, $warnOutput, "Right output" ); |
36 | |||
37 | $result = NPTest->testCmd( "./check_swap -w 100%" ); # 100% (single threshold, always warn) | ||
38 | cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' ); | ||
39 | like( $result->output, $warnOutput, "Right output" ); | ||
40 | |||
41 | $result = NPTest->testCmd( "./check_swap -c 100%" ); # 100% (single threshold, always critical) | ||
42 | cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' ); | ||
43 | like( $result->output, $failureOutput, "Right output" ); | ||