2005-07-24 21:47:15 -04:00
|
|
|
#! /usr/bin/perl -w -I ..
|
|
|
|
|
#
|
|
|
|
|
# Load Average Tests via check_load
|
|
|
|
|
#
|
|
|
|
|
#
|
2002-02-28 01:42:51 -05:00
|
|
|
|
|
|
|
|
use strict;
|
2006-03-21 08:42:18 -05:00
|
|
|
use Test::More;
|
2005-07-24 21:47:15 -04:00
|
|
|
use NPTest;
|
2002-02-28 01:42:51 -05:00
|
|
|
|
2006-03-21 08:42:18 -05:00
|
|
|
my $res;
|
2002-02-28 01:42:51 -05:00
|
|
|
|
2007-12-09 19:19:27 -05:00
|
|
|
my $loadValue = "[0-9]+\.?[0-9]+";
|
2021-07-05 04:30:39 -04:00
|
|
|
my $successOutput = "/^LOAD OK - load average: $loadValue, $loadValue, $loadValue/";
|
|
|
|
|
my $failureOutput = "/^LOAD CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
|
2002-02-28 01:42:51 -05:00
|
|
|
|
2007-12-09 19:19:27 -05:00
|
|
|
plan tests => 11;
|
2002-02-28 01:42:51 -05:00
|
|
|
|
2006-03-21 08:42:18 -05:00
|
|
|
$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
|
|
|
|
|
cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
|
|
|
|
|
like( $res->output, $successOutput, "Output OK");
|
2002-02-28 01:42:51 -05:00
|
|
|
|
2006-03-21 08:42:18 -05:00
|
|
|
$res = NPTest->testCmd( "./check_load -w 0,0,0 -c 0,0,0" );
|
|
|
|
|
cmp_ok( $res->return_code, 'eq', 2, "Load over 0");
|
|
|
|
|
like( $res->output, $failureOutput, "Output OK");
|
2005-07-24 21:47:15 -04:00
|
|
|
|
2007-04-25 18:10:13 -04:00
|
|
|
$res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
|
|
|
|
|
cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
|
|
|
|
|
like( $res->output, $failureOutput, "Output OK");
|
|
|
|
|
|
2007-12-09 19:19:27 -05:00
|
|
|
$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
|
|
|
|
|
cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
|
|
|
|
|
like( $res->output, $successOutput, "Output OK");
|
|
|
|
|
like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
|
|
|
|
|
like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
|
|
|
|
|
like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");
|