--- lwp-http.mon 2002/09/02 13:59:54 1.1 +++ lwp-http.mon 2002/09/02 14:20:14 1.2 @@ -6,6 +6,10 @@ # Lots of options. # # $Id: lwp-http.mon,v 1.3 2000/03/20 05:55:48 hag Exp $ +# +# 2002-09-02 Dobrica Pavlinusic +# added option -o which will return success if ANY of server responded with +# success (so that you can ignore alerts if backup servers are working) use strict; @@ -19,7 +23,7 @@ ### use vars qw($opt_h $opt_p $opt_t $opt_z $opt_d $opt_r $opt_s $opt_P - $opt_v $opt_c); + $opt_v $opt_c $opt_o); ## @@ -60,6 +64,7 @@ $user_agent->timeout($timeout); my @failed; + my @available; my %failure; host: foreach my $host (@_) { @@ -108,13 +113,18 @@ &{$ht_lose}("Regex not found"); } } + push(@available, $host); } if(@failed) { print "$u_proto Failures: " . join(" ", @failed) . "\n"; foreach my $fail (@failed) { print "$fail: $failure{$fail}\n"; } - exit(1); + if ($opt_o && ($#available+1) > 0) { + print "$u_proto Available: ".join(" ", @available)."\n"; + } else { + exit(1); + } } exit; } @@ -140,6 +150,7 @@ -v Invert the regular expression. Content must NOT match. -z Supress zero-length check. -c Enable Cookies. +-o Return success if at least One server is available. EOF } exit 1; @@ -147,7 +158,7 @@ ### -getopts("hszvcp:t:d:r:P:") || do_usage(); +getopts("hszvcp:t:d:r:P:o") || do_usage(); do_usage($opt_h) if($opt_h); &main(@ARGV);