check_load.t 874 B

123456789101112131415161718192021222324252627282930
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # Load Average Tests via check_load
  4. #
  5. # $Id$
  6. #
  7. use strict;
  8. use Test::More;
  9. use NPTest;
  10. my $res;
  11. my $successOutput = '/^OK - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
  12. my $failureOutput = '/^CRITICAL - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
  13. plan tests => 6;
  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");