diff options
| author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-09-11 11:50:45 +0000 | 
|---|---|---|
| committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-09-11 11:50:45 +0000 | 
| commit | deff5f48633cd5f296768b5a9593b8cac9f197a3 (patch) | |
| tree | e90cc4a5a832fab634d9fa824eed8205aac6239c /plugins | |
| parent | 9f032b16eefcee5534fbb5cb5b4c30bba4ba3be2 (diff) | |
| download | monitoring-plugins-deff5f48633cd5f296768b5a9593b8cac9f197a3.tar.gz | |
use prefdata function for size too
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@718 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_http.c | 47 | 
1 files changed, 29 insertions, 18 deletions
| diff --git a/plugins/check_http.c b/plugins/check_http.c index c68b2087..db949329 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
| @@ -120,6 +120,7 @@ void redir (char *pos, char *status_line); | |||
| 120 | int server_type_check(const char *type); | 120 | int server_type_check(const char *type); | 
| 121 | int server_port_check(int ssl_flag); | 121 | int server_port_check(int ssl_flag); | 
| 122 | char *perfd_time (long microsec); | 122 | char *perfd_time (long microsec); | 
| 123 | char *perfd_size (int page_len); | ||
| 123 | int my_recv (void); | 124 | int my_recv (void); | 
| 124 | int my_close (void); | 125 | int my_close (void); | 
| 125 | void print_help (void); | 126 | void print_help (void); | 
| @@ -672,10 +673,10 @@ check_http (void) | |||
| 672 | microsec = deltime (tv); | 673 | microsec = deltime (tv); | 
| 673 | elapsed_time = (double)microsec / 1.0e6; | 674 | elapsed_time = (double)microsec / 1.0e6; | 
| 674 | die (onredirect, | 675 | die (onredirect, | 
| 675 | _(" - %s - %.3f second response time %s%s|%s size=%dB\n"), | 676 | _(" - %s - %.3f second response time %s%s|%s %s\n"), | 
| 676 | status_line, elapsed_time, timestamp, | 677 | status_line, elapsed_time, timestamp, | 
| 677 | (display_html ? "</A>" : ""), | 678 | (display_html ? "</A>" : ""), | 
| 678 | perfd_time (microsec), pagesize); | 679 | perfd_time (microsec), perfd_size (pagesize)); | 
| 679 | } /* end if (strstr (status_line, "30[0-4]") */ | 680 | } /* end if (strstr (status_line, "30[0-4]") */ | 
| 680 | 681 | ||
| 681 | 682 | ||
| @@ -686,10 +687,10 @@ check_http (void) | |||
| 686 | microsec = deltime (tv); | 687 | microsec = deltime (tv); | 
| 687 | elapsed_time = (double)microsec / 1.0e6; | 688 | elapsed_time = (double)microsec / 1.0e6; | 
| 688 | asprintf (&msg, | 689 | asprintf (&msg, | 
| 689 | _("HTTP problem: %s - %.3f second response time %s%s|%s size=%dB\n"), | 690 | _("HTTP problem: %s - %.3f second response time %s%s|%s %s\n"), | 
| 690 | status_line, elapsed_time, timestamp, | 691 | status_line, elapsed_time, timestamp, | 
| 691 | (display_html ? "</A>" : ""), | 692 | (display_html ? "</A>" : ""), | 
| 692 | perfd_time (microsec), pagesize); | 693 | perfd_time (microsec), perfd_size (pagesize)); | 
| 693 | if (check_critical_time == TRUE && elapsed_time > critical_time) | 694 | if (check_critical_time == TRUE && elapsed_time > critical_time) | 
| 694 | die (STATE_CRITICAL, "%s", msg); | 695 | die (STATE_CRITICAL, "%s", msg); | 
| 695 | if (check_warning_time == TRUE && elapsed_time > warning_time) | 696 | if (check_warning_time == TRUE && elapsed_time > warning_time) | 
| @@ -700,16 +701,16 @@ check_http (void) | |||
| 700 | 701 | ||
| 701 | if (strlen (string_expect)) { | 702 | if (strlen (string_expect)) { | 
| 702 | if (strstr (page, string_expect)) { | 703 | if (strstr (page, string_expect)) { | 
| 703 | printf (_("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"), | 704 | printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"), | 
| 704 | status_line, elapsed_time, | 705 | status_line, elapsed_time, | 
| 705 | timestamp, (display_html ? "</A>" : ""), | 706 | timestamp, (display_html ? "</A>" : ""), | 
| 706 | perfd_time (microsec), pagesize); | 707 | perfd_time (microsec), perfd_size (pagesize)); | 
| 707 | exit (STATE_OK); | 708 | exit (STATE_OK); | 
| 708 | } | 709 | } | 
| 709 | else { | 710 | else { | 
| 710 | printf (_("CRITICAL - string not found%s|%s size=%dB\n"), | 711 | printf (_("CRITICAL - string not found%s|%s %s\n"), | 
| 711 | (display_html ? "</A>" : ""), | 712 | (display_html ? "</A>" : ""), | 
| 712 | perfd_time (microsec), pagesize); | 713 | perfd_time (microsec), perfd_size (pagesize)); | 
| 713 | exit (STATE_CRITICAL); | 714 | exit (STATE_CRITICAL); | 
| 714 | } | 715 | } | 
| 715 | } | 716 | } | 
| @@ -717,17 +718,17 @@ check_http (void) | |||
| 717 | if (strlen (regexp)) { | 718 | if (strlen (regexp)) { | 
| 718 | errcode = regexec (&preg, page, REGS, pmatch, 0); | 719 | errcode = regexec (&preg, page, REGS, pmatch, 0); | 
| 719 | if (errcode == 0) { | 720 | if (errcode == 0) { | 
| 720 | printf (_("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"), | 721 | printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"), | 
| 721 | status_line, elapsed_time, | 722 | status_line, elapsed_time, | 
| 722 | timestamp, (display_html ? "</A>" : ""), | 723 | timestamp, (display_html ? "</A>" : ""), | 
| 723 | perfd_time (microsec), pagesize); | 724 | perfd_time (microsec), perfd_size (pagesize)); | 
| 724 | exit (STATE_OK); | 725 | exit (STATE_OK); | 
| 725 | } | 726 | } | 
| 726 | else { | 727 | else { | 
| 727 | if (errcode == REG_NOMATCH) { | 728 | if (errcode == REG_NOMATCH) { | 
| 728 | printf (_("CRITICAL - pattern not found%s|%s size=%dB\n"), | 729 | printf (_("CRITICAL - pattern not found%s|%s %s\n"), | 
| 729 | (display_html ? "</A>" : ""), | 730 | (display_html ? "</A>" : ""), | 
| 730 | perfd_time (microsec), pagesize); | 731 | perfd_time (microsec), perfd_size (pagesize)); | 
| 731 | exit (STATE_CRITICAL); | 732 | exit (STATE_CRITICAL); | 
| 732 | } | 733 | } | 
| 733 | else { | 734 | else { | 
| @@ -742,15 +743,15 @@ check_http (void) | |||
| 742 | /* make sure the page is of an appropriate size */ | 743 | /* make sure the page is of an appropriate size */ | 
| 743 | page_len = strlen (page); | 744 | page_len = strlen (page); | 
| 744 | if ((min_page_len > 0) && (page_len < min_page_len)) { | 745 | if ((min_page_len > 0) && (page_len < min_page_len)) { | 
| 745 | printf (_("HTTP WARNING: page size too small%s|size=%i\n"), | 746 | printf (_("HTTP WARNING: page size %d too small%s|%s\n"), | 
| 746 | (display_html ? "</A>" : ""), page_len ); | 747 | page_len, (display_html ? "</A>" : ""), perfd_size (page_len) ); | 
| 747 | exit (STATE_WARNING); | 748 | exit (STATE_WARNING); | 
| 748 | } | 749 | } | 
| 749 | /* We only get here if all tests have been passed */ | 750 | /* We only get here if all tests have been passed */ | 
| 750 | asprintf (&msg, _("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"), | 751 | asprintf (&msg, _("HTTP OK %s - %d bytes in %.3f seconds %s%s|%s %s\n"), | 
| 751 | status_line, elapsed_time, | 752 | status_line, page_len, elapsed_time, | 
| 752 | timestamp, (display_html ? "</A>" : ""), | 753 | timestamp, (display_html ? "</A>" : ""), | 
| 753 | perfd_time (microsec), pagesize); | 754 | perfd_time (microsec), perfd_size (page_len)); | 
| 754 | die (STATE_OK, "%s", msg); | 755 | die (STATE_OK, "%s", msg); | 
| 755 | return STATE_UNKNOWN; | 756 | return STATE_UNKNOWN; | 
| 756 | } | 757 | } | 
| @@ -1039,12 +1040,22 @@ check_certificate (X509 ** certificate) | |||
| 1039 | 1040 | ||
| 1040 | char *perfd_time (long microsec) | 1041 | char *perfd_time (long microsec) | 
| 1041 | { | 1042 | { | 
| 1042 | perfdata ("time", microsec, "us", | 1043 | return perfdata ("time", microsec, "us", | 
| 1043 | check_warning_time, (int)(1e6*warning_time), | 1044 | check_warning_time, (int)(1e6*warning_time), | 
| 1044 | check_critical_time, (int)(1e6*critical_time), | 1045 | check_critical_time, (int)(1e6*critical_time), | 
| 1045 | TRUE, 0, FALSE, 0); | 1046 | TRUE, 0, FALSE, 0); | 
| 1046 | } | 1047 | } | 
| 1047 | 1048 | ||
| 1049 | |||
| 1050 | char *perfd_size (int page_len) | ||
| 1051 | { | ||
| 1052 | return perfdata ("size", page_len, "B", | ||
| 1053 | (min_page_len>0?TRUE:FALSE), min_page_len, | ||
| 1054 | (min_page_len>0?TRUE:FALSE), 0, | ||
| 1055 | TRUE, 0, FALSE, 0); | ||
| 1056 | } | ||
| 1057 | |||
| 1058 | |||
| 1048 | int | 1059 | int | 
| 1049 | my_recv (void) | 1060 | my_recv (void) | 
| 1050 | { | 1061 | { | 
