From 7fc4252c17e4c2b80281f64b51eb08f1ca9480df Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Wed, 27 Sep 2000 03:30:21 +0000 Subject: [PATCH] Perform _HOST_ -> $host substitution on $url for more informative display when there are failures. Make $summary more consistent (prepend "http " for errors and warnings to match "ok" and other plugins) --- src/lib/Spong/Network/plugins/check_http | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/lib/Spong/Network/plugins/check_http b/src/lib/Spong/Network/plugins/check_http index ec9c110..ba67bd4 100755 --- a/src/lib/Spong/Network/plugins/check_http +++ b/src/lib/Spong/Network/plugins/check_http @@ -23,7 +23,13 @@ sub check_http { my($hpart,$urlpath) = ( $url =~ m|^([^/]+)(/.*)| ); my($hname,$port) = split(/:/,$hpart); $port = 80 if ! $port; - $hname = $host if ( ! $hname || $hname eq '_HOST_' ); + #$hname = $host if ( ! $hname || $hname eq '_HOST_' ); + if ( ! $hname ) { + $hname = $host; + } elsif ( $hname eq '_HOST_' ) { + $hname = $host; + $url =~ s/_HOST_/$host/; + } my $message = &check_tcp( $hname, $port, @@ -33,14 +39,14 @@ sub check_http { my $code = $1; if( $code >= 500 ) { - $color = "red"; $summary = "error - $code - $url"; + $color = "red"; $summary = "http error - $code - $url"; # Treat a 401 (authorization Required) code as a green } elsif( $code >= 400 && $code != 401) { if( $color ne "red" ) { - $color = "yellow"; $summary = "warning - $code - $url"; } + $color = "yellow"; $summary = "http warning - $code - $url"; } } else { if( $color ne "red" && $color ne "yellow" ) { - $color = "green"; $summary = "ok - $code"; } + $color = "green"; $summary = "http ok - $code"; } } } elsif( $message !~ /HTTP/m ) { $color = "red"; $summary = "no response from http server"; @@ -61,14 +67,15 @@ sub check_http { my $code = $1; if( $code >= 500 ) { - $color = "red"; $summary = "error - $code - $file"; + $color = "red"; $summary = "http error - $code - $file"; # Treat a 401 (authorization Required) code as a green } elsif( $code >= 400 && $code != 401) { if( $color ne "red" ) { - $color = "yellow"; $summary = "warning - $code - $file"; } + $color = "yellow"; $summary = "http warning - $code - $file"; + } } else { if( $color ne "red" && $color ne "yellow" ) { - $color = "green"; $summary = "ok - $code"; } + $color = "green"; $summary = "http ok - $code"; } } } elsif( $message !~ /HTTP/m ) { $color = "red"; $summary = "no response from http server"; -- 2.30.2