Merge branch 'master' of ssh://tonvoon@nagiosplug.git.sourceforge.net/gitroot/nagiosp...
[monitoring-plugins.git] / plugins / t / check_cluster.t
blob4736f067513d17bcb1948230f6b252c903910f71
1 #! /usr/bin/perl -w -I ..
3 # check_cluster tests
7 use strict;
8 use Test::More tests => 15;
9 use NPTest;
11 my $result;
13 $result = NPTest->testCmd(
14 "./check_cluster -s -w 0:0 -c 0:0 -d 0,0,0,0"
16 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning ranges" );
17 like( $result->output, qr/service/i, "Output contains the word 'service' (case insensitive)");
19 $result = NPTest->testCmd(
20 "./check_cluster -l LABEL -s -w 0:0 -c 0:0 -d 0,0,0,0"
22 like( $result->output, qr/LABEL/, "Output contains the defined label 'LABEL' (case sensitive)");
24 $result = NPTest->testCmd(
25 "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,0,1"
27 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok services are inside critical and outside warning ranges" );
29 $result = NPTest->testCmd(
30 "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,1,1"
32 cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok services are inside critical and outside warning ranges" );
34 $result = NPTest->testCmd(
35 "./check_cluster -s -w 0 -c 0 -d 0,0,0,0"
37 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning (no ranges)" );
39 $result = NPTest->testCmd(
40 "./check_cluster -s -w 0 -c 1 -d 0,0,1,0"
42 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok services exceed warning (no ranges)" );
44 $result = NPTest->testCmd(
45 "./check_cluster -s -w 0 -c 1 -d 0,0,1,1"
47 cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok services exceed critical warning (no ranges)" );
51 # And for hosts..
53 $result = NPTest->testCmd(
54 "./check_cluster -h -w 0:0 -c 0:0 -d 0,0,0,0"
56 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning ranges" );
57 like( $result->output, qr/host/i, "Output contains the word 'host' (case insensitive)");
59 $result = NPTest->testCmd(
60 "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,0,1"
62 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok hosts are inside critical and outside warning ranges" );
64 $result = NPTest->testCmd(
65 "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,1,1"
67 cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok hosts are inside critical and outside warning ranges" );
69 $result = NPTest->testCmd(
70 "./check_cluster -h -w 0 -c 0 -d 0,0,0,0"
72 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning (no ranges)" );
74 $result = NPTest->testCmd(
75 "./check_cluster -h -w 0 -c 1 -d 0,0,1,0"
77 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok hosts exceed warning (no ranges)" );
79 $result = NPTest->testCmd(
80 "./check_cluster -h -w 0 -c 1 -d 0,0,1,1"
82 cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok hosts exceed critical warning (no ranges)" );