dmshawkat
asked on
Script for File Formatting
I need a script( SUN Solaris OS) that would
read certain lines (lines that match with given string) in a text file then , the script would generate a formatted output file (or statistics)
input read file is below.
#BEGIN LOGRECORD number = 133
TYPE = OPERATIONAL
FDN=O%:CCLN-1-CBS1:SBSS-1- SBSS1:SBSC SUBSYSTEM- 1-SBSCSUBS YSTEM11:RO OT-1-ROOT1 :SBS-1-SBS 1:ESBSSHEL F-1-ESBSSH ELF1:ESELE CTORCARD-1 -ESELECTOR CARD5
Event Name: ConsolidatedOMs
Originator OID: 69.2.0.175.1.5
Manager OID: 69.2.0.175.1.5
Event ID: (Type=0xB6, Seq=0x03)
OM Group: SCH Burst Setup
Pegging Type: Node
Application ID: 0
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_2X
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_4X
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_8X
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_16X
The script would read lines that match all three string SBSCSUBSYSTEM24 , ESELECTORCARD1 and OM Group: SCH Burst Setup
then the script would output a formatted file that contain
FwdBurstSetupFailures_8X = 0 ( here it could be zero or any other number)
FwdBurstSetupFailures_16X =0
Thanks
read certain lines (lines that match with given string) in a text file then , the script would generate a formatted output file (or statistics)
input read file is below.
#BEGIN LOGRECORD number = 133
TYPE = OPERATIONAL
FDN=O%:CCLN-1-CBS1:SBSS-1-
Event Name: ConsolidatedOMs
Originator OID: 69.2.0.175.1.5
Manager OID: 69.2.0.175.1.5
Event ID: (Type=0xB6, Seq=0x03)
OM Group: SCH Burst Setup
Pegging Type: Node
Application ID: 0
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_2X
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_4X
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_8X
Performance Data Value: 0
Performance Attribute Name: FwdBurstSetupFailures_16X
The script would read lines that match all three string SBSCSUBSYSTEM24 , ESELECTORCARD1 and OM Group: SCH Burst Setup
then the script would output a formatted file that contain
FwdBurstSetupFailures_8X = 0 ( here it could be zero or any other number)
FwdBurstSetupFailures_16X =0
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This would be:
open my $fh, "<", "ee_12.txt";
$/ = "#BEGIN LOGRECORD ";
my %stats;
while (<$fh>) {
index($_, "SBSCSUBSYSTEM24") < 0 ||
index($_, "ESELECTORCARD1") < 0 ||
index($_, "OM Group: SCH Burst Setup") < 0 and next;
my %failures = reverse m/Performance Data Value: (\d+)\s+Performance Attribute Name: FwdBurstSetupFailures_(\d+
$stats{$_} += $failures{$_} foreach keys %failures;
}
foreach (sort {$a <=> $b} keys %stats) {
print "FwdBurstSetupFailures_${_
}