Code

check_http: check for and print the certificate cn
[nagiosplug.git] / plugins / t / check_jabber.t
1 #! /usr/bin/perl -w -I ..
2 #
3 # Jabber Server Tests via check_jabber
4 #
5 #
7 use strict;
8 use Test::More;
9 use NPTest;
11 plan tests => 10;
13 my $host_tcp_jabber = getTestParameter( 
14                         "NP_HOST_TCP_JABBER",
15                         "A host providing the Jabber Service",
16                         "jabber.org"
17                         );
19 my $host_nonresponsive = getTestParameter(
20                         "NP_HOST_NONRESPONSIVE", 
21                         "The hostname of system not responsive to network requests",
22                         "10.0.0.1",
23                         );
25 my $hostname_invalid   = getTestParameter( 
26                         "NP_HOSTNAME_INVALID",
27                         "An invalid (not known to DNS) hostname",
28                         "nosuchhost",
29                         );
32 my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/';
34 my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/';
36 my $jabberInvalid = '/JABBER CRITICAL - Invalid hostname, address or socket:\s.+/';
38 my $r;
40 SKIP: {
41         skip "No jabber server defined", 6 unless $host_tcp_jabber;
43         $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber" );
44         is( $r->return_code, 0, "Connected okay");
45         like( $r->output, $jabberOK, "Output as expected" );
47         $r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber -w 9 -c 9 -t 10" );
48         is( $r->return_code, 0, "Connected okay, within limits" );
49         like( $r->output, $jabberOK, "Output as expected" );
50         
51         $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10" );
52         is( $r->return_code, 0, "Old syntax okay" );
53         like( $r->output, $jabberOK, "Output as expected" );
55 }
57 $r = NPTest->testCmd( "./check_jabber $host_nonresponsive" );
58 is( $r->return_code, 2, "Unresponsive host gives critical" );
59 like( $r->output, $jabberUnresponsive );
61 $r = NPTest->testCmd( "./check_jabber $hostname_invalid" );
62 is( $r->return_code, 2, "Invalid hostname gives critical" );
63 like( $r->output, $jabberInvalid );