1
0
Dominique Leuenberger 2022-07-14 14:34:13 +00:00 committed by Git OBS Bridge
commit 8b11caa1b1
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,70 @@
diff -ur monitoring-plugins-2.3.1.orig/plugins/check_by_ssh.c monitoring-plugins-2.3.1/plugins/check_by_ssh.c
--- monitoring-plugins-2.3.1.orig/plugins/check_by_ssh.c 2021-04-10 07:13:41.000000000 -0500
+++ monitoring-plugins-2.3.1/plugins/check_by_ssh.c 2022-07-02 10:33:49.977417534 -0500
@@ -49,6 +49,7 @@
unsigned int services = 0;
int skip_stdout = 0;
int skip_stderr = 0;
+int unknown_timeout = 0;
char *remotecmd = NULL;
char **commargv = NULL;
int commargc = 0;
@@ -100,6 +101,13 @@
result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
+ /* SSH returns 255 if connection attempt fails; include the first line of error output */
+ if (result == 255 && unknown_timeout) {
+ printf (_("SSH connection failed: %s\n"),
+ chld_err.lines > 0 ? chld_err.line[0] : "(no error output)");
+ return STATE_UNKNOWN;
+ }
+
if (verbose) {
for(i = 0; i < chld_out.lines; i++)
printf("stdout: %s\n", chld_out.line[i]);
@@ -176,6 +184,7 @@
{"verbose", no_argument, 0, 'v'},
{"fork", no_argument, 0, 'f'},
{"timeout", required_argument, 0, 't'},
+ {"unknown-timeout", no_argument, 0, 'U'},
{"host", required_argument, 0, 'H'}, /* backward compatibility */
{"hostname", required_argument, 0, 'H'},
{"port", required_argument,0,'p'},
@@ -207,7 +216,7 @@
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
+ c = getopt_long (argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
&option);
if (c == -1 || c == EOF)
@@ -229,6 +238,9 @@
else
timeout_interval = atoi (optarg);
break;
+ case 'U':
+ unknown_timeout = 1;
+ break;
case 'H': /* host */
host_or_die(optarg);
hostname = optarg;
@@ -437,6 +449,8 @@
printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
printf (UT_WARN_CRIT);
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
+ printf (" %s\n","-U, --unknown-timeout");
+ printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));
printf (UT_VERBOSE);
printf("\n");
printf (" %s\n", _("The most common mode of use is to refer to a local identity file with"));
@@ -466,7 +480,7 @@
print_usage (void)
{
printf ("%s\n", _("Usage:"));
- printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n"
+ printf (" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n"
" [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n"
" [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
" [-p port] [-o ssh-option] [-F configfile]\n",

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Sat Jul 2 15:56:26 UTC 2022 - Archie Cobbs <archie.cobbs@gmail.com>
- added monitoring-plugins-2.3.1-check_by_ssh.patch
Adds "-U" flag, which causes a 255 exit value from ssh(1), which
indicates a connection failure, to return UNKNOWN instead of CRITICAL.
(issue #1123)
-------------------------------------------------------------------
Tue Mar 22 09:58:05 UTC 2022 - Stefan Seifert <nine@detonation.org>

View File

@ -87,6 +87,8 @@ Patch126: monitoring-plugins-2.3.1-check_ssh.t_-_improve_testing.patch
# PATCH-FIX-UPSTREAM - see https://github.com/monitoring-plugins/monitoring-plugins/issues/1375
Patch127: monitoring-plugins-2.3.1-check_dhcp_-_detect_rogue_dhcp_servers.patch
Patch128: monitoring-plugins-2.3.1-check_disk_on_btrfs.patch
# PATCH-FIX-UPSTREAM - see https://github.com/monitoring-plugins/monitoring-plugins/pull/1774
Patch129: monitoring-plugins-2.3.1-check_by_ssh.patch
BuildRequires: bind-utils
BuildRequires: dhcp-devel
BuildRequires: fping
@ -1141,6 +1143,7 @@ done
%patch126 -p1
%patch127 -p1
%patch128 -p1
%patch129 -p1
find -type f -exec chmod 644 {} +
%build