Subversion Repositories sysadmin_scripts

Rev

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

Rev 91 Rev 92
Line 120... Line 120...
120
}
120
}
121
 
121
 
122
# Report outage via system mail
122
# Report outage via system mail
123
# your system must be able to send e-mail from 'report from'
123
# your system must be able to send e-mail from 'report from'
124
# otherwise, you'll need to use something like sendemail.pl
124
# otherwise, you'll need to use something like sendemail.pl
-
 
125
# apt install libemail-sender-perl libemail-mime-perl
125
sub reportViaMail {
126
sub reportViaMail {
126
   my ( $name,$parameters ) = @_;
127
   my ( $name,$parameters ) = @_;
127
   use Email::MIME;
128
   use Email::MIME;
128
   my $message = Email::MIME->create(
129
   my $message = Email::MIME->create(
129
     header_str => [
130
     header_str => [
Line 158... Line 159...
158
# if the countdown is exceeded, it will report the status 
159
# if the countdown is exceeded, it will report the status 
159
sub processFailure {
160
sub processFailure {
160
   my ( $name, $parameters ) = @_;
161
   my ( $name, $parameters ) = @_;
161
   # temporary for testing
162
   # temporary for testing
162
   print "Failed test for $name\n";
163
   print "Failed test for $name\n";
163
   my $flagFileName = $flagFileName( $name );
164
   my $flagFileName = &flagFileName( $name );
164
   my $remainingCounts = $parameters->{'failure count'};
165
   my $remainingCounts = $parameters->{'failure count'};
165
   if ( -f $flagFileName ) {
166
   if ( -f $flagFileName ) {
166
      # open flag file, read the value into $remaingCounts
167
      # open flag file, read the value into $remaingCounts
167
      return if $remainingCounts == -1;
168
      return if $remainingCounts == -1;
168
   }
169
   }
169
   if ( $remainingCounts-- == 0 ) {
170
   if ( $remainingCounts-- == 0 ) {
170
      &ReportOutage( $name, $parameters );
171
      &reportOutage( $name, $parameters );
171
   }
172
   }
172
   # open flag file, write new $remainingCounts to it
173
   # open flag file, write new $remainingCounts to it
173
}
174
}
174
 
175
 
175
# we are up, so check for any flag file and unlink if found
176
# we are up, so check for any flag file and unlink if found