1 #! /usr/bin/perl -w -I ..
12 my $ssh_host = getTestParameter
("NP_SSH_HOST",
13 "A host providing SSH service",
16 my $host_nonresponsive = getTestParameter
("NP_HOST_NONRESPONSIVE",
17 "The hostname of system not responsive to network requests",
20 my $hostname_invalid = getTestParameter
("NP_HOSTNAME_INVALID",
21 "An invalid (not known to DNS) hostname",
25 plan skip_all
=> "SSH_HOST must be defined" unless $ssh_host;
29 my $result = NPTest
->testCmd(
30 "./check_ssh -H $ssh_host"
32 cmp_ok
($result->return_code, '==', 0, "Exit with return code 0 (OK)");
33 like
($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
36 $result = NPTest
->testCmd(
37 "./check_ssh -H $host_nonresponsive -t 2"
39 cmp_ok
($result->return_code, '==', 2, "Exit with return code 0 (OK)");
40 like
($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
44 $result = NPTest
->testCmd(
45 "./check_ssh -H $hostname_invalid -t 2"
47 cmp_ok
($result->return_code, '==', 3, "Exit with return code 0 (OK)");
48 like
($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");