Просмотр исходного кода

Merge branch 'master' into fix-mac-build

Sebastian Wolf 6 лет назад
Родитель
Сommit
a3dc1880ff
5 измененных файлов с 47 добавлено и 11 удалено
  1. 2 0
      NEWS
  2. BIN
      perlmods/Module-Build-0.4007.tar.gz
  3. 5 5
      plugins-root/check_icmp.c
  4. 39 5
      plugins/check_http.c
  5. 1 1
      plugins/check_procs.c

+ 2 - 0
NEWS

@@ -4,6 +4,8 @@ This file documents the major additions and syntax changes between releases.
 	FIXES
 	check_http: Fix host:port syntax when using -H (Isaac White)
 	build: Fix broken builds on some systems, including Homebrew (#508)
+	perl dependencies: updated the included Module::Build to work with newer versions of perl (#505)
+	check_icmp: All performance data tags should show when packet loss is 100% (#510)
 
 2.3.1 2019-12-09
 	FIXES

BIN
perlmods/Module-Build-0.4007.tar.gz


+ 5 - 5
plugins-root/check_icmp.c

@@ -1592,7 +1592,7 @@ static void finish(int sig) {
     if (debug) {
       puts("");
     }
-    if (rta_mode && host->pl < 100) {
+    if (rta_mode) {
       printf("%srta=%0.3fms;%0.3f;%0.3f;0; ",
              (targets > 1) ? host->name : "", (float)host->rta / 1000,
              (float)warn.rta / 1000, (float)crit.rta / 1000);
@@ -1601,12 +1601,12 @@ static void finish(int sig) {
       printf("%spl=%u%%;%u;%u;0;100 ", (targets > 1) ? host->name : "",
              host->pl, warn.pl, crit.pl);
     }
-    if (rta_mode && host->pl < 100) {
+    if (rta_mode) {
       printf("%srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ",
              (targets > 1) ? host->name : "", (float)host->rtmax / 1000,
              (targets > 1) ? host->name : "", (float)host->rtmin / 1000);
     }
-    if (jitter_mode && host->pl < 100) {
+    if (jitter_mode) {
       printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; "
              "%sjitter_min=%0.3fms;;;; ",
              (targets > 1) ? host->name : "", (float)host->jitter,
@@ -1614,11 +1614,11 @@ static void finish(int sig) {
              (targets > 1) ? host->name : "", (float)host->jitter_max / 1000,
              (targets > 1) ? host->name : "", (float)host->jitter_min / 1000);
     }
-    if (mos_mode && host->pl < 100) {
+    if (mos_mode) {
       printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ", (targets > 1) ? host->name : "",
              (float)host->mos, (float)warn.mos, (float)crit.mos);
     }
-    if (score_mode && host->pl < 100) {
+    if (score_mode) {
       printf("%sscore=%u;%u;%u;0;100 ", (targets > 1) ? host->name : "",
              (int)host->score, (int)warn.score, (int)crit.score);
     }

+ 39 - 5
plugins/check_http.c

@@ -608,9 +608,11 @@ enable_ssl:
 
 
 
-/* Returns 1 if we're done processing the document body; 0 to keep going */
+/* Returns 0 if we're still retrieving the headers.
+ * Otherwise, returns the length of the header (not including the final newlines)
+ */
 static int
-document_headers_done (char *full_page)
+document_headers_done (const char *full_page)
 {
     const char *body;
 
@@ -622,8 +624,7 @@ document_headers_done (char *full_page)
     if (!*body)
         return 0;  /* haven't read end of headers yet */
 
-    full_page[body - full_page] = 0;
-    return 1;
+    return body - full_page;
 }
 
 static time_t
@@ -1013,6 +1014,10 @@ check_http (void)
     char *page;
     char *auth;
     int http_status;
+    int header_end;
+    int content_length;
+    int content_start;
+    int seen_length;
     int i = 0;
     size_t pagesize = 0;
     char *full_page;
@@ -1195,11 +1200,40 @@ check_http (void)
         full_page = full_page_new;
         pagesize += i;
 
-        if (no_body && document_headers_done (full_page)) {
+        header_end = document_headers_done(full_page);
+        if (header_end) {
             i = 0;
             break;
         }
     }
+
+    if (no_body) {
+        full_page[header_end] = '\0';
+    }
+    else {
+        content_length = get_content_length(full_page);
+
+        content_start = header_end + 1;
+        while (full_page[content_start] == '\n' || full_page[content_start] == '\r') {
+            content_start += 1;
+        }
+        seen_length = pagesize - content_start;
+        /* Continue receiving the body until content-length is met */
+        while (seen_length < content_length
+            && (i = my_recv(buffer, MAX_INPUT_BUFFER-1) > 0)) {
+
+            buffer[i] = '\0';
+
+            if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL)
+                die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n"));
+            memmove(&full_page_new[pagesize], buffer, i);
+            full_page = full_page_new;
+
+            pagesize += i;
+            seen_length = pagesize - content_start;
+        }
+    }
+
     microsec_transfer = deltime (tv_temp);
     elapsed_time_transfer = (double)microsec_transfer / 1.0e6;
 

+ 1 - 1
plugins/check_procs.c

@@ -855,7 +855,7 @@ print_help (void)
   printf ("   %s\n", _("Only scan for processes with args that contain the regex STRING."));
   printf (" %s\n", "-C, --command=COMMAND");
   printf ("   %s\n", _("Only scan for exact matches of COMMAND (without path)."));
-  printf (" %s\n", "-C, --exclude-process");
+  printf (" %s\n", "-X, --exclude-process");
   printf ("   %s\n", _("Exclude processes which match this comma separated list"));
   printf (" %s\n", "-k, --no-kthreads");
   printf ("   %s\n", _("Only scan for non kernel threads (works on Linux only)."));