1 #! /usr/bin/perl -w -I ..
3 # Load Average Tests via check_load
13 my $loadValue = "[0-9]+\.?[0-9]+";
14 my $successOutput = "/^LOAD OK - total load average: $loadValue, $loadValue, $loadValue/";
15 my $successScaledOutput = "/^LOAD OK - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
16 my $failureOutput = "/^LOAD CRITICAL - total load average: $loadValue, $loadValue, $loadValue/";
17 my $failurScaledOutput = "/^LOAD CRITICAL - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
21 $res = NPTest
->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
22 cmp_ok
( $res->return_code, 'eq', 0, "load not over 100");
23 like
( $res->output, $successOutput, "Output OK");
25 $res = NPTest
->testCmd( "./check_load -w 0,0,0 -c 0,0,0" );
26 cmp_ok
( $res->return_code, 'eq', 2, "Load over 0");
27 like
( $res->output, $failureOutput, "Output OK");
29 $res = NPTest
->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
30 cmp_ok
( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
31 like
( $res->output, $failurScaledOutput, "Output OK");
33 $res = NPTest
->testCmd( "./check_load -w 100 -c 100,110" );
34 cmp_ok
( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
35 like
( $res->output, $successOutput, "Output OK");
36 like
( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
37 like
( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
38 like
( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");
41 $res = NPTest
->testCmd( "./check_load -w 100,100,100 -c 100,100,100 -r" );
42 cmp_ok
( $res->return_code, 'eq', 0, "load not over 100");
43 like
( $res->output, $successScaledOutput, "Output OK");