4
0

check_fping.t 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # FPing Tests via check_fping
  4. #
  5. #
  6. use strict;
  7. use Test;
  8. use NPTest;
  9. use vars qw($tests);
  10. BEGIN {$tests = 4; plan tests => $tests}
  11. my $successOutput = '/^FPING OK - /';
  12. my $failureOutput = '/^FPING CRITICAL - /';
  13. my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost",
  14. "The hostname of system responsive to network requests" );
  15. my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
  16. "The hostname of system not responsive to network requests" );
  17. my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
  18. "An invalid (not known to DNS) hostname" );
  19. my $t;
  20. my $fping = qx(which fping 2> /dev/null);
  21. chomp($fping);
  22. if( ! -x "./check_fping") {
  23. $t += skipMissingCmd( "./check_fping", $tests );
  24. }
  25. elsif ( $> != 0 && (!$fping || ! -u $fping)) {
  26. $t += skipMsg( "./check_fping", $tests );
  27. } else {
  28. $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput );
  29. $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] );
  30. $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] );
  31. }
  32. exit(0) if defined($Test::Harness::VERSION);
  33. exit($tests - $t);