|
Each contribution is licensed to you under a License Agreement by its owner, not Microsoft. Microsoft does not guarantee the contribution or purport to grant rights to it.
|
Categories |
Extract Error and Warning Messages from a Backup Exec Log File (Perl)(Community)
Script Code
VBScript
#*******************************************************************************
# Filename: BELogScan.pl
#
# Synopsis: Perl Script that filters error messages from a Backup Exec
# log file into a new text file.
#
# Syntax: BELogScan.vbs InputLog OutputLog
#
# where: InputLog = Name of Backup Exec log to filter.
#
# OutputLog = Name of file to hold error messages.
#
# OutputLog will be created if it does not exist, and new
# records will be appended to it if it does.
#
# Details: Records are filtered to include items with one of the following
# prefixes:
#
# ##WRN##
# ##ERR##
#
# Author: David A. Gray, Chief Wizard
# Simple Soft Services, Inc., d/b/a WizardWrx
# Wizard Wells, Texas, USA.
#
# Date Written: Saturday, 24 December 2005
#
# NOTICE: THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
#
# Copyright: (C) 2005 Simple Soft Services, Inc., d/b/a WizardWrx,
# Wizard Wells, Texas, USA.
# All rights reserved world wide.
#
#*******************************************************************************
# Get arguments.
use integer ; # Save the FPU for when we really need it.
$nargs = @ARGV ;
# Test the command line.
if ( $nargs > 1 ) {
print "BELogScan.vbs Begin\n" ;
# Open input and output files. Complain, but continue, if too many arguments.
$beinplogname = $ARGV [ 0 ] ;
$beoutlogname = $ARGV [ 1 ] ;
warn "Input file: $beinplogname\nOutput file: $beoutlogname\n" ;
if ( $nargs > 2 ) {
warn "Too many arguments - extra arguments ignored\n" ;
}
unless ( open ( IN , "$beinplogname" ) ) {
die "ABORTING: Unable to open input file $beinplogname\a\n" ;
}
unless ( open ( OUT , ">>$beoutlogname" ) ) {
die "ABORTING: Unable to open output file $beoutlogname\a\n" ;
}
# Initialize all counters to zero.
$nrecstot = 0 ;
$nrecslogged = 0 ;
$nwarnings = 0 ;
$nerrors = 0 ;
$nrecsskipped = 0 ;
# Filter the records into the output file.
while ( <IN> ) {
++$nrecstot ;
if ( /^##WRN##/ ) {
++$nwarnings ;
++$nrecslogged ;
print OUT $_ ;
warn "Record $nrecstot is a Warning\n" ;
} else {
if ( /^##ERR##/ ) {
++$nerrors ;
++$nrecslogged ;
print OUT $_ ;
warn "Record $nrecstot is an Error\n" ;
} else {
++$nrecsskipped ;
}
}
if ( $nrecstot % 100 == 0 ) {
warn "$nrecstot records read\n" ;
}
}
# Close file handles and destroy objects.
close IN ;
close OUT ;
# Summarize activity.
print STDERR <<MSG1;
Finished processing of $beinplogname
Warnings logged = $nwarnings
Errors logged = $nerrors
Total Records logged = $nrecslogged
Records skipped = $nrecsskipped
Total records processed = $nrecstot
Output written to $beoutlogname
MSG1
exit ( 0 ) ;
} else {
print STDERR <<MSG2;
BELogScan.vbs InputLog OutputLog
where: InputLog = Name of Backup Exec log to filter.
OutputLog = Name of file to hold error messages.
OutputLog will be created if it does not exist, and new records will be
appended to it if it does.
Please submit a valid command.
MSG2
exit ( 1 ) ;
}
Platforms
For online peer support, join
The Official Scripting Guys Forum!
To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Be the first to create a discussion.
|