forked from pool/monitoring-plugins
8e37c1a55c
want to analize logs generated by (r)syslog or journald Renamed patches: - renamed monitoring-plugins-1.4.6-no_chown.patch to monitoring-plugins-1.4.6-Makefile_-_no_chown.patch to make it easier to detect the patched file - renamed monitoring-plugins-2.1.1-check_logfile.patch to monitoring-plugins-2.1.1-check_log_-_quoting.patch to make it easier to detect the patched file and reason for the patch New patches: - add monitoring-plugins-2.3.1-check_snmp_segfaults.patch: check_snmp will segfaults at line 489 if number of lines returned by SNMPD is greater than number of defined thresholds -> https://github.com/monitoring-plugins/monitoring-plugins/pull/1589 - added monitoring-plugins-2.3.1_-_check_snmp_hang_on_STDERR_workaround.patch: When the MIBs are not quite right, snmpget outputs lots of errors on STDERR before getting down to business. If this is enough to fill the pipe buffer, snmpget hangs waiting for it to be cleared, which it never will be because check_snmp is waiting for snmpget to output something on STDOUT. This simple fix from s2156945 for this is to read STDERR before STDOUT. cmd_run_array from utils_cmd.c is also used by plugins/check_by_ssh and plugins/negate but you're likely to get lots of errors or lots of output, not both at the same time. The real fix is probably to do a select() and read from both as they come in. https://github.com/monitoring-plugins/monitoring-plugins/issues/1706 - added monitoring-plugins-2.3.1-check_dhcp_-_detect_rogue_dhcp_servers.patch: feature enhancement from Patrick Cervicek for check_dhcp, which allows to detect rogue DHCP servers. Use it with the "-x" flag, example: OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins?expand=0&rev=90
141 lines
6.3 KiB
Diff
141 lines
6.3 KiB
Diff
Index: monitoring-plugins-2.3.1/plugins/t/check_ssh.t
|
|
===================================================================
|
|
--- monitoring-plugins-2.3.1.orig/plugins/t/check_ssh.t
|
|
+++ monitoring-plugins-2.3.1/plugins/t/check_ssh.t
|
|
@@ -8,34 +8,105 @@ 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)");
|
|
+my $res;
|
|
|
|
+# 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 tests => 14 + 6;
|
|
+
|
|
+SKIP: {
|
|
+ skip "SSH_HOST must be defined", 6 unless $ssh_host;
|
|
+ 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)");
|
|
+}
|
|
+
|
|
+SKIP: {
|
|
+ skip "No netcat available", 12 unless (system("which nc > /dev/null") == 0);
|
|
+
|
|
+ my $nc_flags = "-l 5003 -i 1";
|
|
+ #A valid protocol version control string has the form
|
|
+ # SSH-protoversion-softwareversion SP comments CR LF
|
|
+ #
|
|
+ # where `comments` is optional, protoversion is the SSH protocol version and
|
|
+ # softwareversion is an arbitrary string representing the server software version
|
|
+ open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1' | nc ${nc_flags}|");
|
|
+ sleep 1;
|
|
+ $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
|
+ cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string");
|
|
+ like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK");
|
|
+ close NC;
|
|
+
|
|
+ open(NC, "echo 'SSH-2.0-3.2.9.1' | nc ${nc_flags}|");
|
|
+ sleep 1;
|
|
+ $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
|
+ cmp_ok( $res->return_code, "==", 0, "Got SSH protocol version control string with non-alpha softwareversion string");
|
|
+ like( $res->output, '/^SSH OK - 3.2.9.1 \(protocol 2.0\)/', "Output OK for non-alpha softwareversion string");
|
|
+ close NC;
|
|
+
|
|
+ open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1 this is a comment' | nc ${nc_flags} |");
|
|
+ sleep 1;
|
|
+ $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003 -r nagiosplug.ssh.0.1" );
|
|
+ cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string, and parsed comment appropriately");
|
|
+ like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK");
|
|
+ close NC;
|
|
+
|
|
+ open(NC, "echo 'SSH-' | nc ${nc_flags}|");
|
|
+ sleep 1;
|
|
+ $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
|
+ cmp_ok( $res->return_code, '==', 2, "Got invalid SSH protocol version control string");
|
|
+ like( $res->output, '/^SSH CRITICAL/', "Output OK");
|
|
+ close NC;
|
|
+
|
|
+ open(NC, "echo '' | nc ${nc_flags}|");
|
|
+ sleep 1;
|
|
+ $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
|
+ cmp_ok( $res->return_code, '==', 2, "No version control string received");
|
|
+ like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK");
|
|
+ close NC;
|
|
+
|
|
+ open(NC, "echo 'Not a version control string' | nc ${nc_flags}|");
|
|
+ sleep 1;
|
|
+ $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
|
+ cmp_ok( $res->return_code, '==', 2, "No version control string received");
|
|
+ like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK");
|
|
+ close NC;
|
|
+
|
|
+ #RFC 4253 permits servers to send any number of data lines prior to sending the protocol version control string
|
|
+ open(NC, "{ echo 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; sleep 1;
|
|
+ echo 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'; sleep 1;
|
|
+ echo 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'; sleep 1;
|
|
+ echo 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'; sleep 1;
|
|
+ printf 'EEEEEEEEEEEEEEEEEE'; sleep 1;
|
|
+ printf 'EEEEEEEEEEEEEEEEEE\n'; sleep 1;
|
|
+ echo 'Some\nPrepended\nData\nLines\n'; sleep 1;
|
|
+ echo 'SSH-2.0-nagiosplug.ssh.0.2';} | nc ${nc_flags}|");
|
|
+ sleep 1;
|
|
+ $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" );
|
|
+ cmp_ok( $res->return_code, '==', 0, "Got delayed SSH protocol version control string");
|
|
+ like( $res->output, '/^SSH OK - nagiosplug.ssh.0.2 \(protocol 2.0\)/', "Output OK");
|
|
+ close NC;
|
|
+
|