#! /usr/local/bin/perl #$Id: //depot/prod/test/main/storage/hdd/NADQ_SEA/NDATE/SUPPORT_SCRIPTS/parser.thpl#8 #=================================================== # The Parser # # author:reeserr@netapp.com # version:1.1 #=================================================== use strict; use IO::Handle; use San; use HTML::Mail; use Storage::Common_Lib; use NACL::C::Node; use NATE::ParamSet; use TCD; #use Params::Check qw/check/; my $nateRun = "false"; my @Log_arr = (); my $Home = $ENV{HOME}; my $test_dir_name_g; my $test_suit_name; my $flag_system_logs = 0; eval { #Uncomment the 2 lines below if you are using the parser #with the SEA BEGIN { push( @INC, "./lib" ); } use Tharn; use vars qw( $FILER $FILERB $FILERA $TEST_CONFIG $FILER_CONN $MAINT_PRMPT $MAIL_TO $MAIL_FROM $RUNID $STEST_FILE $PARSE_ID $STEST_DEBUG $LOGDIR $LOGLVL $EMAIL ); my $params = NATE::ParamSet->new( global => 1 ); param( 'RUNID', '-default', '' ); param( 'FILER', '-mesg', 'HostID of filer' ); param( 'FILERA', '-default', '' ); param( 'FILERB', '-default', '' ); param( 'TEST_CONFIG', '-mesg', 'Test config' ); param( 'FILER_CONN', '-default', '#console' ); param( 'MAIL_TO', '-default', 'default' ); param( 'MAIL_FROM', '-default', 'default' ); param( "MAINT_PRMPT", '-default', '\*>' ); param( 'PARSE_ID', '-mesg', 'parse id' ); param( 'STEST_DEBUG', '-default', '1' ); param( 'STEST_FILE', '-mesg', 'Runlist file' ); param( 'LOGDIR', '-default', '' ); param( 'LOGLVL', '-default', '2' ); # push (@INC, split(/;/, $NATE_LIB)); $nateRun = "true"; }; my $EMAIL = param( 'EMAIL', '-default', 'n' ); logcomment("FILER: $FILER"); my $original_filers_name = $FILER; my @Filers; if ( $FILER =~ /\,/ ) { @Filers = split( /\,/, $FILER ); } else { push( @Filers, $FILER ); } my @Nodes = NACL::C::Node->find(); logcomment("Nodes : @Nodes"); my ( $fail_flag, $fatal_flag, $fail_suite ); my $flag_remote; my $test_fail_cmd = "PASS"; if ( $TEST_CONFIG eq 'E' ) { $FILER =~ s/\,/\_/; } else { if ($FILERA) { $FILER = $FILERA; } } package parser; use Switch; use Getopt::Std; use File::Copy; use vars qw/%opt/; use Storage::Common_Lib; sub main(@); sub launch_test($); sub print_usage(); sub find_file_to_open($); sub log_error($$); sub log_pass($); sub log_fail($); sub log_other($$); sub num_of_errors(@); sub isARuleFile($); sub parseRuleFile($$); sub createTestEntry($$); sub fail_rest(); sub set_logpos($); sub cur_logpos(); sub undo_last_move(); sub next_logline(); sub skip_lines($); sub generate_report(); sub print_error($); sub flagSetup(); sub retrieve_cur_timestamp($); sub generate_timestamp($); sub find_timestamp($); sub run_regex($); sub find_command($); sub retrieve_var($); sub store_var($$); sub return_curline_num(); sub trim($); sub rename_log_file($); my $p_parse_id; #eval #{ main( flagSetup() ); #}; sub main(@) { my ( $oldprsoutput, $prsoutput ); if ( $main::URUNID ne "" || $main::FILER ne "" ) { open $prsoutput, '>>', $main::LOGDIR . "/../../../" . $main::PARSE_ID . "_" . $main::FILER . ".parsed" or die "Cant Redirect output"; select $prsoutput; # push (@_, $main::URUNID . ".log"); } else { print "NATE is not being used\n" if $opt{d}; } #Setup variable hash references our ( $testVarsRef, $curTest, $failRest, $curLog, $lastLoc, $logFilesRef, $outputF ); my ( $ruleFilesRef, @testList, @logList, $curFunc, @logListOld, %varss, @subtestlist, $subtestdir ); $outputF = ""; $failRest = "false"; $testVarsRef->{"TestList"} = \@testList; $testVarsRef->{"LogList"} = \@logList; $testVarsRef->{"DoneLogList"} = \@logListOld; $testVarsRef->{"Vars"} = \%varss; $testVarsRef->{"LineNum"} = 0; #To enable the parser to work with SEA push( @_, "Chk_Cond.pm" ); push( @_, $main::LOGDIR . "/" . $main::PARSE_ID . ".log" ); @subtestlist = `ls $main::LOGDIR`; store_var( "SAN", new San( \*ntest::NTEST_STDOUT ) ); foreach my $otherfiles (@subtestlist) { if ( trim($otherfiles) =~ m/(.*END_FILER_CONFIG.*\.log)/g ) { move( "$main::LOGDIR/" . trim($otherfiles), "$main::LOGDIR/../../../" . trim($otherfiles) ); } if ( trim($otherfiles) !~ m/(.*\.log|.*\.parsed|.*\.console|HDD_SUMMARY.*|parser-.*|$main::PARSE_ID*.log)/g ) { move( "$main::LOGDIR/" . trim($otherfiles), "$main::LOGDIR/../../../" . trim($otherfiles) ); } } if ( $main::TEST_CONFIG eq "C" ) { $subtestdir = $main::LOGDIR . "/../../../" . $main::PARSE_ID; if ( -x $subtestdir ) { @subtestlist = `ls $subtestdir`; foreach my $subtst (@subtestlist) { push( @_, $subtestdir . "/" . $subtst ); } store_var( "SUBTESTS", \@subtestlist ); } } store_var( "CurTest", $main::PARSE_ID ); store_var( "FILER", $main::FILER ); store_var( "FILERA", $main::FILERA ); store_var( "FILERB", $main::FILERB ); store_var( "LOGDIR", $main::LOGDIR ); store_var( "TEST_CONFIG", $main::TEST_CONFIG ); #Parse Rule Files while ( my $curFile = shift(@_) ) { if ( $curFile =~ m/(.*)=(\s*)(.*)/ ) { my $varnme = trim($1); my $varvlue = trim($3); print "Adding variable $varnme:$varvlue\n" if $opt{d}; $testVarsRef->{"Vars"}->{$varnme} = $varvlue; next; } my $myhandle = find_file_to_open($curFile); if ( "true" eq isARuleFile($myhandle) ) { #print if debug flag is on print("Rulefile: $curFile\n") if $opt{d}; $ruleFilesRef->{$curFile} = $myhandle; parseRuleFile( $myhandle, $curFile ); } else { push( @{ $testVarsRef->{"LogList"} }, $curFile ); print("other(logFile): $curFile\n") if $opt{d}; $logFilesRef->{$curFile} = $myhandle; } } #Section to handle launching tests with -m flag. Makes copies of everytest and #assigns them to each logfile individually. if ( $opt{m} or ( $main::TEST_CONFIG eq "C" ) ) { my ( @tmpRuleArray, @deleteArray ); foreach my $tests ( @{ $testVarsRef->{"TestList"} } ) { foreach my $logg ( @{ $testVarsRef->{"LogList"} } ) { print "Adding $tests on Log: $logg\n" if ( $opt{d} ); push( @tmpRuleArray, "$tests on Log: $logg" ); createTestEntry( "$tests on Log: $logg", "false" ); $testVarsRef->{ $tests . " on Log: " . $logg }->{"FUNC"} = $testVarsRef->{$tests}->{"FUNC"}; foreach my $testVars ( keys( %{ $testVarsRef->{$tests}->{"Vars"} } ) ) { $testVarsRef->{ $tests . " on Log: " . $logg }->{"Vars"}->{$testVars} = $testVarsRef->{$tests}->{"Vars"}->{$testVars}; print " Inserting $testVars into $tests on Log: $logg\n" if ( $opt{d} ); print " with value of " . $testVarsRef->{$tests}->{$testVars} . "\n" if ( $opt{d} ); } } push( @deleteArray, $tests ); } foreach my $del (@deleteArray) { delete( $testVarsRef->{$del} ); } $testVarsRef->{"TestList"} = \@tmpRuleArray; foreach my $curLogName ( @{ $testVarsRef->{"LogList"} } ) { $curLog = $logFilesRef->{$curLogName}; push( @{ $testVarsRef->{"DoneLogList"} }, $curLogName ); foreach $curTest ( @{ $testVarsRef->{"TestList"} } ) { if ( $curTest =~ /$curLogName/ ) { my $pos = cur_logpos(); print "Starting Test:" . $curTest . "\n" if $opt{d}; print " FUNC=" . $testVarsRef->{$curTest}->{"FUNC"} . "\n" if $opt{d}; $curFunc = \&{ $testVarsRef->{$curTest}->{"FUNC"} }; launch_test($curFunc); set_logpos($pos); } } } } #launching tests for non -m mode. Uses a simple foreach loop to launch each test. else { my $tmpp = shift @{ $testVarsRef->{"LogList"} }; push( @{ $testVarsRef->{"DoneLogList"} }, $tmpp ); $curLog = $logFilesRef->{$tmpp}; #Run each test from the parsed rule files foreach $curTest ( @{ $testVarsRef->{"TestList"} } ) { $curFunc = \&{ $testVarsRef->{$curTest}->{"FUNC"} }; print "Starting Test:" . $curTest . "\n" if $opt{d}; launch_test($curFunc); } } generate_report(); if ( $main::URUNID ne "" || $main::FILER ne "" ) { select $oldprsoutput; close $prsoutput; } rename_log_file($test_dir_name_g); } logcomment("Parse ID: $main::PARSE_ID"); sub rename_log_file($) { my $dir = shift; my $a_parseid = $main::PARSE_ID; my $a_filer = $main::FILER; my $a_filera = $main::FILERA; my $a_filerb = $main::FILERB; my $destination; my $timestamp; my $source; my @main_dir; $a = scalar( localtime() ); $a =~ s/\s\s*/ /g; $a =~ s/ /:/g; $a =~ s/:/ /g; $a =~ s/ /_/g; my @time_a = split( /_/, $a ); my @final; my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my %mon_num = qw( Jan 01 Feb 02 Mar 03 Apr 04 May 05 Jun 06 Jul 07 Aug 08 Sep 09 Oct 10 Nov 11 Dec 12 ); foreach my $val (@time_a) { if ( grep( /$val/i, @abbr ) ) { my $mon_val = $mon_num{"$time_a[1]"}; push( @final, $mon_val ); } else { if ( $val =~ /^[0-9]$/ ) { $val = "0" . $val; push( @final, $val ); } else { push( @final, $val ); } } } #$timestamp = $final[6].$final[1].$final[2]."_".$final[3].$final[4].$final[5]; my ( $year_1, $year_2 ) = $final[6] =~ /^(\d{2})(\d{2})\z/; $timestamp = $year_2 . $final[1] . $final[2] . "_" . $final[3] . $final[4]; print "time - $timestamp\n"; push( @Log_arr, "$dir\n" ); my $time_a_parseid = "$timestamp" . "_" . "$a_parseid"; push( @Log_arr, "$time_a_parseid\n" ); @main_dir = `ls $dir`; foreach (@main_dir) { my $new = $timestamp . "_" . $_; if ( ( ( $_ =~ /^$a_parseid/ ) && ( $_ !~ /check_setup/ ) ) && ( $_ !~ /Pre_Post/ ) ) { if ( ( $_ =~ /\.log$/ ) || ( $_ =~ /\.console$/ ) ) { $source = "$dir$_"; $destination = "$dir$new"; open( SOURCE_F, "$source" ) || die "Could not open $source..."; open( New_F, ">$destination" ) || die "Could not open $destination..."; while ( $_ = ) { print New_F "$_"; } sleep 5; if ( ( $destination =~ /\.log$/ ) && ( $destination !~ /END_FILER_CONFIG/ ) ) { push( @Log_arr, $destination ); } } `sudo rm -f $source`; sleep 5; } if ( ( $_ =~ /init_setup|MINI_DISK_CREATE|DELETE_MINI_DISK/ ) && ( $_ !~ /\d._.\d/ ) ) { if ( $_ =~ /\.log$/ ) { $source = "$dir$_"; $destination = "$dir$new"; open( SOURCE_F, "$source" ) || die "Could not open $source..."; open( New_F, ">$destination" ) || die "Could not open $destination..."; while ( $_ = ) { print New_F "$_"; } sleep 5; `sudo rm -f $source`; } else { `sudo mv $_ $new`; } } if ( ( $_ =~ /Pre_Post/ ) && ( $_ !~ /\d._.\d/ ) ) { if ( $_ =~ /\.log$/ ) { $source = "$dir$_"; $destination = "$dir$new"; open( SOURCE_F, "$source" ) || die "Could not open $source..."; open( New_F, ">$destination" ) || die "Could not open $destination..."; while ( $_ = ) { print New_F "$_"; } sleep 5; `sudo rm -f $source`; } else { `sudo mv $_ $new`; } } if ( ( $_ =~ /System_logs_beginning/ ) && ( $_ !~ /^\d+/ ) ) { if ( $_ =~ /\.log$/ ) { $source = "$dir$_"; $destination = "$dir$new"; open( SOURCE_F, "$source" ) || die "Could not open $source..."; open( New_F, ">$destination" ) || die "Could not open $destination..."; while ( $_ = ) { print New_F "$_"; } sleep 5; `sudo rm -f $source`; } else { chomp($_); $new = $timestamp . $_; my $source = "$dir$_"; my $destination = "$dir$new"; `sudo mv $source $destination`; } } if ( ( $_ =~ /System_logs_end/ ) && ( $_ !~ /^\d+/ ) ) { if ( $_ =~ /\.log$/ ) { $source = "$dir$_"; $destination = "$dir$new"; open( SOURCE_F, "$source" ) || die "Could not open $source..."; open( New_F, ">$destination" ) || die "Could not open $destination..."; while ( $_ = ) { print New_F "$_"; } sleep 5; `sudo rm -f $source`; } else { chomp($_); $new = $timestamp . $_; my $source = "$dir$_"; my $destination = "$dir$new"; `sudo mv $source $destination`; } } if ( ( $_ =~ /Acorn_Dongle_logs_Beginning/ ) && ( $_ !~ /^\d+/ ) ) { chomp($_); my @acr_dir = `ls $dir$_`; if ( !@acr_dir ) { print "Deleting Acorn logs."; `sudo rm -rf $dir$_`; } else { chomp($_); $new = $timestamp . $_; my $source = "$dir$_"; my $destination = "$dir$new"; `sudo mv $source $destination`; } } if ( ( $_ =~ /Acorn_Dongle_logs_at_end/ ) && ( $_ !~ /^\d+/ ) ) { chomp($_); my @acr_dir = `ls $dir$_`; if ( !@acr_dir ) { print "Deleting Acorn logs."; `sudo rm -rf $dir$_`; } else { chomp($_); $new = $timestamp . $_; my $source = "$dir$_"; my $destination = "$dir$new"; `sudo mv $source $destination`; } } } if ( $main::TEST_CONFIG ne 'E' ) { push( @Log_arr, $dir . "check_setup_$a_filer.log" . "\n" ); } #Dummy file for summary parser.. open( FILL1, ">$Home/NDATE/SUPPORT_SCRIPTS/PARSED_OUTPUT_$test_suit_name.txt" ) || die "Could not open dummy file..."; foreach (@Log_arr) { print FILL1 "$_"; } close(FILL1); check_HDD_FILE( $dir, $time_a_parseid, $a_parseid ); } sub check_HDD_FILE($$$) { my ( $log_dir, $time, $PARSE_ID ) = @_; open( HDD, "$log_dir/HDD_SUMMARY_RESULTS" ) || die "Could not open HDD file..."; open( NEWF, ">$log_dir/HDD.txt" ) || die "Could not create HDD file..."; my $filer; my $P_DIR; my @m_log_dir; my $flag = 0; foreach my $line () { if ( ( $line =~ /\/$PARSE_ID/ ) && ( $line !~ /\.parsed/ ) && ( $line !~ /check_setup/ ) ) { $line =~ s/$PARSE_ID/$time/g; print NEWF "$line"; if ( $line =~ /(.*)$PARSE_ID(.*)\.log/ ) { $filer = $2; } } if ( ( $line =~ /Parsed File:(.*)$PARSE_ID(.*)/ ) && ( $line !~ /PARSED_FILES/ ) && ( $line !~ /check_setup/ ) ) { my $new_dir = $log_dir . "PARSED_FILES_" . $time . "/" . $time . $filer . ".parsed"; $line =~ /Parsed File:(.*)/; $line =~ s/$1/$new_dir/g; print NEWF "$line"; } elsif ( ( $line !~ /$time/ ) ) { print NEWF "$line"; } } `sudo cp $log_dir/HDD.txt $log_dir/HDD_SUMMARY_RESULTS`; `sudo rm -f $log_dir/HDD.txt`; remove_main_log_file( $log_dir, $PARSE_ID ); } sub remove_main_log_file($$) { my ( $logdir, $parsed_id ) = @_; my $log_file_name = $main::PARSE_ID; my $main_log_dir = $main::LOGDIR; $log_file_name = "$main_log_dir" . "/" . "$log_file_name" . ".log"; `sudo rm -f $log_file_name`; sleep 1; } sub launch_test($) { my $curFunc = shift; if ( $parser::failRest ne "false" ) { $parser::testVarsRef->{$parser::curTest}->{"Result"} = "FAIL"; } else { $curFunc->($parser::testVarsRef); } } sub print_usage() { return; #TODO fix so this wont print print "parser -dhmsN [rulefiles] [logfiles]\n"; print " flags:\n -d Debug mode. Prints out debug messages.\n" . " -m Multi mode. Run each test on every logfile instead of treating it is as one large log file.\n" . " -h Prints this help message\n" . " -s Silent mode. Prints only tests that have not passed\n" . " -N Indicates that the logfile has been generated by NATE\n"; #TODO Remove comments exit(0); } #Searches NATE_LIB to find the named files. Written to function like NATE sub find_file_to_open($) { my ( $finalHandle, $curFile ) = ( undef, shift ); my @paths = split( /;/, $main::NATE_LIB ); push( @paths, "." ); push( @paths, "$main::LOGDIR" ); push( @paths, $ENV{HOME} . "/NDATE/SUPPORT_SCRIPTS/rules" ); push( @paths, $ENV{HOME} . "/NDATE/SUPPORT_SCRIPTS" ); if ( open( $finalHandle, $curFile ) ) { print "File Found without NATE_LIB\n" if $opt{d}; return $finalHandle; } else { foreach my $pth (@paths) { if ( open( $finalHandle, $pth . "/" . $curFile ) ) { print "File Found $pth/$curFile\n" if $opt{d}; return $finalHandle; } } die "While trying to open $curFile : $_"; } } #Used to check for every flag and remove them from the array #passed to main. It also sets the variables related to each flag sub flagSetup() { my $opts = 'Ndhms'; my @remainArgs = @ARGV; getopts( $opts, \%opt ) or print_usage(); print_usage() if $opt{h}; print_usage() if ( not @remainArgs ); $nateRun = "true" if $opt{N}; foreach ( values %opt ) { shift @remainArgs; if ( !( $_ eq "1" ) ) { shift @remainArgs; } } @remainArgs; } #Used to parse out variables in the rule files and then uses perl #to include the functions sub parseRuleFile($$) { my $ruleHandle = shift @_; my $ruleName = shift @_; my ( $testName, $curLine, $curName, $curValue, $varName ); my @curTestVars; my @aFile = <$ruleHandle>; $testName = ""; while ( $curLine = shift @aFile ) { #filters out all non-#// lines next if ( $curLine !~ /^#\/\// and $testName ne "" ); #Trim functions to remove #// and extra leading & trailing #whitespace $curLine =~ s/^\s+|#\/\///; $curLine =~ s/\s+$//; #Splits Variables apart and Values from Variables @curTestVars = split( /\"\s+|=\s*"?/, $curLine ); while ( $curName = shift @curTestVars ) { #More Trimming $curName = trim($curName); print " Name:" . $curName . "\n" if $opt{d}; if ( $curValue = shift @curTestVars ) { $curValue =~ s/\s*\"$//; print " Value:" . $curValue . "\n" if $opt{d}; } else { print "Error in parsing Rule file:" . $ruleName . "\n"; exit(255); } #More Trimming $curValue =~ s/^\s+//; $curValue =~ s/\s+$//; if ( $curName eq "TESTNAME" ) { $testName = createTestEntry( $curValue, "true" ); } else { if ( $testName ne "" ) { if ( $curName eq "FUNC" ) { $parser::testVarsRef->{$testName}->{$curName} = $curValue; } elsif ( $curName eq "OUTPUTFILE" ) { $parser::outputF = $curValue; } else { $parser::testVarsRef->{"Vars"}->{$curName} = $curValue; } } else { print "Error in parsing Rule file:" . $ruleName . "\n"; exit(255); } } } } require $ruleName; if ( $ruleName =~ m/.*\/(.*)/ ) { import $1; } else { import $ruleName; } close $ruleHandle; } sub createTestEntry($$) { my $testName = shift @_; my $multiFlg = shift; my %testVals; if ( $multiFlg eq "true" ) { push( @{ $parser::testVarsRef->{"TestList"} }, $testName ); } $parser::testVarsRef->{$testName}->{"Vars"} = \%testVals; $parser::testVarsRef->{$testName}->{"Errors"}->{"CRITICAL"}->{"Count"} = 0; $parser::testVarsRef->{$testName}->{"Errors"}->{"DEBUG"}->{"Count"} = 0; $parser::testVarsRef->{$testName}->{"Errors"}->{"WARNING"}->{"Count"} = 0; $parser::testVarsRef->{$testName}->{"Errors"}->{"COMMENT"}->{"Count"} = 0; $parser::testVarsRef->{$testName}->{"Result"} = "None reported"; $testName; } #Checks if file given is a rule file by checking the first 3 characters for the #signature sub isARuleFile($) { my $returnn = "false"; my $arg = shift(@_); my ( $n, $data ); if ( ( $n = read $arg, $data, 3 ) == 3 ) { if ( $data eq "#//" ) { $returnn = "true"; } else { seek( $arg, 0, 0 ); } } $returnn; } sub log_error($$) { my ( $type, $message ) = @_; $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$type"}->{ $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$type"}->{"Count"} } = $message; $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$type"}->{"Count"}++; if ( $type eq "WARNING" and $opt{N} ) { $Tharn::Log->warn($message); } elsif ( $type eq "CRITICAL" and $opt{N} ) { $main::Log->error($message); } } sub log_pass($) { $parser::testVarsRef->{$parser::curTest}->{"Result"} = "PASS"; $parser::testVarsRef->{$parser::curTest}->{"Remark"} = shift; print(" PASS reported for test: $parser::curTest\n") if $opt{d}; } sub log_fail($) { $parser::testVarsRef->{$parser::curTest}->{"Result"} = "FAIL"; $parser::testVarsRef->{$parser::curTest}->{"Remark"} = shift; print(" FAIL reported for test: $parser::curTest\n") if $opt{d}; if ( $nateRun eq "true" ) { $main::Log->error( $parser::testVarsRef->{$parser::curTest}->{"Remark"} ); } } sub log_other($$) { $parser::testVarsRef->{$parser::curTest}->{"Result"} = shift @_; $parser::testVarsRef->{$parser::curTest}->{"Remark"} = shift; print(" Other condition reported for test: $parser::curTest\n") if $opt{d}; } sub num_of_errors(@) { my $cnt = 0; foreach my $err (@_) { if ( $err ne "CRITICAL" and $err ne "WARNING" and $err ne "DEBUG" and $err ne "COMMENT" ) { die "num_of_errors only accepts CRITCAL, WARNING, DEBUG, COMMENT" . " but received " . $err; } $cnt += $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$err"}->{"Count"}; } return $cnt; } sub fail_rest() { $parser::failRest = "true"; } sub set_logpos($) { my $savePt = shift; my $bool = "true"; my $tmpp; $parser::lastLoc = cur_logpos(); while ( $bool eq "true" ) { if ( @{ $parser::testVarsRef->{"DoneLogList"} } ) { $tmpp = pop @{ $parser::testVarsRef->{"DoneLogList"} }; if ( $tmpp eq $savePt->{"file"} ) { push @{ $parser::testVarsRef->{"DoneLogList"} }, $tmpp; print "Restoring point file:$tmpp line:" . $savePt->{"line"} . "\n" if $opt{d}; $parser::curLog = $parser::logFilesRef->{$tmpp}; seek( $parser::curLog, $savePt->{"pos"}, 0 ); $parser::testVarsRef->{"LineNum"} = $savePt->{"line"}; return undef; } print "Unshifting doneLogList to LogList\n" if $opt{d}; unshift( @{ $parser::testVarsRef->{"LogList"} }, ($tmpp) ); } else { die "set_logpos Error"; } } } sub undo_last_move() { set_logpos($parser::lastLoc); } sub cur_logpos() { my %savePt; $savePt{"pos"} = tell($parser::curLog); $savePt{"line"} = $parser::testVarsRef->{"LineNum"}; $savePt{"file"} = pop @{ $parser::testVarsRef->{"DoneLogList"} }; push @{ $parser::testVarsRef->{"DoneLogList"} }, $savePt{"file"}; print "Returning current pos. Line:" . $savePt{"line"} . " file:" . $savePt{"file"} . "\n" if ( $opt{d} ); return \%savePt; } sub retrieve_cur_timestamp($) { my $line = shift; my $timestmp; if ( $line eq undef ) { $line = next_logline(); } if ( $line =~ m/(\d{4})(\d{2})(\d{2}) (\d{2})(\d{2})(\d{2}) (.*)/ ) { $timestmp->{"YEAR"} = $1; $timestmp->{"MONTH"} = $2; $timestmp->{"DAY"} = $3; $timestmp->{"HOUR"} = $4; $timestmp->{"MIN"} = $5; $timestmp->{"SEC"} = $6; # $timestmp-> { "PRINT" } = "$4:$5:$6 on $2/$3/$1"; return $timestmp; } else { return ""; } # my $checked = check( $tmpl, \%args, "false") or die "Check failed: $!"; } sub generate_report() { my ( $time, @datetime ); @datetime = localtime(time); $time = join( '', @datetime ); if ( $parser::outputF eq "" ) { } elsif ( $parser::outputF eq "NONE" ) #opt flag { } else { open OUTPUT, '>', $parser::outputF; STDOUT->fdopen( \*OUTPUT, 'w' ) or die $!; } my ( $s, $m, $h, $d, $mon, $yr, $wd, $yd, $isdst ) = localtime(time); my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); print ":::::::::::::::: Parsed at " . localtime() . " ::::::::::::::::::\n"; if ( not $opt{m} and ( not $main::TEST_CONFIG eq "C" ) ) { print "Logfiles used:"; foreach my $tmps ( @{ $parser::testVarsRef->{"DoneLogList"} } ) { print " " . $tmps; } print "\n"; } ##Creating a dummy file to capture the logs created which will be parsed ##by the parser: nate_logpar_r41e.thpl my $hdd_dir_name = "$main::LOGDIR"; my $test_dir_name = substr( $hdd_dir_name, 0, index( $hdd_dir_name, "HDD/" ) ); $test_dir_name_g = $test_dir_name; # my ($log_dir_name) = $test_dir_name =~ /TEST_LOGS\/(.*)\//; # my ($test_suit_name) = $log_dir_name =~ /\d+_\d+_(.*)/; # print "The test suit name is $test_suit_name\n"; $test_suit_name = $main::STEST_FILE; print "The test suit name is $test_suit_name\n"; print "The directory is $test_dir_name\n"; my @LOG_ARR_main_dir = `ls $test_dir_name`; my $filer = $main::FILER; my $filera = $main::FILERA; my $filerb = $main::FILERB; my $parseid = $main::PARSE_ID; my ( $log_filerA, $log_filerB, $subdir_name ); # push(@Log_arr, "$test_dir_name\n"); # push(@Log_arr, "$parseid\n"); foreach (@LOG_ARR_main_dir) { if ( $_ =~ /(.*$parseid.$filer.log)/ ) { $log_filerA = $test_dir_name . $1 . "\n"; # push(@Log_arr, $log_filerA); } elsif ( $_ =~ /(.*$parseid.$filerb.log)/ ) { $log_filerB = $test_dir_name . $1 . "\n"; # push(@Log_arr, $log_filerB); } elsif ( $_ =~ /(^$parseid$)/ ) { ##Burt Fix ##SUb TEST log is disables from parsing, # Subtest log entry is not made in dummy file. # #if (-d "$test_dir_name$parseid"){ # #my $subdir_name = $test_dir_name.$parseid; # #print" The present subtest directory is $subdir_name \n"; # opendir(DIR,$subdir_name); # my @logarry_subtest = readdir(DIR); # foreach(@logarry_subtest){ # if($_ =~ /(^\w+)/){ # print "req $_\n"; # my $subtest_filename = $subdir_name."/".$_."\n"; # push(@Log_arr, $subtest_filename); # } # } # } } } # push(@Log_arr, $test_dir_name."check_setup_$filer.log"."\n"); # open(FILL1, ">$Home/NDATE/SUPPORT_SCRIPTS/PARSED_OUTPUT_$test_suit_name.txt"); # foreach(@Log_arr){ # print FILL1 "$_"; # } # close(FILL1); foreach $parser::curTest ( @{ $parser::testVarsRef->{"TestList"} } ) { if ( $parser::testVarsRef->{$parser::curTest}->{"Result"} eq "PASS" ) { next if ( $opt{s} ); print trim($parser::curTest) . ": PASS\n"; print " Remarks: " . $parser::testVarsRef->{$parser::curTest}->{"Remark"} . "\n"; } elsif ( $parser::testVarsRef->{$parser::curTest}->{"Result"} eq "FAIL" ) { print trim($parser::curTest) . ": FAIL\n"; print " Remarks: " . $parser::testVarsRef->{$parser::curTest}->{"Remark"} . "\n"; } elsif ( $parser::testVarsRef->{$parser::curTest}->{"Result"} eq "None reported" ) { print "$parser::curTest: Nothing Reported\n"; } else { print "$parser::curTest: OTHER " . $parser::testVarsRef->{$parser::curTest}->{"Result"} . "\n"; } print "================================================================" . "================\n"; print_error("COMMENT"); if ( ( $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"CRITICAL"}->{"Count"} + $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"WARNING"}->{"Count"} + $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"DEBUG"}->{"Count"} ) > 0 ) { print " * * * Errors Detected!! * * *\n"; } print_error("DEBUG"); print_error("CRITICAL"); print_error("WARNING"); } } sub print_error($) { my $val = shift @_; my $typString; if ( $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$val"}->{"Count"} == 0 ) { return 1; } if ( $val eq "CRITICAL" ) { $typString = "Drives with error(s)"; } elsif ( $val eq "WARNING" ) { $typString = "Warning error(s)"; } elsif ( $val eq "DEBUG" ) { $typString = "Inspection or Configuration error(s)"; } elsif ( $val eq "COMMENT" ) { $typString = "Comments"; } print "$typString: "; print $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$val"}->{"Count"} . "\n"; for ( my $i = 0 ; $i < $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$val"}->{"Count"} ; $i++ ) { print " " . $parser::testVarsRef->{$parser::curTest}->{"Errors"}->{"$val"}->{"$i"} . "\n\n"; } print "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " . "- - - - - - - -\n\n"; } #Arguments # Name of Variable sub retrieve_var($) { if ( exists( $parser::testVarsRef->{"Vars"}->{ $_[0] } ) ) { return $parser::testVarsRef->{"Vars"}->{ $_[0] }; } return ""; } #Arguments # Name of Variable # Value of Variable sub store_var($$) { $parser::testVarsRef->{"Vars"}->{ $_[0] } = $_[1]; } sub run_regex($) { my $line = shift @_; my $next; $parser::lastLoc = cur_logpos(); while ( ( $next = next_logline() ) ne "" ) { if ( $next =~ m/$line/ ) { return $next; } } ""; } sub next_logline() { $parser::lastLoc = cur_logpos(); while (<$parser::curLog>) { $parser::testVarsRef->{"LineNum"}++; return $_; } if ( @{ $parser::testVarsRef->{"LogList"} } > 0 and ( not $opt{m} ) and ( not $main::TEST_CONFIG eq "C" ) ) { my $logname = shift @{ $parser::testVarsRef->{"LogList"} }; push @{ $parser::testVarsRef->{"DoneLogList"} }, $logname; $parser::curLog = $parser::logFilesRef->{$logname}; $parser::testVarsRef->{"LineNum"} = 0; return next_logline(); } ""; } sub skip_lines($) { my $num = shift; $parser::lastLoc = cur_logpos(); while ( $num != 0 && $num > 0 ) { next_logline(); $num--; } $num; } sub find_command($) { my $line = shift @_; my ( $next, $flg ) = ( "", "false" ); $parser::lastLoc = cur_logpos(); while ( ( $next = next_logline() ) ne "" ) { if ( $next =~ m/$line/ ) { if ( $flg eq "true" or $nateRun eq "false" ) { return $next; } else { $flg = "true"; } } else { $flg = "false"; } } ""; } ################################################################################################ ## Authorc: aditis@netapp.com ## functionality: system logs will be copied in CLI mode for FATAL ################################################################################################ sub ems_log_generate { logcomment("Inside ems log generate"); my $parse_id; logcomment("Filers present : @Filers"); my $main_log_dir; my $LOGDIR = $main::LOGDIR; if ( $LOGDIR =~ /(\S+)\/HDD\/(\S+)/ ) { $main_log_dir = $1; logcomment("Logdir is $main_log_dir"); } opendir( DIR, "$main_log_dir" ); my @files = readdir(DIR); my @file_arr = (); foreach my $file (@files) { if ( $file =~ /\d+_\d+_(\d+)_NADQ02_\S+\.log/i ) { $parse_id = $1; } } foreach my $node (@Nodes) { my $FILER_C = $node->name(); my $Transit_obj = NACL::Transit->new( name => $FILER_C ); my $filer_state = $Transit_obj->get_state( 'timeout' => 3600, 'get_state_timeout' => 7200 ); logcomment("FILER IS IN $filer_state STATE. "); if ( $filer_state =~ /MAINT/gi ) { logcomment("FILER IS IN $filer_state STATE. SYSTEM LOGS WILL NOT BE GENERATED"); last; } elsif ( $filer_state =~ /CLI/gi ) { if ( $flag_system_logs == 1 ) { read_ems_logs( Node => $node ); my $log_dir = "$main_log_dir\/SYSTEM_LOGS\/" . $parse_id . "\/" . $FILER_C; logcomment("log_dir: $log_dir"); if ( !( -d "$log_dir" ) ) { system("sudo mkdir -p $log_dir"); } get_system_logs( Node => $node, logdir => $log_dir ); logcomment("$FILER_C : System logs copied to the directory : $log_dir"); } else { logcomment("$FILER_C : System logs will be copied only if Script result is FATAL"); } } } } ################################################################################################ ## Author ## arjun.lavu@netap.com ## functionality ## Cleaning empty files and folders and empty lines in the log files ################################################################################################ clean(); sub clean() { my $main_log_dir; my %scsi_sense_codes = ( '0x0' => 'DATA PHASE ERROR', '0x1' => 'INVALID TARGET PORT TRANSFER TAG RECEIVED', '0x2' => 'TOO MUCH WRITE DATA', '0x3' => 'ACK/NAK TIMEOUT', '0x4' => 'NAK RECEIVED', '0x5' => 'DATA OFFSET ERROR', '0x6' => 'INITIATOR RESPONSE TIMEOUT', '0x7' => 'CONNECTION LOST' ); my $LOGDIR = $main::LOGDIR; if ( $LOGDIR =~ /(\S+)\/HDD\/(\S+)/ ) { $main_log_dir = $1; logcomment("Logdir is $main_log_dir"); } logcomment("Checking the empty files under the directory $main_log_dir"); while (1) { my $empty_file = `find $main_log_dir -type f -empty`; $empty_file =~ s/^\s+$//; if ($empty_file) { logcomment("Empty files present in the directory $main_log_dir are"); logcomment("$empty_file"); foreach ( split( /\n/, $empty_file ) ) { logcomment("Deleting the file $_"); `sudo rm -f $_`; } } else { logcomment("No empty files present in the driectory $main_log_dir"); last; } } logcomment("Checking the empty folders under the directory $main_log_dir"); while (1) { ##keep on finding the empty folder till there are no empty folders my $empty = `find $main_log_dir -type d -empty`; $empty =~ s/^\s+$//; if ($empty) { logcomment("Empty folder present in the directory $main_log_dir are"); logcomment("$empty"); foreach ( split( /\n/, $empty ) ) { logcomment("Deleting the folder $_"); `sudo rmdir $_`; } } else { logcomment("No empty folder present in the driectory $main_log_dir"); last; } } #$main_log_dir = "$LOGDIR/../../../"; opendir( OPE, "$main_log_dir" ); my @all_files = readdir(OPE); logcomment("All the files present in the dir $main_log_dir are"); grep { logcomment("$_"); } @all_files; foreach (@all_files) { next if ( $_ =~ /^\.+$/ ); if ( -d "$main_log_dir/$_" ) { logcomment("dir file $main_log_dir/$_"); opendir( OPE1, "$main_log_dir/$_" ); my @inside_files = readdir(OPE1); logcomment("Files present under $main_log_dir/$_ are"); grep { logcomment(" $_") } @inside_files; foreach my $var (@inside_files) { #next if($var=~/\.+/); if ( $var =~ /.log$/i ) { logcomment("LOG FILE $main_log_dir/$_/$var "); open( FH, "$main_log_dir/$_/$var" ) || die("Not able to open the file $main_log_dir/$_/$var "); $/ = undef; my $data = ; if ( $data =~ /\[HDD\S+\]/i ) { $data =~ s/\[HDD\S+\]//g; close(FH); open( FH3, ">$main_log_dir/$_/$var" ); print FH3 $data; close(FH3); } } } $/ = "\n"; } logcomment("file :: $main_log_dir/$_"); if ( -f "$main_log_dir/$_" ) { my @main_log; if ( $_ =~ /\.log$/ ) { my $fail_suite = 0; my @data_line; open( FHR, "$main_log_dir/$_" ) || die "Can not open file $main_log_dir/$_"; my @arr = ; close FHR; foreach my $line (@arr) { while (1) { my $flag = chomp($line); last if ( $flag == 0 ); } if ( ( !defined $line ) || ( $line =~ /^\s+$/ ) || ( $line !~ /\S+/ ) || ( $line !~ /(.+)/ ) ) { next; } # push(@data_line,$line); push( @main_log, $line . "\n" ); } my $m_parseid = $main::PARSE_ID; if ( ( $_ =~ /$m_parseid(.*)\.log$/ ) && ( $_ !~ /results|END_FILER_CONFIG/ ) ) { logcomment("inside parse"); my $fle = $_; my ( $file_cnt, $file_name ) = ( 0, 0 ); ( $file_cnt, $file_name ) = filter( $main_log_dir, $m_parseid ); logcomment("inside :: $file_cnt,$file_name"); if ( $file_name !~ /^$fle$/ ) { next; } else { my %result_struct; my $cntr = 0; my $Home = $ENV{HOME}; $/ = undef; my $no_run_flag = 0; open( Fh, "$Home/NDATE/SUPPORT_SCRIPTS/ERROR_FILE" ) || print "Cannot open file $Home/SUPPORT_SCRIPTS/ERROR_FILE"; my $error_file = ; logcomment("Error meassages from the NDATE : $error_file"); close Fh; open( Fh, "$Home/NDATE/SUPPORT_SCRIPTS/cmd_failed_err" ) || print "Cannot open file $Home/SUPPORT_SCRIPTS/ERROR_FILE"; my @cmd_expect_fails = ; logcomment("Command Failed meassages which are expected : @cmd_expect_fails"); close Fh; $/ = "\n"; my @PANIC_FATAL = (); my $PANIC_FLAG = 0; my $PANIC_Check = 0; my %check_condition; my %check_condition_line; my %new_check_condition; my %check_condition_line1; my %check_condition_fatal; my %check_condition_adapter; my %check_condition_adapter_line; my %check_condition_disk_rec; my %check_condition_disk_exceed_limit; my %check_condition_disk_exceed_limit_line; # logcomment("Total number of lines : ". scalar @data_line); my $temp = 0; foreach my $line (@main_log) { $cntr++; if ( ( $line =~ /Comment:\s*DEBUG\s*:/i ) || ( $line =~ /Comment:\s*\*\*DEBUG\*\*\s*:/i ) ) { $line =~ s/(\.?)\s*Comment:\s*DEBUG\s*:\s*/\*\*DEBUG\*\* : /i; $line =~ s/(\.?)\s*Comment:\s*\*\*DEBUG\*\*\s*:\s*/\*\*DEBUG\*\* : /i; } elsif ( $line =~ /\*\*(WARNING|FAIL|FATAL|NORUN)\*\*/ ) { $line =~ s/(\.?)\s*Comment\s*:\s*//; } if ( $line =~ /NDATE\s*Build\s*Version\s*used\s*\:\s*(.+)/i ) { $result_struct{'NDATE_VERSION'} = $1; } if ( $line =~ /NDATE\s*Build\s*Date\s*\:\s*(.+)/i ) { $result_struct{'NDATE_BUILD_DATE'} = $1; } if ( $line =~ /PNATE\s*Build\s*Version\s*\:\s*(.+)/i ) { $result_struct{'pNATE_VERSION'} = $1; } if ( $line =~ /Finished with Re-estabilishing Connection to Filer/ig ) { $temp = 1; } if ( ( $line =~ /\*\*(WARNING)\*\*/i ) || ( $line =~ /\*\*(NORUN)\*\*/i ) || ( $line =~ /\*\*(FAIL)\*\*/i ) || ( $line =~ /\*\*(FATAL)\*\*/i ) || ( $line =~ /\* (FATAL) FAIL:/ ) ) { my $tmp; my $line1; my $err_ty = $1; # (my $tmp = $line)=~s/\d+\s*\d+\s*\.\s*Comment\s*:\s*//; if ( $line =~ /(.*)Comment\s*:\s*/ ) { ( $tmp = $line ) =~ s/(.*)Comment\s*:\s*//; } if ( $line =~ /^\d+\s*\d+/ ) { ( $tmp = $line ) =~ s/^\d+\s*\d+//; } next if ( $line =~ /\* FATAL FAIL:/ ); if ( $line =~ /\* FATAL FAIL:/ ) { $tmp = $line; $tmp =~ s/^\* FATAL FAIL:/\*\*FATAL\*\*/; } chomp($tmp); my $msg = "$tmp" . " in Line number : $cntr"; push( @{ $result_struct{$err_ty} }, $msg ); } if ( $line =~ /(Connection closed by foreign host|closed by remote host)/ ) { my $tmp; my $err_ty; ( my $p_parse_id = $m_parseid ) =~ s/^\d+\_*//; if ( ( $line =~ /(Connection closed by foreign host)/i ) && ( $temp == 1 ) ) { logcomment("inside Conn $temp"); $err_ty = 'FATAL'; $tmp = "Connection closed by foreign host"; my $msg = "$tmp" . " in Line number : $cntr"; push( @{ $result_struct{$err_ty} }, $msg ); } if ( ( $line =~ /(Connection closed by foreign host)/i ) && ( $p_parse_id !~ /check_filer|CONVERT_SETUP/i ) ) { logcomment("inside not check_filer"); $err_ty = 'FATAL'; $tmp = $1; my $msg = "$tmp" . " in Line number : $cntr"; push( @{ $result_struct{$err_ty} }, $msg ); } if ( $line =~ /(closed by remote host)/i ) { my $rem_line_cnt = $cntr + 20; for ( my $i = $cntr ; $i < $rem_line_cnt ; $i++ ) { my $check_line = $main_log[$i]; $check_line =~ s/(\r|\n)//g; if ( $check_line =~ /TCD::_run_method\(\):testcase exited/i ) { $err_ty = 'FAIL'; $tmp = "closed by remote host"; my $msg = "$tmp" . " in Line number : $cntr"; push( @{ $result_struct{$err_ty} }, $msg ); } elsif ( $check_line =~ /(.*::\*>)|(LOADER)|(\*>)|(::>)/i ) { logcomment("RE-establishing the Connection"); $flag_remote = 1; last; } } } } if ( $line =~ /TCD::_run_method\(\):\s*testcase exited(.*)/ig ) { my $ll2 = $1; $ll2 =~ s/(\n|\r)//g; my $msg; if ( ( $ll2 =~ /(Unexpected EOF.*)/ ) || ( $ll2 =~ /(Timed out waiting for recognizable output to identify current boot state)/ ) || ( $ll2 =~ /(Timed out 'awaiting prompts' while logging in on connection)/ ) ) { my $ll2 = $1; $msg = "**FAIL** : $ll2 in LineNumber : $cntr"; } else { $msg = "**FAIL** : EXPECTED PROMPT IS NOT APPEARED, Exiting From the Test - in line number: $cntr " if ( !defined @{ $result_struct{"FAIL"} } ); } push( @{ $result_struct{"FAIL"} }, $msg ); } if ( $line =~ /\* FAIL:\s*(.*)/ ) { my $ll2 = $1; if ( $ll2 =~ /(Testcase Complete:\s*.*failed)/ ) { $test_fail_cmd = "FAIL"; next; } elsif ( $ll2 =~ /(cycled through too many boot state)|(Timed out waiting for recognizable output to identify)/ig ) { my $l2 = $1; my $msg = "**FAIL** : $l2 in Line Number : $cntr"; push( @{ $result_struct{"FAIL"} }, $msg ); } elsif ( length($ll2) < 100 ) { my $msg = "**FAIL** : $ll2 - in Line Number : $cntr"; push( @{ $result_struct{"FAIL"} }, $msg ); } else { my $msg = "**FAIL** : EXPECTED PROMPT IS NOT APPEARED, Exiting From the Test - in Line Number : $cntr" if ( !defined @{ $result_struct{"FAIL"} } ); push( @{ $result_struct{"FAIL"} }, $msg ); } } if ( $line =~ /Connect Failed: NATE::ServiceAPI->request_get/i ) { my $msg = "CANNOT CONNECT TO FILER USING SYSTEMSHELL in Line number : $cntr"; push( @{ $result_struct{"COMMAND_FAILED_MESSAGES"} }, $msg ); } ( my $p_parse_id = $m_parseid ) =~ s/^\d+\_*//; if ( ( $line =~ /(PANIC):(.*)/i ) && ( $p_parse_id !~ /SprayCore_T|NVMe_Enum_Panic_Cmd/ig ) ) { my $panic = $2; $PANIC_FLAG = 1; my $msg = "PANIC:$panic found in Line number : $cntr"; push( @PANIC_FATAL, $msg ); # push (@{$result_struct{"FATAL"}},$msg); } if ( $line =~ /(TESTSCRIPT):(.*)/i ) { my $script = $2; $script =~ s/\.thpl$//; $result_struct{$1} = $script; } if ( $line =~ /TESTLOG\s*:\s*(\S+)\/HDD/ ) { $result_struct{'TESTLOG_FILE'} = $1 . "/$_"; } if ( ( $line =~ /(\d+\s+\S+\s+Failed\*\*\s+.*setup)/ ) || ( $line =~ /\*\*NORUN\*\*/ ) || ( $line =~ /Testing aborted due to fatal return from setup/ ) ) { sleep(10); $result_struct{'SCRIPT_RESULT'} = 'NORUN'; $no_run_flag = 1; } if ( $line =~ /\d+\s+\S+\s+Failed\*\*\s+|Script error/ ) { $result_struct{'SCRIPT_RESULT'} = 'FAILED'; } if ( ( $line =~ /\*\*FATAL\*\*/i ) && ( $no_run_flag == 0 ) ) { $result_struct{'SCRIPT_RESULT'} = 'FATAL'; } if ( ( $line =~ /Timeout waiting for (waitstrings\/prompts|command to complete)/ig ) && ( $no_run_flag == 0 ) ) { my $var = "**FAIL*** : EXPECTED PROMPT IS NOT APPEARED, Exiting From the Test - in line number: $cntr"; push( @{ $result_struct{"FAIL"} }, $var ); } if ( $line =~ /Number of FAILED disks are/i ) { $result_struct{'KILL_TEST_SUITE'} = 'YES'; } if ( $line =~ /.*(Detected encrypting disk.*)/ ) { my $msg = "**WARNING**: $1 in Line Number : $cntr"; logcomment("**WARNING** $line in Line Number : $cntr"); push( @{ $result_struct{"WARNING"} }, $msg ); } if ( ( $line =~ /unknown operand|unknown option/ ) || ( $line =~ /Invalid option|Invalid command/ ) || ( $line =~ /(not found\.\s*Type\s*\'\?\'\s*for a list of commands)/ ) || ( $line =~ /(Error: Ambiguous argument)|(\".*\" is not supported: use the \"system node run.*)/ ) || ( ( $line =~ /(Did not recognize option)|(is not a recognized command)|(Type '\?' for a list of commands|Unrecognized option)/ ) && ( $line !~ /Failure in subtest/i ) ) || ( ( $line =~ /Error: command failed:/i ) && ( $line !~ /rename/ ) ) || ( $line =~ /Error: Cannot read chassis FRU PROM/ ) ) { #Burt996827 my $line1 = $line; $line1 =~ s/(\n|\r)//g; $line1 =~ s/\d+\s+\d+\s+< $comment -> scsi $line1 "); my ($drv) = ( $line =~ /Disk device\s*(\w+\.\w+\.\w+)/i ); my ($check_cond) = ( $line =~ /(\w+x\w+ - \w+x\w+ \w+x\w+ \w+x\w+)/i ); if ( $line1 =~ /Sense Data SCSI:aborted command.*0xb - 0x4b \w+x\w+ \w+x\w+/i ) { grep { $check_condition{$drv}{"Sense Data SCSI:aborted command"}{$_}++ } $check_cond; $check_condition_line{$drv} = $cntr; } #********************Burt 961618********************# ##added by abalaji@netapp.com if ( ( $line1 =~ /(Sense Data.*)\(0x5 - \wx\w+ \wx\w+ \wx\w+\)/ ) && ( $p_parse_id =~ /FA_Byte/i ) ) { # my $msg = "**WARNING**:$comment in Line Number: $cntr"; # push( @{ $result_struct{"WARNING"} }, $msg ); grep { $check_condition{$drv}{$1}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; } #****************************************# next if ( $line1 =~ /\(0x5 - 0x24 0x0 0x\w+\)/ ); #BURT 1000463 next if ( $line1 =~ /0x5 - 0x20 0x0 0x\w+/ ); #BURT 1000463 next if ( $line1 =~ /0x5 - 0x2c 0xf 0x0/ ) && ( $p_parse_id =~ /PwrCyc|PwrCyc_FW_DL|Hmr_Adp_Rst|Disk_Qual_Dev_Rst|Disk_Qual_Adapt_Rst/i ); #Burt 1161321 kiranp1 if ( ( $line1 =~ /(\(0x4 - \wx\w+ \wx\w+ 0x\w+\))|(\(0x1 - 5xD \wx\w+ 0x\w+\))/ ) && ( $p_parse_id !~ /FA_Byte/i ) ) { #BURT 1000463 logcomment("FATAL , Since $line1 :$cntr"); $fatal_flag = 1; #BURT 1000463 my $msg = "**FATAL**:$comment in Line Number: $cntr"; push( @{ $result_struct{"FATAL"} }, $msg ); } elsif ( $p_parse_id =~ /PwrCyc|Disk_FW_DL|Ping_Pong|PwrCyc_FW_DL/i ) { if ( ( $line1 =~ /(\(0x2 - 0x4 0x1 0x\w+\))/ ) || ( $line1 =~ /0x5 - 0x2c 0xf 0x0/ ) ) { #Burt 1161321 kiranp1 #BURT 1000463 next; } else { # my $msg = "**WARNING**:$comment in Line Number: $cntr"; # push( @{ $result_struct{"WARNING"} }, $msg ); grep { $check_condition{$drv}{"scsi check Condition"}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; } } elsif ( $p_parse_id =~ /Sanitize_Verify|PwrCyc|PwrCyc_FW_DL|WCache_Integrity/i ) { #BURT 1043843 blessy if ( ( $line1 =~ /(\(0x2 - 0x4 0x1b 0x\w+\))/ ) || ( $line1 =~ /0x5 - 0x2c 0xf 0x0/ ) ) { #Burt 1161321 kiranp1 next; } else { # my $msg = "**WARNING**:$comment in Line Number: $cntr"; # push( @{ $result_struct{"WARNING"} }, $msg ); grep { $check_condition{$drv}{"scsi check Condition"}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; } } elsif ( $p_parse_id =~ /ERR_Inject|Hmr_Adp_Rst|Disk_Qual_Dev_Rst|Disk_Qual_Adapt_Rst/ ) { if ( $line1 =~ /(\(0x2 - 0x4 (\w+x\w+) \w+x\w+\))/ ) { #BURT 1000463 # my $msg = "**WARNING**:$comment in Line Number: $cntr"; # push( @{ $result_struct{"WARNING"} }, $msg ); my $temp = $1; $temp =~ s/^\s+|\s+$//g; foreach my $code ( keys %scsi_sense_codes ) { $new_check_condition{$temp}{$drv}++ if ( $temp eq $code ); } #grep { $check_condition{$drv}{"Sense Data SCSI:not ready"}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; } else { # my $msg = "**WARNING**:$comment in Line Number: $cntr"; # push( @{ $result_struct{"WARNING"} }, $msg ); grep { $check_condition{$drv}{"scsi check Condition"}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; } } elsif ( $p_parse_id =~ /ECC/i ) { if ( $line1 =~ /(\(0x5 - 0x24 0x0 0x\w+\))|(\(0x3 - 1x1 0x0 0x\w+\))/ ) { #BURT 1000463 $fail_flag = 1; next; } else { grep { $check_condition{$drv}{"scsi check Condition"}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; # my $msg = "**WARNING**:$comment in Line Number: $cntr"; # push( @{ $result_struct{"WARNING"} }, $msg ); } } elsif ( $p_parse_id =~ /PVT/i ) { if ( $line1 =~ /SCSI:not ready/ ) { #BURT 1000463 $fail_flag = 1; next; } } else { grep { $check_condition{$drv}{"scsi check Condition"}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; # my $msg = "**WARNING**:$comment in Line Number: $cntr"; # push( @{ $result_struct{"WARNING"} }, $msg ); } } # pushing all the arning messages my @err_cnt = $line =~ /($err)/gsi; foreach (@err_cnt) { push( @{ $result_struct{'ERROR_MESSAGES'}{$_} }, $cntr ); } } } } if ( $line =~ /Time:\s+(\S+)/ ) { $PANIC_Check = 1; my (@time) = split( ":", $1 ); my $time = "$time[0] Hours, $time[1] Minutes, " . int( $time[2] ) . " Seconds"; $result_struct{'TIME'} = $time; } elsif ( ( $line =~ /Pass:\s*0/ ) && ( $PANIC_Check == 1 ) ) { push( @{ $result_struct{"FATAL"} }, @PANIC_FATAL ) if ( $PANIC_FLAG == 1 ); } if ( $line =~ /\*\s*SCRIPT ERROR:/ ) { my $msg = "SCRIPT ERROR FOUND in Line number : $cntr"; push( @{ $result_struct{'SCRIPT_ERROR'} }, $msg ); } #Burt 1124134 if ( $p_parse_id =~ /FW_DL_Dev_Rst|Disk_Qual_Dev_Rst|Compliance|PwrCyc|PwrCyc_FW_DL|Sanitize_Verify|DRAM_stress|Unmap_Error|WCache_Integrity|Hmr_Adp_Rst|Qual_Adapt_Rst/i ) { if ( $line =~ /disk\.exceed\.cmd\.completeTime:info]:\s*Disk\s*(\S+)\s*has\s*exceeded\s*\d+\s*ms\s*limit\s*--\s*required\s*(\d+)\s*ms/ ) { my $disk_rec = $1; my $rec_time = $2; if ( $rec_time >= 60000 ) { my ($check_cond) = ( $line =~ /(has exceeded 30000 ms limit -- required)/ ); grep { $check_condition_disk_exceed_limit{$disk_rec}{"has exceeded 60000 ms limit"}{$check_cond}++ } $check_cond; $check_condition_disk_exceed_limit_line{$disk_rec} = $cntr; } } if ( $line =~ /scsi\.cmd\.retrySuccess:debug]:\s*Disk\s*device\s*(\S+):\s*request\s*successful\s*after\s*retry\s*\S*:\s*\S*\s*\S*\s*\((\d+)\)/ ) { my $drv = $1; my $rec_time = $2; if ( $rec_time >= 60000 ) { my ($check_cond) = ( $line =~ /(request successful after retry)/ ); grep { $check_condition_disk_rec{$drv}{"Disk recovery after retry"}{$check_cond}++ } $check_cond; $check_condition_line{$drv} = $cntr; } } } if ( $line =~ /raid\.rg\.scrub\.cksum\.embed:notice/ ) { my ($drv) = ( $line =~ /Disk\s*\S*\/(\w+\.\w+\.\w+)/i ); my ($check_cond) = ( $line =~ /(Invalid checksum entry)/ ); grep { $check_condition_fatal{$drv}{"Data Corruption"}{$check_cond}++ } $check_cond; $check_condition_line1{$drv} = $cntr; } if ( $line =~ /raid\.rg\.readerr\.repair\.data:notice/ ) { my $msg = "**FATAL** raid readerr data notice found in Line number : $cntr"; push( @{ $result_struct{"FATAL"} }, $msg ); } if ( $line =~ /raid\.rg\.readerr\.repair\.cksum\.error:notice/ ) { my ($drv) = ( $line =~ /Disk\s*\S*\/(\w+\.\w+\.\w+)/i ); my ($check_cond) = ( $line =~ /(Data recalculated from parity)/ ); grep { $check_condition_fatal{$drv}{"Drive Failure"}{$check_cond}++ } $check_cond; $check_condition_line1{$drv} = $cntr; } if ( $line =~ /raid\.rg\.scrub\.summary\.cksum:notice/ ) { my ($err) = ( $line =~ /Scrub\s*found\s*(\d+)\s*checksum\s*errors/ ); if ( $err > 0 ) { my $msg = "**WARNING** $err checksum errors found in Line number : $cntr"; push( @{ $result_struct{"WARNING"} }, $msg ); } } ## Burt : 1126545 if ( $p_parse_id !~ /Qual_Adapt_Rst/i ) { #Burt1162330 if ( $line =~ /sas\.adapter\.reset:debug/i ) { my ($check_cond) = ( $line =~ /(Resetting SAS adapter)\s*(\d\S)/i ); grep { $check_condition_adapter{$2}{$check_cond}++ } $check_cond; $check_condition_adapter_line{$2} = $cntr; } } if ( $line =~ /(disk\.ioRecoveredError\.reassign:notice)/i ) { my ($check_cond) = ( $line =~ /(Recovered error on disk)\s*(\w+\.\w+\.\w+)/i ); grep { $check_condition{$2}{"disk.ioRecoveredError.reassign:notice"}{$check_cond}++ } $check_cond; $check_condition_line{$2} = $cntr; } } if ( defined %check_condition ) { foreach my $drv ( keys %check_condition ) { foreach my $err ( keys %{ $check_condition{$drv} } ) { foreach my $check_con ( keys %{ $check_condition{$drv}{$err} } ) { push( @{ $result_struct{"WARNING"} }, "**WARNING**: Drive $drv had $check_condition{$drv}{$err}{$check_con} Check Conditions -- $err - ($check_con) in Line number : $check_condition_line{$drv}" ); } } } } if ( defined %new_check_condition ) { foreach my $code ( keys %new_check_condition ) { my @drives = keys %{ $new_check_condition{$code} }; push( @{ $result_struct{"WARNING"} }, "**WARNING**: Total " . scalar(@drives) . " drives has $scsi_sense_codes{$code} ($code) and drives are : @drives" ); } } if ( defined %check_condition_fatal ) { foreach my $drv ( keys %check_condition_fatal ) { foreach my $err ( keys %{ $check_condition_fatal{$drv} } ) { foreach my $check_con ( keys %{ $check_condition_fatal{$drv}{$err} } ) { push( @{ $result_struct{"FATAL"} }, "**FATAL**: $check_con on disk -- $drv for $check_condition_fatal{$drv}{$err}{$check_con} times in Line number : $check_condition_line1{$drv}" ); } } } } #burt1124134 if ( defined %check_condition_disk_exceed_limit ) { foreach my $drv ( keys %check_condition_disk_exceed_limit ) { foreach my $err ( keys %{ $check_condition_disk_exceed_limit{$drv} } ) { foreach my $check_con ( keys %{ $check_condition_disk_exceed_limit{$drv}{$err} } ) { push( @{ $result_struct{"WARNING"} }, "**WARNING**: Drive $drv $err to complete disk recovery command and appeared $check_condition_disk_exceed_limit{$drv}{$err}{$check_con} times in Line : $check_condition_disk_exceed_limit_line{$drv}" ); } } } } if ( defined %check_condition_disk_rec ) { foreach my $drv ( keys %check_condition_disk_rec ) { foreach my $err ( keys %{ $check_condition_disk_rec{$drv} } ) { foreach my $check_con ( keys %{ $check_condition_disk_rec{$drv}{$err} } ) { push( @{ $result_struct{"WARNING"} }, "**WARNING**: $err took more than 60,000 ms on disk $drv appeared $check_condition_disk_rec{$drv}{$err}{$check_con} times in Line : $check_condition_line{$drv}" ); } } } } if ( defined %check_condition_adapter ) { foreach my $adapt ( keys %check_condition_adapter ) { my @check_cond = keys %{ $check_condition_adapter{$adapt} }; foreach my $check_cond (@check_cond) { push( @{ $result_struct{"WARNING"} }, "**WARNING**: Adapter $adapt has Resetting SAS adapter messages $check_condition_adapter{$adapt}{$check_cond} times in line number $check_condition_adapter_line{$adapt}" ); } } } # if((defined $result_struct{'FAIL'})||(defined $result_struct{'FATAL'})){ if ( defined $result_struct{'NORUN'} ) { $result_struct{'SCRIPT_RESULT'} = 'NO_RUN'; } elsif ( defined $result_struct{'FAIL'} ) { $result_struct{'SCRIPT_RESULT'} = 'FAILED'; } elsif ( ( defined $result_struct{'FATAL'} ) || ( defined $result_struct{'SCRIPT_ERROR'} ) ) { #&&($no_run_flag == 0)){Burt996827 $flag_system_logs = 1; $result_struct{'SCRIPT_RESULT'} = 'FATAL'; } elsif ( $result_struct{'SCRIPT_RESULT'} !~ /FAILED|NO_RUN|FATAL/ ) { #Burt996827 $result_struct{'SCRIPT_RESULT'} = 'PASSED'; } if ( defined $result_struct{'FATAL'} ) { $flag_system_logs = 1; $result_struct{'SCRIPT_RESULT'} = 'FATAL'; } push( @data_line, "\n#################################################################################################\n" ); # if(defined $result_struct{TESTSCRIPT}){ # push(@data_line,"## SCRIPT NAME : $result_struct{TESTSCRIPT}\n"); # }else { $p_parse_id; ( $p_parse_id = $m_parseid ) =~ s/^\d+\_*//; if ( $file_cnt > 1 ) { $p_parse_id = $p_parse_id . "\(" . ( $file_cnt - 1 ) . "\)"; } push( @data_line, "## SCRIPT NAME : $p_parse_id\n" ); } push( @data_line, "## TOTAL TIME TAKEN : $result_struct{TIME}\n" ); push( @data_line, "## SCRIPT RESULT : $result_struct{SCRIPT_RESULT}\n" ); if ( defined $result_struct{TESTLOG_FILE} ) { push( @data_line, "## LOG FILE : $result_struct{TESTLOG_FILE}\n##\n" ); } else { push( @data_line, "## LOG FILE : $_\n##\n" ); } push( @data_line, "## WARNING MESSAGES :\n##" ); my @data1 = do { my %seen; grep { !$seen{$_}++ } @{ $result_struct{'WARNING'} }; }; my %seen; foreach (@data1) { if ( ( $m_parseid =~ /510|407|401|506|504|501/ ) && ( $_ =~ /DWORD|LOS count|Disparity Error count/i ) ) { #its not required to chk for these TC burt971123 next; } elsif ( ( $_ =~ /.*(scsi\.cmd\.checkCondition.*(\w+\.\d+\.\w+).*)/ ) || ( $_ =~ /(Medium\s*error\s*on\s*disk|ioMediumError|SCSI:medium error.*(\w+\.\d+\.\w+).*)/i ) ) { ##Burt1031268 my $drive = $2; my $sent = $1; chomp($sent); $seen{$drive} = "\n## $sent"; } elsif ( ( $_ =~ /(COULDN'T UNFAIL THE DISK : \S+)/ ) || ( $_ =~ /(Detected encrypting disk \S+)/ ) ) { my $ll = "$_"; my $drive = $1; $seen{$drive} = "\n## $ll"; } elsif ( $_ =~ /(container disk \S+ not assigned)/ ) { my $ll = "$_"; my $drive = $1; $seen{$drive} = "\n## $ll"; } elsif ( $_ =~ /\*\*WARNING\*\*:\s*Drive\s*\w+.(\d+.\d+).*in Line.*/i ) { my $ll = "$_"; my $drive = $1; $seen{$drive} = "\n## $ll"; } elsif ( ( $_ =~ /\*\*WARNING\*\*:.*(\w+\.\w+).*in Line.*/i ) || ( $_ =~ /\*\*WARNING\*\*:.*(\w+\.\w+\.\w+).*in Line.*/i ) ) { my $ll = "$_"; my $drive = $1; $seen{$drive} = "\n## $ll"; } elsif ( $_ =~ /\*\*WARNING\*\*:(.*)in Line.*/ ) { my $ll = "$_"; my $drive = $1; $seen{$drive} = "\n## $ll"; } else { push( @data_line, "\n## $_" ); } } my @value = values %seen; push( @data_line, @value ); my %seen_norun; push( @data_line, "\n## No Warning messages available\n##" ) if ( !( @{ $result_struct{'WARNING'} } ) ); push( @data_line, "\n##" ); push( @data_line, "\n## NO_RUN MESSAGES:\n##" ); my $flag_norun = 1; foreach ( @{ $result_struct{'NORUN'} } ) { $flag_norun = 0; if ( $_ =~ /\*\*NORUN\*\*\s*:\s*(.*)in Line .*/i ) { my $key = $1; $seen_norun{$key} = "\n## $_"; } else { push( @data_line, "\n## $_" ); } } push( @data_line, reverse values %seen_norun ); push( @data_line, "\n## No No_Run messages available\n##" ) if ( !( @{ $result_struct{'NORUN'} } ) ); push( @data_line, "\n##" ); push( @data_line, "\n## FAILURE MESSAGES:\n##" ); my %seen_fail; my $flag_fail = 0; foreach ( @{ $result_struct{'FAIL'} } ) { logcomment("--> $_"); next if ( ( $_ =~ /EXPECTED PROMPT IS NOT APPEARED, Exiting From the Test/ ) && ( ( defined $result_struct{'SCRIPT_ERROR'} ) || ( defined $result_struct{'FATAL'} ) ) || ( $flag_norun == 0 ) ); $flag_fail = 1; if ( ( $_ =~ /.*(scsi\.cmd\.checkCondition.*\w+\.\d+\.\w+)/ ) ) { ##changes made by abalaji my $drive = $1; $seen_fail{$drive} = "\n## $_"; } elsif ( $_ =~ /(EXPECTED PROMPT IS NOT APPEARED, Exiting From the Test)/ ) { my $ll = "$_"; my $drive = $1; $seen_fail{$drive} = "\n## $ll"; } elsif ( $_ =~ /\*\*FAIL\*\*:(.*)in Line .*/i ) { my $ll = "$_"; my $drive = $1; $seen_fail{$drive} = "\n## $ll"; } else { push( @data_line, "\n## $_" ); } } my @value1 = values %seen_fail; push( @data_line, @value1 ); push( @data_line, "\n## No Failure messages available\n##" ) if ( ( !( @{ $result_struct{'FAIL'} } ) ) || ( $flag_fail == 0 ) ); push( @data_line, "\n##" ); push( @data_line, "\n## FATAL MESSAGES :\n##" ); my %seen_fatal; foreach ( @{ $result_struct{'FATAL'} } ) { if ( ( $_ =~ /.*scsi.cmd.checkCondition.*(Disk device \w+\.(\d+\.\w+): .*)/ ) ) { my $ll = "**FATAL** : $1"; my $drive = $2; $seen_fatal{$drive} = "\n## $ll"; } elsif ( $_ =~ /(EXPECTED PROMPT IS NOT APPEARED, Exiting From the Test)/ ) { my $var = $1; $seen_fatal{$var} = "\n## $_"; } elsif ( $_ =~ /\*\*FATAL\*\*:(.*)in Line .*/ ) { my $ll = "$_"; my $drive = $1; $seen_fatal{$drive} = "\n## $ll"; } else { push( @data_line, "\n## $_" ); } } my @value2 = values %seen_fatal; push( @data_line, @value2 ); push( @data_line, "\n## No Fatal messages available\n##" ) if ( !( @{ $result_struct{'FATAL'} } ) ); push( @data_line, "\n##" ); push( @data_line, "\n## ERROR MESSAGES:\n##" ); # foreach(@{$result_struct{'ERROR_MESSAGES'}}){ # push(@data_line,"\n## $_"); # } foreach my $key ( keys %{ $result_struct{'ERROR_MESSAGES'} } ) { my @errors = @{ $result_struct{'ERROR_MESSAGES'}{$key} }; if ( ( $m_parseid =~ /FA_Byte/ ) && ( $key =~ /SCSI:recovered\s*error/i ) ) { next; } if ( ( $m_parseid =~ /Unmap_Error_Injection/ ) && ( $key =~ /scsi\.cmd\.notReadyCondition/i ) ) { next; } if ( scalar @errors > 1 ) { push( @data_line, "\n## $key found : " . scalar @errors . " times between lines $errors[0] to $errors[-1]" ); } elsif ( scalar @errors == 1 ) { push( @data_line, "\n## $key found in Line number : @errors" ); } } push( @data_line, "\n## No Error messages available\n##" ) if ( !( keys %{ $result_struct{'ERROR_MESSAGES'} } ) ); push( @data_line, "\n##" ); push( @data_line, "\n## SCRIPT ERROR MESSAGES:\n##" ); if ( defined $result_struct{'SCRIPT_ERROR'} ) { foreach ( @{ $result_struct{'SCRIPT_ERROR'} } ) { push( @data_line, "\n## $_" ); } } else { push( @data_line, "\n## No Script Error messages available\n##" ); } push( @data_line, "\n##" ); push( @data_line, "\n## COMMAND FAILED MESSAGES:\n##" ); my %seen_cmd; if ( defined $result_struct{'COMMAND_FAILED_MESSAGES'} ) { foreach ( @{ $result_struct{'COMMAND_FAILED_MESSAGES'} } ) { if ( ( $_ =~ /Command failed\s*\".*\|(.*)\" message found/ig ) ) { #Burt996827 - printing unique commands failed msgs. nmamatha my $drive = $1; $seen_cmd{$drive} = "\n## $_"; } elsif ( $_ =~ /(.*)in Line/ig ) { my $drive = $1; $seen_cmd{$drive} = "\n## $_"; } else { push( @data_line, "\n## $_" ); } } my @value2 = values %seen_cmd; push( @data_line, @value2 ); } else { push( @data_line, "\n## No Command Failed messages available\n##\n##" ); } push( @data_line, "\n##" ); push( @data_line, "\n#################################################################################################\n\n" ); push @main_log, @data_line; @data_line = grep { $_ =~ /[^\n]/ } @data_line; #logcomment("data : @data_line"); my $status = join( "", @data_line ); open( STATUS, ">>$main_log_dir/TEST_SUMMARY_DETAILS" ); print STATUS $status; close STATUS; { my %replace = ( 'NO_RUN' => "\'background-color: #E60303;\'>NO_RUN", 'FAILED' => "\'background-color: #E60303;\'>FAILED", 'PASSED' => "\'background-color: #46ED30;\'>PASSED", 'FATAL' => "\'background-color: #E60303;\'>FATAL" ); my $replace = 'SCRIPT RESULT : '; $status =~ s/SCRIPT RESULT\s*:\s*(\S+)/$replace$replace{$1}$replace_1/g; logcomment("status $status"); my $params = NATE::ParamSet->new( global => 1 ); my $MAIL_FROM = $params->get( 'MAIL_FROM', default => '' ); my $MAIL_TO = $params->get( 'MAIL_TO', default => '' ); my $STEST_FILE = $params->get( 'STEST_FILE', default => '' ); my $FILER = $params->get( 'FILER', default => '' ); my $version_details = "NDATE VERSION : $result_struct{'NDATE_VERSION'} NDATE BUILD DATE : $result_struct{'NDATE_BUILD_DATE'} pNATE VERSION : $result_struct{'pNATE_VERSION'} TEST SUITE : $STEST_FILE FILER USED : $original_filers_name MAIN LOG DIRECTORY : $main_log_dir\n"; # MAIN LOG DIRECTORY : $result_struct{TESTLOG}\n"; my $file_na = $original_filers_name; $file_na =~ s/,|\s+/-/g; print "Filer : $file_na "; # $version_details = $version_details." TEST SUITE : $STEST_FILE\n FILER USED : $FILER\n MAIN LOG DIRECTORY : $result_struct{TESTLOG}\n"; # $fail_suite = 1 if((($result_struct{SCRIPT_RESULT}=~/FAILED|FATAL/i)&&($p_parse_id=~/check_filer/i))|| # ($result_struct{'KILL_TEST_SUITE'}=~/YES/i)); $fail_suite = 1 if ( ( $result_struct{SCRIPT_RESULT} =~ /FAILED|FATAL/i ) && ( $p_parse_id =~ /check_filer/i ) ); $fail_suite = 1 if ( ( $result_struct{SCRIPT_RESULT} =~ /FATAL/i ) || ( $result_struct{'KILL_TEST_SUITE'} =~ /YES/i ) ); my ($ndate_ver) = $result_struct{'NDATE_VERSION'} =~ /(\d+\.\d+)/; my $mail_subject = "Test Results : $file_na : $result_struct{SCRIPT_RESULT} : $p_parse_id : NDATE $ndate_ver "; my $mail_body = $version_details . "\n" . $status; # $mail_body = $mail_body."*** Killing the test-suite : $STEST_FILE, because of failure in check_filer_setup" if($fail_suite); $mail_body = "*** STOPPING THE TEST-SUITE : $STEST_FILE, BECAUSE OF THE FAILURES IN THE FILER-SETUP\n\n" . $mail_body if ( $fail_suite == 1 ); if ( $EMAIL !~ /d/i ) { my %mail_params = ( HTML => $mail_body, Text => $mail_body, From => $MAIL_FROM, To => $MAIL_TO, Subject => $mail_subject, ); $mail_params{HTML} = "
$mail_params{Text}<\\HTML>";
                                my $mail = HTML::Mail->new(%mail_params);
                                $mail->send() or logcomment("CONFIG : trouble sending mail");
                            } else {
                                logcomment("EMAIL NOT SENT BECAUSE EMAIL SET TO DEBUG BY USER.");
                            }

                        }

                        #logcomment("status string : $status");
                    }
                }

                logcomment("Writing to log $main_log_dir/$_");
                my $log_kill = "$main_log_dir/$_";
                system("sudo chmod 666 $log_kill");
                open( RES, ">$log_kill" ) || die "Can not open file $log_kill";
                print RES @main_log;
                close RES;
                if ( $fail_suite == 1 ) {
                    if ( ( $flag_system_logs == 1 ) && ( $p_parse_id !~ /check_filer/i ) ) {
                        logcomment("DEBUG : ems_log_generate is calling");
                        ems_log_generate();
                    }
                    logcomment("Process-ID is :: $$");
                    my $process = `ps -ef|grep $$`;
                    foreach ( split( /\n/, $process ) ) {
                        if ( $_ =~ /NDATE/ ) {
                            system("sudo cp -rf $LOGDIR/* $main_log_dir");
                            my ($PPID) = $_ =~ /^\S+\s*\S+\s*(\S+)/;
                            logcomment("Parent process-id is $PPID, Killing the parent Process-ID");
                            system("sudo kill -9 $PPID");
                            sleep 60;
                        }
                    }

                }

            }
        }
    }

}

sub return_curline_num() {
    return $parser::testVarsRef->{"LineNum"};
}

sub trim($) {
    my $curLine = shift @_;
    $curLine =~ s/^\s+//;
    $curLine =~ s/\s+$//;
    $curLine;
}

sub filter($$) {
    logcomment("Inside filter");
    my ( $MAIN, $file_name ) = @_;
    logcomment("FILE ::  $file_name main $MAIN");
    my $list = `ls -lrt $MAIN|grep "$file_name.*\.log"`;
    logcomment("$list");
    my @total_list = split( "\n", $list );
    @total_list = grep { /log$/ } @total_list;
    my @line_list = split( /\s+/, $total_list[-1] );
    print "file name is : $line_list[-1]";
    return ( scalar @total_list, $line_list[-1] );
}

sub highlight {

}