From a87f9bd8de15418d9df85dc8bfa531426c84f297 Mon Sep 17 00:00:00 2001 From: Stephen Smoogen Date: Mar 12 2017 22:31:10 +0000 Subject: Fix the patch order to get the code working again. get final fix from patrick for check_http header problem --- diff --git a/nagios-plugins-0001-Updates-to-git-20170227.patch b/nagios-plugins-0001-Updates-to-git-20170227.patch new file mode 100644 index 0000000..b36c7cd --- /dev/null +++ b/nagios-plugins-0001-Updates-to-git-20170227.patch @@ -0,0 +1,208 @@ +diff -up ./plugins/check_http.c.git-20170227-39c5e4ed595c ./plugins/check_http.c +--- ./plugins/check_http.c.git-20170227-39c5e4ed595c 2017-01-19 11:01:31.000000000 -0500 ++++ ./plugins/check_http.c 2017-03-12 16:52:42.658470005 -0400 +@@ -1263,12 +1263,14 @@ check_http (void) + /* server errors result in a critical state */ + else if (http_status >= 500) { + xasprintf (&msg, _("%s%s - "), msg, status_line); +- result = STATE_CRITICAL; ++ if (bad_response || !server_expect_yn) ++ result = STATE_CRITICAL; + } + /* client errors result in a warning state */ + else if (http_status >= 400) { + xasprintf (&msg, _("%s%s - "), msg, status_line); +- result = max_state_alt(STATE_WARNING, result); ++ if (bad_response || !server_expect_yn) ++ result = max_state_alt(STATE_WARNING, result); + } + /* check redirected page if specified */ + else if (http_status >= 300) { +diff -up ./plugins/check_snmp.c.git-20170227-39c5e4ed595c ./plugins/check_snmp.c +--- ./plugins/check_snmp.c.git-20170227-39c5e4ed595c 2017-01-19 11:01:31.000000000 -0500 ++++ ./plugins/check_snmp.c 2017-03-12 16:53:00.559189010 -0400 +@@ -724,7 +724,7 @@ process_arguments (int argc, char **argv + } + + while (1) { +- c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", ++ c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", + longopts, &option); + + if (c == -1 || c == EOF) +diff -up ./plugins/check_swap.c.git-20170227-39c5e4ed595c ./plugins/check_swap.c +--- ./plugins/check_swap.c.git-20170227-39c5e4ed595c 2017-01-16 12:24:03.000000000 -0500 ++++ ./plugins/check_swap.c 2017-03-12 16:53:10.699029841 -0400 +@@ -51,7 +51,7 @@ const char *email = "devel@nagios-plugin + # define SWAP_CONVERSION 1 + #endif + +-int check_swap (int usp, float free_swap_mb); ++int check_swap (int usp, double free_swap_mb); + int process_arguments (int argc, char **argv); + int validate_arguments (void); + void print_usage (void); +@@ -61,8 +61,8 @@ int have_warn = 0; + int have_crit = 0; + int warn_percent = 0; + int crit_percent = 0; +-float warn_size_bytes = 0; +-float crit_size_bytes= 0; ++double warn_size_bytes = 0; ++double crit_size_bytes= 0; + int verbose; + int allswaps; + +@@ -70,8 +70,8 @@ int + main (int argc, char **argv) + { + int percent_used, percent; +- float total_swap_mb = 0, used_swap_mb = 0, free_swap_mb = 0; +- float dsktotal_mb = 0, dskused_mb = 0, dskfree_mb = 0, tmp_mb = 0; ++ double total_swap_mb = 0, used_swap_mb = 0, free_swap_mb = 0; ++ double dsktotal_mb = 0, dskused_mb = 0, dskfree_mb = 0, tmp_mb = 0; + int result = STATE_UNKNOWN; + char input_buffer[MAX_INPUT_BUFFER]; + #ifdef HAVE_PROC_MEMINFO +@@ -117,7 +117,7 @@ main (int argc, char **argv) + } + fp = fopen (PROC_MEMINFO, "r"); + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { +- if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %f %f %f", &dsktotal_mb, &dskused_mb, &dskfree_mb) == 3) { ++ if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %lf %lf %lf", &dsktotal_mb, &dskused_mb, &dskfree_mb) == 3) { + dsktotal_mb = dsktotal_mb / 1048576; /* Apply conversion */ + dskused_mb = dskused_mb / 1048576; + dskfree_mb = dskfree_mb / 1048576; +@@ -134,9 +134,9 @@ main (int argc, char **argv) + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + } + } +- else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) { ++ else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %lf %*[k]%*[B]", str, &tmp_mb)) { + if (verbose >= 3) { +- printf("Got %s with %f\n", str, tmp_mb); ++ printf("Got %s with %lf\n", str, tmp_mb); + } + /* I think this part is always in Kb, so convert to mb */ + if (strcmp ("Total", str) == 0) { +@@ -162,7 +162,7 @@ main (int argc, char **argv) + # ifdef _AIX + if (!allswaps) { + xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); +- xasprintf(&swap_format, "%s", "%f%*s %f"); ++ xasprintf(&swap_format, "%s", "%lf%*s %lf"); + conv_factor = 1; + } + # endif +@@ -189,9 +189,9 @@ main (int argc, char **argv) + temp_buffer = strtok (input_buffer, " \n"); + while (temp_buffer) { + if (strstr (temp_buffer, "blocks")) +- sprintf (str, "%s %s", str, "%f"); ++ sprintf (str, "%s %s", str, "%lf"); + else if (strstr (temp_buffer, "dskfree")) +- sprintf (str, "%s %s", str, "%f"); ++ sprintf (str, "%s %s", str, "%lf"); + else + sprintf (str, "%s %s", str, "%*s"); + temp_buffer = strtok (NULL, " \n"); +@@ -281,8 +281,8 @@ main (int argc, char **argv) + } + + for(i=0;iswt_ent[i].ste_pages / SWAP_CONVERSION; +- dskfree_mb = (float) tbl->swt_ent[i].ste_free / SWAP_CONVERSION; ++ dsktotal_mb = (double) tbl->swt_ent[i].ste_pages / SWAP_CONVERSION; ++ dskfree_mb = (double) tbl->swt_ent[i].ste_free / SWAP_CONVERSION; + dskused_mb = ( dsktotal_mb - dskfree_mb ); + + if (verbose >= 3) +@@ -323,8 +323,8 @@ main (int argc, char **argv) + } + + for(i=0;i 0){ +@@ -376,10 +376,10 @@ main (int argc, char **argv) + + + int +-check_swap (int usp, float free_swap_mb) ++check_swap (int usp, double free_swap_mb) + { + int result = STATE_UNKNOWN; +- float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */ ++ double free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */ + if (usp >= 0 && crit_percent != 0 && usp >= (100.0 - crit_percent)) + result = STATE_CRITICAL; + else if (crit_size_bytes > 0 && free_swap <= crit_size_bytes) +@@ -424,13 +424,13 @@ process_arguments (int argc, char **argv + switch (c) { + case 'w': /* warning size threshold */ + if (is_intnonneg (optarg)) { +- warn_size_bytes = (float) atoi (optarg); ++ warn_size_bytes = (double) atoi (optarg); + have_warn = TRUE; + break; + } + else if (strstr (optarg, ",") && + strstr (optarg, "%") && +- sscanf (optarg, "%f,%d%%", &warn_size_bytes, &warn_percent) == 2) { ++ sscanf (optarg, "%lf,%d%%", &warn_size_bytes, &warn_percent) == 2) { + warn_size_bytes = floorf(warn_size_bytes); + have_warn = TRUE; + break; +@@ -445,13 +445,13 @@ process_arguments (int argc, char **argv + } + case 'c': /* critical size threshold */ + if (is_intnonneg (optarg)) { +- crit_size_bytes = (float) atoi (optarg); ++ crit_size_bytes = (double) atoi (optarg); + have_crit = TRUE; + break; + } + else if (strstr (optarg, ",") && + strstr (optarg, "%") && +- sscanf (optarg, "%f,%d%%", &crit_size_bytes, &crit_percent) == 2) { ++ sscanf (optarg, "%lf,%d%%", &crit_size_bytes, &crit_percent) == 2) { + crit_size_bytes = floorf(crit_size_bytes); + have_crit = TRUE; + break; +@@ -495,12 +495,12 @@ process_arguments (int argc, char **argv + if (c == argc) + return validate_arguments (); + if (warn_size_bytes == 0 && is_intnonneg (argv[c])) +- warn_size_bytes = (float) atoi (argv[c++]); ++ warn_size_bytes = (double) atoi (argv[c++]); + + if (c == argc) + return validate_arguments (); + if (crit_size_bytes == 0 && is_intnonneg (argv[c])) +- crit_size_bytes = (float) atoi (argv[c++]); ++ crit_size_bytes = (double) atoi (argv[c++]); + + return validate_arguments (); + } +diff -up ./plugins/check_users.c.git-20170227-39c5e4ed595c ./plugins/check_users.c +--- ./plugins/check_users.c.git-20170227-39c5e4ed595c 2017-03-12 16:51:45.631365181 -0400 ++++ ./plugins/check_users.c 2017-03-12 16:52:01.045123228 -0400 +@@ -222,10 +222,10 @@ process_arguments (int argc, char **argv + /* this will abort in case of invalid ranges */ + set_thresholds (&thlds, warning_range, critical_range); + +- if (thlds->warning->end <= 0) +- usage4 (_("Warning threshold must be a positive integer")); +- if (thlds->critical->end <= 0) +- usage4 (_("Critical threshold must be a positive integer")); ++ if (thlds->warning->end < 0) ++ usage4 (_("Warning threshold must be zero or greater")); ++ if (thlds->critical->end < 0) ++ usage4 (_("Critical threshold must be zero or greater")); + + return OK; + } diff --git a/nagios-plugins-0011-various_bugzilla_fixes.patch b/nagios-plugins-0011-various_bugzilla_fixes.patch index e69de29..1387efa 100644 --- a/nagios-plugins-0011-various_bugzilla_fixes.patch +++ b/nagios-plugins-0011-various_bugzilla_fixes.patch @@ -0,0 +1,195 @@ +diff -up ./plugins/check_dns.c.fixes_for_release_201702 ./plugins/check_dns.c +--- ./plugins/check_dns.c.fixes_for_release_201702 2017-01-19 11:01:31.000000000 -0500 ++++ ./plugins/check_dns.c 2017-03-12 17:57:36.266206371 -0400 +@@ -28,9 +28,9 @@ + * + * + *****************************************************************************/ +-#define IF_RECORD(label, querytype, verb_str) if (strstr (chld_out.line[i], label) && (strncmp(query_type, querytype, query_size) == 0 || strncmp(query_type, "-querytype=ANY", query_size) == 0)) { \ ++#define IF_RECORD(label, querytype, verb_str, comp_str) if (strstr (chld_out.line[i], label) && (strncmp(query_type, querytype, query_size) == 0 || strncmp(query_type, "-querytype=ANY", query_size) == 0)) { \ + if (verbose) printf(verb_str); \ +- temp_buffer = rindex (chld_out.line[i], ' '); \ ++ temp_buffer = rindex (chld_out.line[i], comp_str); \ + addresses[n_addresses++] = check_new_address(temp_buffer); \ + memset(query_found, '\0', sizeof(query_found)); \ + strncpy(query_found, querytype, sizeof(query_found)); +@@ -189,12 +189,12 @@ main (int argc, char **argv) + if (strstr (chld_out.line[i], "Name:")) + parse_address = TRUE; + /* begin handling types of records */ +- IF_RECORD("AAAA address", "-querytype=AAAA", "Found AAAA record\n") } +- else IF_RECORD("exchanger =", "-querytype=MX", "Found MX record\n") } +- else IF_RECORD("service =", "-querytype=SRV", "Found SRV record\n") } +- else IF_RECORD("nameserver =", "-querytype=NS", "Found NS record\n") } +- else IF_RECORD("dname =", "-querytype=DNAME", "Found DNAME record\n") } +- else IF_RECORD("protocol =", "-querytype=WKS", "Found WKS record\n") } ++ IF_RECORD("AAAA address", "-querytype=AAAA", "Found AAAA record\n", ' ') } ++ else IF_RECORD("exchanger =", "-querytype=MX", "Found MX record\n", '=') } ++ else IF_RECORD("service =", "-querytype=SRV", "Found SRV record\n", ' ') } ++ else IF_RECORD("nameserver =", "-querytype=NS", "Found NS record\n", ' ') } ++ else IF_RECORD("dname =", "-querytype=DNAME", "Found DNAME record\n", ' ') } ++ else IF_RECORD("protocol =", "-querytype=WKS", "Found WKS record\n", ' ') } + else if (strstr (chld_out.line[i], "text =") && (strncmp(query_type, "-querytype=TXT", query_size) == 0 || strncmp(query_type, "-querytype=ANY", query_size) == 0)) { + if (verbose) printf("Found TXT record\n"); + temp_buffer = index(chld_out.line[i], '"'); +@@ -203,8 +203,9 @@ main (int argc, char **argv) + memset(query_found, '\0', sizeof(query_found)); + strncpy(query_found, "-querytype=TXT", sizeof(query_found)); + } ++ + /* only matching for origin records, if requested other fields could be included at a later date */ +- else IF_RECORD("origin =", "-querytype=SOA", "Found SOA record\n") } ++ else IF_RECORD("origin =", "-querytype=SOA", "Found SOA record\n", ' ') } + /* cnames cannot use macro as we must check for accepting them separately */ + else if (accept_cname && strstr (chld_out.line[i], "canonical name =") && (strncmp(query_type, "-querytype=CNAME", query_size) == 0 || strncmp(query_type, "-querytype=ANY", query_size) == 0)) { + if (verbose) printf("Found CNAME record\n"); +@@ -220,7 +221,7 @@ main (int argc, char **argv) + strncpy(query_found, "-querytype=A", sizeof(query_found)); + } + /* must be after other records with "name" as an identifier, as ptr does not spefify */ +- else IF_RECORD("name =", "-querytype=PTR", "Found PTR record\n") } ++ else IF_RECORD("name =", "-querytype=PTR", "Found PTR record\n", ' ') } + /* needed for non-query ptr\reverse lookup checks */ + else if (strstr(chld_out.line[i], ".in-addr.arpa") && !query_set) { + if ((temp_buffer = strstr(chld_out.line[i], "name = "))) +diff -up ./plugins/check_http.c.fixes_for_release_201702 ./plugins/check_http.c +--- ./plugins/check_http.c.fixes_for_release_201702 2017-03-12 17:57:36.262206434 -0400 ++++ ./plugins/check_http.c 2017-03-12 18:10:54.827662579 -0400 +@@ -750,7 +750,8 @@ header_value (const char *headers, const + + value_end = strchr(s, '\r'); + if (!value_end) { +- die (STATE_UNKNOWN, _("HTTP_UNKNOWN - Failed to parse response headers\n")); ++ // die (STATE_UNKNOWN, _("HTTP_UNKNOWN - Failed to parse response headers\n")); ++ value_end = s + strlen(s); + } + + value_size = value_end - s; +@@ -1241,52 +1242,52 @@ check_http (void) + _("Status line output matched \"%s\" - "), server_expect); + if (verbose) + printf ("%s\n",msg); +- } else ++ } else { + xasprintf (&msg, ""); +- } + + /* Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF */ + /* HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT */ + /* Status-Code = 3 DIGITS */ + +- status_code = strchr (status_line, ' ') + sizeof (char); +- if (strspn (status_code, "1234567890") != 3) +- die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status Line (%s)\n"), status_line); +- +- http_status = atoi (status_code); +- +- /* check the return code */ +- +- if (http_status >= 600 || http_status < 100) { +- die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status (%s)\n"), status_line); +- } +- /* server errors result in a critical state */ +- else if (http_status >= 500) { +- xasprintf (&msg, _("%s%s - "), msg, status_line); +- if (bad_response || !server_expect_yn) +- result = STATE_CRITICAL; +- } +- /* client errors result in a warning state */ +- else if (http_status >= 400) { +- xasprintf (&msg, _("%s%s - "), msg, status_line); +- if (bad_response || !server_expect_yn) +- result = max_state_alt(STATE_WARNING, result); +- } +- /* check redirected page if specified */ +- else if (http_status >= 300) { ++ status_code = strchr (status_line, ' ') + sizeof (char); ++ if (strspn (status_code, "1234567890") != 3) ++ die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status Line (%s)\n"), status_line); + +- if (onredirect == STATE_DEPENDENT) +- redir (header, status_line); +- else +- result = max_state_alt(onredirect, result); +- xasprintf (&msg, _("%s%s - "), msg, status_line); +- } /* end if (http_status >= 300) */ +- else if (!bad_response) { +- /* Print OK status anyway */ +- xasprintf (&msg, _("%s%s - "), msg, status_line); +- } ++ http_status = atoi (status_code); ++ ++ /* check the return code */ + +- free(status_line); ++ if (http_status >= 600 || http_status < 100) { ++ die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status (%s)\n"), status_line); ++ } ++ /* server errors result in a critical state */ ++ else if (http_status >= 500) { ++ xasprintf (&msg, _("%s%s - "), msg, status_line); ++ if (bad_response || !server_expect_yn) ++ result = STATE_CRITICAL; ++ } ++ /* client errors result in a warning state */ ++ else if (http_status >= 400) { ++ xasprintf (&msg, _("%s%s - "), msg, status_line); ++ if (bad_response || !server_expect_yn) ++ result = max_state_alt(STATE_WARNING, result); ++ } ++ /* check redirected page if specified */ ++ else if (http_status >= 300) { ++ ++ if (onredirect == STATE_DEPENDENT) ++ redir (header, status_line); ++ else ++ result = max_state_alt(onredirect, result); ++ xasprintf (&msg, _("%s%s - "), msg, status_line); ++ } /* end if (http_status >= 300) */ ++ else if (!bad_response) { ++ /* Print OK status anyway */ ++ xasprintf (&msg, _("%s%s - "), msg, status_line); ++ } ++ } ++ } ++ free(status_line); + + if (bad_response) + die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); +diff -up ./plugins/check_snmp.c.fixes_for_release_201702 ./plugins/check_snmp.c +--- ./plugins/check_snmp.c.fixes_for_release_201702 2017-03-12 17:57:36.262206434 -0400 ++++ ./plugins/check_snmp.c 2017-03-12 17:57:36.266206371 -0400 +@@ -328,12 +328,12 @@ main (int argc, char **argv) + command_line[10 + numcontext + i] = authpriv[i]; + } + +- xasprintf (&command_line[10 + numcontext + numauthpriv], "%s:%s", server_address, port); ++ xasprintf (&command_line[10 + numcontext + numauthpriv], "%s%s:%s", ip_version, server_address, port); + + /* This is just for display purposes, so it can remain a string */ +- xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s:%s", ++ xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s%s:%s", + snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[context]", "[authpriv]", +- server_address, port); ++ ip_version, server_address, port); + + for (i = 0; i < numoids; i++) { + command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i]; +@@ -705,8 +705,8 @@ process_arguments (int argc, char **argv + {"offset", required_argument, 0, L_OFFSET}, + {"invert-search", no_argument, 0, L_INVERT_SEARCH}, + {"perf-oids", no_argument, 0, 'O'}, +- {"ipv4", no_argument, 0, '4'}, +- {"ipv6", no_argument, 0, '6'}, ++ {"use-ipv4", no_argument, 0, '4'}, ++ {"use-ipv6", no_argument, 0, '6'}, + {0, 0, 0, 0} + }; + +@@ -1276,5 +1276,5 @@ print_usage (void) + printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); + printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); + printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); +- printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); ++ printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n"); + } diff --git a/nagios-plugins.spec b/nagios-plugins.spec index 7a22ef5..c05508e 100644 --- a/nagios-plugins.spec +++ b/nagios-plugins.spec @@ -2,7 +2,7 @@ Name: nagios-plugins Version: 2.2.0 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Host/service/network monitoring program plugins for Nagios Group: Applications/System @@ -10,13 +10,9 @@ License: GPLv2+ URL: https://www.nagios-plugins.org/ Source0: https://www.nagios-plugins.org/download/%{name}-%{version}.tar.gz Source1: nagios-plugins.README.Fedora +Patch1: nagios-plugins-0001-Updates-to-git-20170227.patch Patch2: nagios-plugins-0002-Remove-assignment-of-not-parsed-to-jitter.patch -# https://bugzilla.redhat.com/512559 -#Patch5: nagios-plugins-0005-Prevent-check_swap-from-returning-OK-if-no-swap-acti.patch Patch7: nagios-plugins-0007-Fix-the-use-lib-statement-and-the-external-ntp-comma.patch -# Patch 8 no longer needed -# Patch 9 no longer needed -# Patch 10 no longer needed Patch11: nagios-plugins-0011-various_bugzilla_fixes.patch @@ -561,6 +557,7 @@ Provides check_wave support for Nagios. %prep %setup -q +%patch1 -p1 -b .git-20170227-39c5e4ed595c %patch2 -p1 -b .not_parsed %patch7 -p1 -b .ext_ntp_cmds @@ -807,6 +804,10 @@ chmod 644 %{buildroot}/%{_libdir}/nagios/plugins/utils.pm %{_libdir}/nagios/plugins/check_wave %changelog +* Sun Mar 12 2017 Stephen Smoogen - 2.2.0-7 +- Fix the patch order to get the code working again. +- get final fix from patrick for check_http header problem + * Fri Mar 10 2017 Stephen Smoogen - 2.2.0-6 - Consolidate the patches from patrick and git