Thanks for the reccomendation. This is what I have so far, it is mostly cannibalized from a similar reporting scheme. The comparison tags in here are from the original script, I will not be searching for things like dkcHWProcessor in my script.
I just need to figure out how to get the line after something is found, IE the line directly after SA220 Fault report, and place it into the array entry. I also need to be able to check that field and compare to "The array is operating normally." in order to flag for the summary.
use strict;
use Time::Local;
use File::Basename;
use File::Spec;
use Cwd;
use Getopt::Long;
use constant TRUE => 1;
use constant FALSE => 0;
use MIME::Lite::TT::HTML;
use warnings;
my $OUTFILE_3 = "/EMC/faults.txt";
my $OUTFILE_5 = "EMCerrors.txt";
my $OUTFILE_6 = "EMCerrorlog.txt";
my $OUTFILE_7 = "EMCmailtxt.txt";
my $OUTFILE_8 = "/EMC/simrc.txt";
# Get the current time and date
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
my $second = undef;
my $minute = undef;
my $hour = undef;
my $dayOfMonth = undef;
my $month = undef;
my $yearOffset = undef;
my $dayOfWeek = undef;
my $dayOfYear = undef;
my $daylightSavings = undef;
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek
+, $dayOfYear, $daylightSavings) = localtime();
my $year = 1900 + $yearOffset;
my $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$m
+onth] $dayOfMonth, $year";
my @TEMP_ARRAY_1 = undef;
my @TEMP_ARRAY_2 = undef;
my @TEMP_ARRAY_3 = undef;
my $SRCHSTR = undef;
my $SRCHSTR1 = undef;
my $SRCHSTR2 = undef;
my $SRCHSTR3 = undef;
my $PRTSTR = undef;
my %PARAMS;
open(F_INFILE_3, "< $OUTFILE_3");
open(F_INFILE_8, "< $OUTFILE_8");
$PARAMS{MTIME} = $theTime;
foreach (<F_INFILE_3>) {
chomp $_;
$_ =~ s /^\s//g;
$_ =~ s /\./_/g;
if ( $_ =~ m/dkcHWProcessor/g ) {
@TEMP_ARRAY_1 = split("=",$_);
@TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]);
$PARAMS{SA120} = $TEMP_ARRAY_2[1];
if ( $PARAMS{SA120} =~ m/noError/g ) {
} else {
$PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA120;";
}
}
if ( $_ =~ m/dkcHWCSW/g ) {
@TEMP_ARRAY_1 = split("=",$_);
@TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]);
$PARAMS{SA121} = $TEMP_ARRAY_2[1];
if ( $PARAMS{SA121} =~ m/noError/g ) {
} else {
$PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA121;";
}
}
if ( $_ =~ m/dkcHWCache/g ) {
@TEMP_ARRAY_1 = split("=",$_);
@TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]);
$PARAMS{SA122} = $TEMP_ARRAY_2[1];
if ( $PARAMS{SA122} =~ m/noError/g ) {
} else {
$PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA122;";
}
}
if ( $_ =~ m/dkcHWSM/g ) {
@TEMP_ARRAY_1 = split("=",$_);
@TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]);
$PARAMS{SA210} = $TEMP_ARRAY_2[1];
if ( $PARAMS{SA210} =~ m/noError/g ) {
} else {
$PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA220;";
}
}
if ( $_ =~ m/dkcHWPS/g ) {
@TEMP_ARRAY_1 = split("=",$_);
@TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]);
$PARAMS{SA211} = $TEMP_ARRAY_2[1];
if ( $PARAMS{SA211} =~ m/noError/g ) {
} else {
$PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA221;";
}
}
if ( $_ =~ m/dkcHWBattery/g ) {
@TEMP_ARRAY_1 = split("=",$_);
@TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]);
$PARAMS{SA212} = $TEMP_ARRAY_2[1];
if ( $PARAMS{SA212} =~ m/noError/g ) {
} else {
$PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA222;";
}
}
}
close F_INFILE_3;
if ( $PARAMS{SUMMARY} eq "" ) {
$PARAMS{SUMMARY} = "NO ERRORS FOUND";
my $msg = MIME::Lite::TT::HTML->new(
From => 'santeam@bla.com',
To => 'pbkhk@bla.com',
Subject => 'EMC CX HEALTH REPORT:NO ERRORS FOUND',
Template => {
html => 'EMC.html.tt',
},
TmplParams => \%PARAMS,
);
$msg->send;
} else {
$PARAMS{SUMMARY} = "ERRORS FOUND:".$PARAMS{SUMMARY};
my $msg = MIME::Lite::TT::HTML->new(
From => 'santeam@bla.com',
To => 'pbkhk@bla.com',
Subject => 'EMC CX HEALTH REPORT:ERRORS FOUND',
Template => {
html => 'EMC.html.tt',
},
TmplParams => \%PARAMS,
);
$msg->send;
};
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.