aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <Sven.Nierlein@consol.de> 2013-09-17 11:43:22 +0200
committerGravatar Sven Nierlein <sven@consol.de> 2013-09-17 12:13:51 +0200
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 00000000..80083492
--- /dev/null
+++ b/plugins/t/check_ssh.t
@@ -0,0 +1,49 @@
+#! /usr/bin/perl -w -I ..
+#
+# check_ssh tests
+#
+#
+
+use strict;
+use Test::More;
+use NPTest;
+
+# Required parameters
+my $ssh_host = getTestParameter("NP_SSH_HOST",
+ "A host providing SSH service",
+ "localhost");
+
+my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE",
+ "The hostname of system not responsive to network requests",
+ "10.0.0.1" );
+
+my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID",
+ "An invalid (not known to DNS) hostname",
+ "nosuchhost" );
+
+
+plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
+plan tests => 6;
+
+
+my $result = NPTest->testCmd(
+ "./check_ssh -H $ssh_host"
+ );
+cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
+like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
+
+
+$result = NPTest->testCmd(
+ "./check_ssh -H $host_nonresponsive -t 2"
+ );
+cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
+like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
+
+
+
+$result = NPTest->testCmd(
+ "./check_ssh -H $hostname_invalid -t 2"
+ );
+cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
+like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
+