summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_http.c26
-rw-r--r--plugins/utils.c27
2 files changed, 29 insertions, 24 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index b676eec..54bbf00 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -120,7 +120,7 @@ int check_http (void);
120void redir (char *pos, char *status_line); 120void redir (char *pos, char *status_line);
121int server_type_check(const char *type); 121int server_type_check(const char *type);
122int server_port_check(int ssl_flag); 122int server_port_check(int ssl_flag);
123char *perfd_time (long microsec); 123char *perfd_time (double microsec);
124char *perfd_size (int page_len); 124char *perfd_size (int page_len);
125int my_recv (void); 125int my_recv (void);
126int my_close (void); 126int my_close (void);
@@ -685,7 +685,7 @@ check_http (void)
685 _(" - %s - %.3f second response time %s%s|%s %s\n"), 685 _(" - %s - %.3f second response time %s%s|%s %s\n"),
686 status_line, elapsed_time, timestamp, 686 status_line, elapsed_time, timestamp,
687 (display_html ? "</A>" : ""), 687 (display_html ? "</A>" : ""),
688 perfd_time (microsec), perfd_size (pagesize)); 688 perfd_time (elapsed_time), perfd_size (pagesize));
689 } /* end if (http_status >= 300) */ 689 } /* end if (http_status >= 300) */
690 690
691 } /* end else (server_expect_yn) */ 691 } /* end else (server_expect_yn) */
@@ -697,7 +697,7 @@ check_http (void)
697 _("HTTP problem: %s - %.3f second response time %s%s|%s %s\n"), 697 _("HTTP problem: %s - %.3f second response time %s%s|%s %s\n"),
698 status_line, elapsed_time, timestamp, 698 status_line, elapsed_time, timestamp,
699 (display_html ? "</A>" : ""), 699 (display_html ? "</A>" : ""),
700 perfd_time (microsec), perfd_size (pagesize)); 700 perfd_time (elapsed_time), perfd_size (pagesize));
701 if (check_critical_time == TRUE && elapsed_time > critical_time) 701 if (check_critical_time == TRUE && elapsed_time > critical_time)
702 die (STATE_CRITICAL, "%s", msg); 702 die (STATE_CRITICAL, "%s", msg);
703 if (check_warning_time == TRUE && elapsed_time > warning_time) 703 if (check_warning_time == TRUE && elapsed_time > warning_time)
@@ -711,13 +711,13 @@ check_http (void)
711 printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"), 711 printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"),
712 status_line, elapsed_time, 712 status_line, elapsed_time,
713 timestamp, (display_html ? "</A>" : ""), 713 timestamp, (display_html ? "</A>" : ""),
714 perfd_time (microsec), perfd_size (pagesize)); 714 perfd_time (elapsed_time), perfd_size (pagesize));
715 exit (STATE_OK); 715 exit (STATE_OK);
716 } 716 }
717 else { 717 else {
718 printf (_("CRITICAL - string not found%s|%s %s\n"), 718 printf (_("CRITICAL - string not found%s|%s %s\n"),
719 (display_html ? "</A>" : ""), 719 (display_html ? "</A>" : ""),
720 perfd_time (microsec), perfd_size (pagesize)); 720 perfd_time (elapsed_time), perfd_size (pagesize));
721 exit (STATE_CRITICAL); 721 exit (STATE_CRITICAL);
722 } 722 }
723 } 723 }
@@ -728,14 +728,14 @@ check_http (void)
728 printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"), 728 printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"),
729 status_line, elapsed_time, 729 status_line, elapsed_time,
730 timestamp, (display_html ? "</A>" : ""), 730 timestamp, (display_html ? "</A>" : ""),
731 perfd_time (microsec), perfd_size (pagesize)); 731 perfd_time (elapsed_time), perfd_size (pagesize));
732 exit (STATE_OK); 732 exit (STATE_OK);
733 } 733 }
734 else { 734 else {
735 if (errcode == REG_NOMATCH) { 735 if (errcode == REG_NOMATCH) {
736 printf (_("CRITICAL - pattern not found%s|%s %s\n"), 736 printf (_("CRITICAL - pattern not found%s|%s %s\n"),
737 (display_html ? "</A>" : ""), 737 (display_html ? "</A>" : ""),
738 perfd_time (microsec), perfd_size (pagesize)); 738 perfd_time (elapsed_time), perfd_size (pagesize));
739 exit (STATE_CRITICAL); 739 exit (STATE_CRITICAL);
740 } 740 }
741 else { 741 else {
@@ -758,7 +758,7 @@ check_http (void)
758 asprintf (&msg, _("HTTP OK %s - %d bytes in %.3f seconds %s%s|%s %s\n"), 758 asprintf (&msg, _("HTTP OK %s - %d bytes in %.3f seconds %s%s|%s %s\n"),
759 status_line, page_len, elapsed_time, 759 status_line, page_len, elapsed_time,
760 timestamp, (display_html ? "</A>" : ""), 760 timestamp, (display_html ? "</A>" : ""),
761 perfd_time (microsec), perfd_size (page_len)); 761 perfd_time (elapsed_time), perfd_size (page_len));
762 die (STATE_OK, "%s", msg); 762 die (STATE_OK, "%s", msg);
763 return STATE_UNKNOWN; 763 return STATE_UNKNOWN;
764} 764}
@@ -1045,12 +1045,12 @@ check_certificate (X509 ** certificate)
1045 1045
1046 1046
1047 1047
1048char *perfd_time (long microsec) 1048char *perfd_time (double elapsed_time)
1049{ 1049{
1050 return perfdata ("time", microsec, "us", 1050 return fperfdata ("time", elapsed_time, "s",
1051 check_warning_time, (int)(1e6*warning_time), 1051 check_warning_time, warning_time,
1052 check_critical_time, (int)(1e6*critical_time), 1052 check_critical_time, critical_time,
1053 TRUE, 0, FALSE, 0); 1053 TRUE, 0, FALSE, 0);
1054} 1054}
1055 1055
1056 1056
diff --git a/plugins/utils.c b/plugins/utils.c
index 77e2e27..bb38030 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -561,25 +561,30 @@ char *fperfdata (const char *label,
561 char *data = NULL; 561 char *data = NULL;
562 562
563 if (strpbrk (label, "'= ")) 563 if (strpbrk (label, "'= "))
564 asprintf (&data, "'%s'=%ld%s;", label, val, uom); 564 asprintf (&data, "'%s'=", label);
565 else 565 else
566 asprintf (&data, "%s=%ld%s;", label, val, uom); 566 asprintf (&data, "%s=", label);
567
568 asprintf (&data, "%s%f", data, val);
569 asprintf (&data, "%s%s;", data, uom);
567 570
568 if (warnp) 571 if (warnp)
569 asprintf (&data, "%s%ld;", data, warn); 572 asprintf (&data, "%s%f", data, warn);
570 else 573
571 asprintf (&data, "%s;", data); 574 asprintf (&data, "%s;", data);
572 575
573 if (critp) 576 if (critp)
574 asprintf (&data, "%s%ld;", data, crit); 577 asprintf (&data, "%s%f", data, crit);
575 else 578
576 asprintf (&data, "%s;", data); 579 asprintf (&data, "%s;", data);
577 580
578 if (minp) 581 if (minp)
579 asprintf (&data, "%s%ld", data, minv); 582 asprintf (&data, "%s%f", data, minv);
580 583
581 if (maxp) 584 if (maxp) {
582 asprintf (&data, "%s;%ld", data, maxv); 585 asprintf (&data, "%s;", data);
586 asprintf (&data, "%s%f", data, maxv);
587 }
583 588
584 return data; 589 return data;
585} 590}