aboutsummaryrefslogtreecommitdiff
path: root/plugins/t/check_cluster.t
blob: f3e78b83c95c047d92c9e1c36fbd098993c2eea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /usr/bin/perl -w -I ..
#
# check_cluster tests
#
# $Id$
#

use strict;
use Test::More tests => 15;
use NPTest;

my $result;

$result = NPTest->testCmd(
	"./check_cluster -s -w 0:0 -c 0:0 -d 0,0,0,0"
	);
cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning ranges" );
like( $result->output, qr/service/i, "Output contains the word 'service' (case insensitive)");

$result = NPTest->testCmd(
	"./check_cluster -l LABEL -s -w 0:0 -c 0:0 -d 0,0,0,0"
	);
like( $result->output, qr/LABEL/, "Output contains the defined label 'LABEL' (case sensitive)");

$result = NPTest->testCmd(
	"./check_cluster -s -w 0:0 -c 0:1 -d 0,0,0,1"
	);
cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok services are inside critical and outside warning ranges" );

$result = NPTest->testCmd(
	"./check_cluster -s -w 0:0 -c 0:1 -d 0,0,1,1"
	);
cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok services are inside critical and outside warning ranges" );

$result = NPTest->testCmd(
	"./check_cluster -s -w 0 -c 0 -d 0,0,0,0"
	);
cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning (no ranges)" );

$result = NPTest->testCmd(
	"./check_cluster -s -w 0 -c 1 -d 0,0,1,0"
	);
cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok services exceed warning (no ranges)" );

$result = NPTest->testCmd(
	"./check_cluster -s -w 0 -c 1 -d 0,0,1,1"
	);
cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok services exceed critical warning (no ranges)" );


#
# And for hosts..
#
$result = NPTest->testCmd(
	"./check_cluster -h -w 0:0 -c 0:0 -d 0,0,0,0"
	);
cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning ranges" );
like( $result->output, qr/host/i, "Output contains the word 'host' (case insensitive)");

$result = NPTest->testCmd(
	"./check_cluster -h -w 0:0 -c 0:1 -d 0,0,0,1"
	);
cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok hosts are inside critical and outside warning ranges" );

$result = NPTest->testCmd(
	"./check_cluster -h -w 0:0 -c 0:1 -d 0,0,1,1"
	);
cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok hosts are inside critical and outside warning ranges" );

$result = NPTest->testCmd(
	"./check_cluster -h -w 0 -c 0 -d 0,0,0,0"
	);
cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning (no ranges)" );

$result = NPTest->testCmd(
	"./check_cluster -h -w 0 -c 1 -d 0,0,1,0"
	);
cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok hosts exceed warning (no ranges)" );

$result = NPTest->testCmd(
	"./check_cluster -h -w 0 -c 1 -d 0,0,1,1"
	);
cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok hosts exceed critical warning (no ranges)" );