Fix INADDR_NONE value (for systems which don't define it).
[monitoring-plugins.git] / plugins / t / check_load.t
blob8987b84cc9efbf61fa32466bca995db47cccb78c
1 #! /usr/bin/perl -w -I ..
3 # Load Average Tests via check_load
5 # $Id$
8 use strict;
9 use Test::More;
10 use NPTest;
12 my $res;
14 my $loadValue = "[0-9]+\.?[0-9]+";
15 my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/";
16 my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
18 plan tests => 11;
20 $res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
21 cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
22 like( $res->output, $successOutput, "Output OK");
24 $res = NPTest->testCmd( "./check_load -w 0,0,0 -c 0,0,0" );
25 cmp_ok( $res->return_code, 'eq', 2, "Load over 0");
26 like( $res->output, $failureOutput, "Output OK");
28 $res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
29 cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
30 like( $res->output, $failureOutput, "Output OK");
32 $res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
33 cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
34 like( $res->output, $successOutput, "Output OK");
35 like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
36 like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
37 like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");