4
0

check_load.t 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # Load Average Tests via check_load
  4. #
  5. #
  6. use strict;
  7. use Test::More;
  8. use NPTest;
  9. my $res;
  10. my $loadValue = "[0-9]+\.?[0-9]+";
  11. my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/";
  12. my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
  13. plan tests => 11;
  14. $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
  15. cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
  16. like( $res->output, $successOutput, "Output OK");
  17. $res = NPTest->testCmd( "./check_load -w 0,0,0 -c 0,0,0" );
  18. cmp_ok( $res->return_code, 'eq', 2, "Load over 0");
  19. like( $res->output, $failureOutput, "Output OK");
  20. $res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
  21. cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
  22. like( $res->output, $failureOutput, "Output OK");
  23. $res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
  24. cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
  25. like( $res->output, $successOutput, "Output OK");
  26. like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
  27. like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
  28. like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");