check_swap.t 815 B

12345678910111213141516171819202122232425262728293031323334
  1. #! /usr/bin/perl -w
  2. use strict;
  3. use Cache;
  4. use Test;
  5. use vars qw($tests);
  6. BEGIN {$tests = 6; plan tests => $tests}
  7. my $null = '';
  8. my $cmd;
  9. my $str;
  10. my $t;
  11. $cmd = "./check_swap 100 100";
  12. $str = `$cmd`;
  13. $t += ok $?>>8,0;
  14. print "Test was: $cmd\n" if ($?);
  15. $t += ok $str, '/^Swap ok - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/';
  16. $cmd = "./check_swap 0 0";
  17. $str = `$cmd`;
  18. $t += ok $?>>8,2;
  19. print "Test was: $cmd\n" unless ($?);
  20. $t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/';
  21. $cmd = "./check_swap 100 100 1000000000 1000000000";
  22. $str = `$cmd`;
  23. $t += ok $?>>8,2;
  24. print "Test was: $cmd\n" unless ($?);
  25. $t += ok $str, '/^CRITICAL - Swap used\: +[0-9]{1,2}\% \([0-9]+ bytes out of [0-9]+\)$/';
  26. exit(0) if defined($Test::Harness::VERSION);
  27. exit($tests - $t);