summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSven Nierlein <Sven.Nierlein@consol.de>2013-09-17 09:43:22 (GMT)
committerSven Nierlein <sven@consol.de>2013-09-17 10:13:51 (GMT)
commit9090beb058739f24930c27a3864daa773985144d (patch)
tree9755665c3d5acef0c448389f1ea40d0974783d07 /plugins
parentb83904c528d98a6eaed570cf82e0595107bab53e (diff)
downloadmonitoring-plugins-9090beb058739f24930c27a3864daa773985144d.tar.gz
check_ssh: added test case
Diffstat (limited to 'plugins')
-rw-r--r--plugins/t/check_ssh.t49
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/t/check_ssh.t b/plugins/t/check_ssh.t
new file mode 100644
index 0000000..8008349
--- /dev/null
+++ b/plugins/t/check_ssh.t
@@ -0,0 +1,49 @@
1#! /usr/bin/perl -w -I ..
2#
3# check_ssh tests
4#
5#
6
7use strict;
8use Test::More;
9use NPTest;
10
11# Required parameters
12my $ssh_host = getTestParameter("NP_SSH_HOST",
13 "A host providing SSH service",
14 "localhost");
15
16my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE",
17 "The hostname of system not responsive to network requests",
18 "10.0.0.1" );
19
20my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID",
21 "An invalid (not known to DNS) hostname",
22 "nosuchhost" );
23
24
25plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
26plan tests => 6;
27
28
29my $result = NPTest->testCmd(
30 "./check_ssh -H $ssh_host"
31 );
32cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
33like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
34
35
36$result = NPTest->testCmd(
37 "./check_ssh -H $host_nonresponsive -t 2"
38 );
39cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
40like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
41
42
43
44$result = NPTest->testCmd(
45 "./check_ssh -H $hostname_invalid -t 2"
46 );
47cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
48like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
49