Code

check_http: check for and print the certificate cn
[nagiosplug.git] / plugins / t / check_load.t
1 #! /usr/bin/perl -w -I ..
2 #
3 # Load Average Tests via check_load
4 #
5 #
7 use strict;
8 use Test::More;
9 use NPTest;
11 my $res;
13 my $loadValue = "[0-9]+\.?[0-9]+";
14 my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/";
15 my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
17 plan tests => 11;
19 $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
20 cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
21 like( $res->output, $successOutput, "Output OK");
23 $res = NPTest->testCmd( "./check_load -w 0,0,0 -c 0,0,0" );
24 cmp_ok( $res->return_code, 'eq', 2, "Load over 0");
25 like( $res->output, $failureOutput, "Output OK");
27 $res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
28 cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
29 like( $res->output, $failureOutput, "Output OK");
31 $res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
32 cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
33 like( $res->output, $successOutput, "Output OK");
34 like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
35 like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
36 like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");