check_disk.t 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # Disk Space Tests via check_disk
  4. #
  5. # $Id$
  6. #
  7. use strict;
  8. use Test;
  9. use NPTest;
  10. use vars qw($tests);
  11. BEGIN {$tests = 10; plan tests => $tests}
  12. my $successOutput = '/^DISK OK - /';
  13. my $failureOutput = '/^DISK CRITICAL - /';
  14. my $mountpoint_valid = getTestParameter( "mountpoint_valid", "NP_MOUNTPOINT_VALID", "/",
  15. "The path to a valid mountpoint" );
  16. my $mountpoint_invalid = getTestParameter( "mountpoint_invalid", "NP_MOUNTPOINT_INVALID", "/missing",
  17. "The path to a invalid (non-existent) mountpoint" );
  18. my $t;
  19. $t += checkCmd( "./check_disk 100 100 ${mountpoint_valid}", 0, $successOutput );
  20. $t += checkCmd( "./check_disk -w 0 -c 0 ${mountpoint_valid}", 0, $successOutput );
  21. $t += checkCmd( "./check_disk -w 1\% -c 1\% ${mountpoint_valid}", 0, $successOutput );
  22. $t += checkCmd( "./check_disk 0 0 ${mountpoint_valid}", 2, $failureOutput );
  23. $t += checkCmd( "./check_disk 100 100 ${mountpoint_invalid}", 2, '/not found/' );
  24. exit(0) if defined($Test::Harness::VERSION);
  25. exit($tests - $t);