Subversion Repositories sysadmin_scripts

Rev

Rev 93 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 93 Rev 94
Line 21... Line 21...
21
 
21
 
22
use Data::Dumper;
22
use Data::Dumper;
23
use FindBin;
23
use FindBin;
24
use File::Spec;
24
use File::Spec;
25
 
25
 
26
my $TESTING = 0;
-
 
27
 
-
 
28
# name of script directory, no trailing slash
26
# name of script directory, no trailing slash
29
my $MY_DIR = $FindBin::Bin;
27
my $MY_DIR = $FindBin::Bin;
30
# name of currently executing file
28
# name of currently executing file
31
my $MY_NAME = $FindBin::Script;
29
my $MY_NAME = $FindBin::Script;
32
 
30
 
Line 60... Line 58...
60
   unless ( $netcat ) {
58
   unless ( $netcat ) {
61
      warn "Netcat not found, not testing\n";
59
      warn "Netcat not found, not testing\n";
62
      return 0;
60
      return 0;
63
   }
61
   }
64
   $netcat = join( ' ', ($netcat, "-z -w $timeout", $additionalParameters, $url, $port ) );
62
   $netcat = join( ' ', ($netcat, "-z -w $timeout", $additionalParameters, $url, $port ) );
65
   print "\t$netcat\n" if $TESTING;
63
   print "\t$netcat\n" if $config->{'TESTING'};
66
   `$netcat`;
64
   `$netcat`;
67
   return not $? >> 8;
65
   return not $? >> 8;
68
} 
66
} 
69
 
67
 
70
# this has only been tested on http and https, but with a little work
68
# this has only been tested on http and https, but with a little work
Line 170... Line 168...
170
sub processFailure {
168
sub processFailure {
171
   my ( $name, $parameters ) = @_;
169
   my ( $name, $parameters ) = @_;
172
   # temporary for testing
170
   # temporary for testing
173
   my $flagFileName = &flagFileName( $name );
171
   my $flagFileName = &flagFileName( $name );
174
   my $remainingCounts = $parameters->{'failure count'};
172
   my $remainingCounts = $parameters->{'failure count'};
175
   print "$name => Failed\n" if $TESTING;
173
   print "$name => Failed\n" if $config->{'TESTING'};
176
   if ( -f $flagFileName ) {
174
   if ( -f $flagFileName ) {
177
      # open flag file, read the value into $remaingCounts
175
      # open flag file, read the value into $remaingCounts
178
      return if $remainingCounts == -1;
176
      return if $remainingCounts == -1;
179
   }
177
   }
180
   if ( $remainingCounts-- == 0 ) {
178
   if ( $remainingCounts-- == 0 ) {
Line 184... Line 182...
184
}
182
}
185
 
183
 
186
# we are up, so check for any flag file and unlink if found
184
# we are up, so check for any flag file and unlink if found
187
sub cleanUp {
185
sub cleanUp {
188
   my $name = shift;
186
   my $name = shift;
189
   print "$name => Success\n" if $TESTING;
187
   print "$name => Success\n" if $config->{'TESTING'};
190
   $name = &flagFileName( $name );
188
   $name = &flagFileName( $name );
191
   unlink $name if -f $name;
189
   unlink $name if -f $name;
192
}
190
}
193
 
191
 
194
#######################################################################
192
#######################################################################