/[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.3 by dpavlin, Fri Mar 7 16:08:34 2003 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 58  sub main { Line 62  sub main {
62      $user_agent->agent($agent);      $user_agent->agent($agent);
63      $user_agent->from($maintainer);      $user_agent->from($maintainer);
64      $user_agent->timeout($timeout);      $user_agent->timeout($timeout);
65        $user_agent->env_proxy();
66    
67      my @failed;      my @failed;
68        my @available;
69      my %failure;      my %failure;
70    host:    host:
71      foreach my $host (@_) {      foreach my $host (@_) {
# Line 108  sub main { Line 114  sub main {
114                  &{$ht_lose}("Regex not found");                  &{$ht_lose}("Regex not found");
115              }              }
116          }          }
117            push(@available, $host);
118      }      }
119      if(@failed) {      if(@failed) {
120          print "$u_proto Failures: " . join(" ", @failed) . "\n";          print "$u_proto Failures: " . join(" ", @failed) . "\n";
121          foreach my $fail (@failed) {          foreach my $fail (@failed) {
122              print "$fail: $failure{$fail}\n";              print "$fail: $failure{$fail}\n";
123          }          }
124          exit(1);          if ($opt_o && ($#available+1) > 0) {
125                    print "$u_proto Available: ".join(" ", @available)."\n";
126            } else {
127                    exit(1);
128            }
129      }      }
130      exit;      exit;
131  }  }
# Line 140  sub do_usage { Line 151  sub do_usage {
151  -v              Invert the regular expression.  Content must NOT match.  -v              Invert the regular expression.  Content must NOT match.
152  -z              Supress zero-length check.  -z              Supress zero-length check.
153  -c              Enable Cookies.  -c              Enable Cookies.
154    -o              Return success if at least One server is available.
155  EOF  EOF
156      }      }
157      exit 1;      exit 1;
# Line 147  EOF Line 159  EOF
159    
160  ###  ###
161    
162  getopts("hszvcp:t:d:r:P:") || do_usage();  getopts("hszvcp:t:d:r:P:o") || do_usage();
163  do_usage($opt_h) if($opt_h);  do_usage($opt_h) if($opt_h);
164    
165  &main(@ARGV);  &main(@ARGV);

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

  ViewVC Help
Powered by ViewVC 1.1.26