diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2022-01-03 13:48:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 13:48:39 +0100 |
commit | 2714df42fd27ec377228a102acff3744d6bff86d (patch) | |
tree | 3098fa3d9be4826e5da9d1df39ecf6b42bf3570b /plugins/t/check_fping.t | |
parent | 11af74de386ba7c02d5d0e53f2500b5029a4537d (diff) | |
parent | 78a999edd4dd3305ef8fa3e06c43f6a893fb6fea (diff) | |
download | monitoring-plugins-2714df42fd27ec377228a102acff3744d6bff86d.tar.gz |
Merge branch 'master' into master
Diffstat (limited to 'plugins/t/check_fping.t')
-rw-r--r-- | plugins/t/check_fping.t | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t index 342b0a7e..67b357b2 100644 --- a/plugins/t/check_fping.t +++ b/plugins/t/check_fping.t | |||
@@ -5,34 +5,30 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test; | 8 | use Test::More; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | use vars qw($tests); | ||
12 | |||
13 | BEGIN {$tests = 4; plan tests => $tests} | ||
14 | |||
15 | my $successOutput = '/^FPING OK - /'; | ||
16 | my $failureOutput = '/^FPING CRITICAL - /'; | ||
17 | |||
18 | my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "localhost"); | 11 | my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "localhost"); |
19 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); | 12 | my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); |
20 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); | 13 | my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost"); |
21 | 14 | ||
22 | my $t; | 15 | my $res; |
23 | 16 | ||
24 | my $fping = qx(which fping 2> /dev/null); | 17 | my $fping = qx(which fping 2> /dev/null); |
25 | chomp($fping); | 18 | chomp($fping); |
26 | if( ! -x "./check_fping") { | 19 | if( ! -x "./check_fping") { |
27 | $t += skipMissingCmd( "./check_fping", $tests ); | 20 | plan skip_all => "check_fping not found, skipping tests"; |
28 | } | 21 | } |
29 | elsif ( $> != 0 && (!$fping || ! -u $fping)) { | 22 | elsif ( !$fping || !-x $fping ) { |
30 | $t += skipMsg( "./check_fping", $tests ); | 23 | plan skip_all => "fping not found or cannot be executed, skipping tests"; |
31 | } else { | 24 | } else { |
32 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); | 25 | plan tests => 3; |
33 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); | 26 | $res = NPTest->testCmd( "./check_fping $host_responsive" ); |
34 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); | 27 | cmp_ok( $res->return_code, '==', 0, "Responsive host returns OK"); |
35 | } | 28 | |
29 | $res = NPTest->testCmd( "./check_fping $host_nonresponsive" ); | ||
30 | cmp_ok( $res->return_code, '==', 2, "Non-Responsive host returns Critical"); | ||
36 | 31 | ||
37 | exit(0) if defined($Test::Harness::VERSION); | 32 | $res = NPTest->testCmd( "./check_fping $hostname_invalid" ); |
38 | exit($tests - $t); | 33 | cmp_ok( $res->return_code, '==', 3, "Invalid host returns Unknown"); |
34 | } | ||