/[mon-modules]/lwp-http.mon
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lwp-http.mon

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Mon Sep 2 13:59:54 2002 UTC revision 1.2 by dpavlin, Mon Sep 2 14:20:14 2002 UTC
# Line 6  Line 6 
6  # Lots of options.  # Lots of options.
7  #  #
8  # $Id$  # $Id$
9    #
10    # 2002-09-02 Dobrica Pavlinusic <dpavlin@rot13.org>
11    # added option -o which will return success if ANY of server responded with
12    # success (so that you can ignore alerts if backup servers are working)
13    
14  use strict;  use strict;
15    
# Line 19  use URI; Line 23  use URI;
23  ###  ###
24    
25  use vars qw($opt_h $opt_p $opt_t $opt_z $opt_d $opt_r $opt_s $opt_P  use vars qw($opt_h $opt_p $opt_t $opt_z $opt_d $opt_r $opt_s $opt_P
26              $opt_v $opt_c);          $opt_v $opt_c $opt_o);
27    
28  ##  ##
29    
# Line 60  sub main { Line 64  sub main {
64      $user_agent->timeout($timeout);      $user_agent->timeout($timeout);
65    
66      my @failed;      my @failed;
67        my @available;
68      my %failure;      my %failure;
69    host:    host:
70      foreach my $host (@_) {      foreach my $host (@_) {
# Line 108  sub main { Line 113  sub main {
113                  &{$ht_lose}("Regex not found");                  &{$ht_lose}("Regex not found");
114              }              }
115          }          }
116            push(@available, $host);
117      }      }
118      if(@failed) {      if(@failed) {
119          print "$u_proto Failures: " . join(" ", @failed) . "\n";          print "$u_proto Failures: " . join(" ", @failed) . "\n";
120          foreach my $fail (@failed) {          foreach my $fail (@failed) {
121              print "$fail: $failure{$fail}\n";              print "$fail: $failure{$fail}\n";
122          }          }
123          exit(1);          if ($opt_o && ($#available+1) > 0) {
124                    print "$u_proto Available: ".join(" ", @available)."\n";
125            } else {
126                    exit(1);
127            }
128      }      }
129      exit;      exit;
130  }  }
# Line 140  sub do_usage { Line 150  sub do_usage {
150  -v              Invert the regular expression.  Content must NOT match.  -v              Invert the regular expression.  Content must NOT match.
151  -z              Supress zero-length check.  -z              Supress zero-length check.
152  -c              Enable Cookies.  -c              Enable Cookies.
153    -o              Return success if at least One server is available.
154  EOF  EOF
155      }      }
156      exit 1;      exit 1;
# Line 147  EOF Line 158  EOF
158    
159  ###  ###
160    
161  getopts("hszvcp:t:d:r:P:") || do_usage();  getopts("hszvcp:t:d:r:P:o") || do_usage();
162  do_usage($opt_h) if($opt_h);  do_usage($opt_h) if($opt_h);
163    
164  &main(@ARGV);  &main(@ARGV);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26