#!/usr/software/bin/perl
# $Id: //depot/prod/test/Rsierranevada/storage/hdd/NADQ_SEA/NDATE/SUPPORT_SCRIPTS/post_job.thpl#3 $
# Copyright (c) 2005 Network Appliance, Inc.
# All rights reserved
#
## @summary Mode
## Delete extra log files
## @description
## Delete send_result_to_console.log file
## @param LOGDIR Location of the log file to be deleted
## @param LOGLVL Log level (delete logs if log level is less thsn 4)
## @status public
## @author maji@netapp.com
#use strict;
use Cwd qw(abs_path);
use HTML::Mail;
use NATE::TestInfo;
use San;
use Data::Dumper;
use Net::SCP::Expect;
use Storage::Common_Lib;
sub clean_up_subdir();
my $status;
my $Home = $ENV{HOME};
my $san_obj = new San( \*ntest::NTEST_STDOUT );
if ( $san_obj->error() ) {
logresult( 'FATAL', "Failed to instantiate San object" . $san_obj->errmsg() );
}
########################################
### Initialization/declaration
#########################################
use vars qw(
$LOGLVL
$LOGDIR
$TEST_CONFIG
$RUNPYTH
$PYTHPATH
$AUTO_PUSH
$MAIL_TO
$MAIL_FROM
$RUNID
);
param( 'LOGDIR', '-default', '' );
param( 'LOGLVL', '-default', '2' );
param( 'RUNPYTH', '-default', '2' );
param( 'PYTHPATH', '-default', '/usr/software/bin/python' );
param( 'AUTO_PUSH', '-default', '0' );
param( 'MAIL_TO', '-default', '0' );
param( 'MAIL_FROM', '-default', '0' );
param( 'RUNID', '-default', '0' );
opendir( IMD, $LOGDIR ) || die("Cannot open directory");
logcomment("LOGDIR - $LOGDIR");
my @thefiles = readdir(IMD);
logcomment("Files present in DIR: @thefiles");
my $consolefilename;
closedir(IMD);
my @par_log;
my $mail_subject = "Final LEMUR Test Result : $LOGDIR";
my $mail_body;
foreach my $file (@thefiles) {
my $final_log;
if ( $file =~ /Lemur/ ) {
open( MAIN_LOG, "$LOGDIR" . "/" . "$file" );
$final_log = "$LOGDIR" . "/" . "PARSED_" . "$file";
my @total_data = NDATE version " . $value ."
Build date ". $date ." Log Directory " .$log_dir ."
SCRIPT NAME : " .$test_scp ." LEMUR IMAGE : " .$lemur_img ."
TOTAL TIME TAKEN : ". $tota_time."
SCRIPT RESULT : " .$result. "
LOG FILE : ". $main_file. "
#########################################################
WARNING MESSAGES:
".@warn."
NO_RUN MESSGES:
".@no_run."
FAILURE MESSAGES:
".@fail."
FATAL MESSAGES:
".@fatal."
#########################################################
"; =head ##### my $mail_body = "
NDATE version | $value |
Build date | $date |
Log Directory | $log_dir |
SCRIPT NAME : | $test_scp |
LEMUR IMAGE : | $lemur_img |
TOTAL TIME TAKEN : $tota_time
SCRIPT RESULT : $result
LOG FILE : $main_file
#########################################################
WARNING MESSAGES:
@warn
NO_RUN MESSGES:
@no_run
FAILURE MESSAGES:
@fail
FATAL MESSAGES:
@fatal
#########################################################
"; #### =cut 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 logresult( "CONFIG", "trouble sending mail" ); sub rename_log_file { my $timestamp; $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]; logcomment("time - $timestamp"); return $timestamp; }