Hi guys
I having problems parsing this file to csv format. 1 Record is composed for different lines and they can have
different amount of lines per record.
It's an output that is variable. Let me try to explain the issues,
with one record:
1.1 Lines that contain "ALARM" sometimes has WCEL-#(WCEL-1) and others no
*** ALARM WBTS-3146 WCEL-1 1.2
next line is the WCEL name "DXB3146". It could be as well alarm description if the line before did not have "WCEL-XX"
1.2
*** ALARM WBTS-3146
next line will be alarm number and description "7653 CELL FAULTY"
The rest of the other lines for this record will be part of the alarm description.
2. Between lines
ALARM and
7653 CELL FAULTY
Sometimes we could have a line with the name of the WBTS . For this record it is DXB3146. In other cases
the WBTS Name does not exist. See this record:
I was able to parse some similar data in the past with a horrible logic, But I can't do it again.
I need advices working with this type of records......Combining alarmsdescription and having flags for
printing at the right time,assigning the line to the wcelname or to alarm description.
dmazzini
GSM System and Telecomm Consultant
I having problems parsing this file to csv format. 1 Record is composed for different lines and they can have
different amount of lines per record.
It's an output that is variable. Let me try to explain the issues,
with one record:
Code:
(25825) DXBRN01 EQUIPM 2007-01-29 10:11:40.62
*** ALARM WBTS-3146 WCEL-1
DXB3146
7653 CELL FAULTY
OBH_QX OMU-1
02 03 01 0702WPAD 01 00
LPA input signal level is too high
1.1 Lines that contain "ALARM" sometimes has WCEL-#(WCEL-1) and others no
*** ALARM WBTS-3146 WCEL-1 1.2
next line is the WCEL name "DXB3146". It could be as well alarm description if the line before did not have "WCEL-XX"
1.2
*** ALARM WBTS-3146
next line will be alarm number and description "7653 CELL FAULTY"
The rest of the other lines for this record will be part of the alarm description.
2. Between lines
ALARM and
7653 CELL FAULTY
Sometimes we could have a line with the name of the WBTS . For this record it is DXB3146. In other cases
the WBTS Name does not exist. See this record:
Code:
(10698) DXBRN01 QUAL 2007-01-03 18:44:17.81
** ALARM WBTS-3011
3117 FAILURE IN SAAL UNI SIGNALLING LINK ACTIVATION
A2SPRB ICSU-2
0047 0001 003E
I was able to parse some similar data in the past with a horrible logic, But I can't do it again.
I need advices working with this type of records......Combining alarmsdescription and having flags for
printing at the right time,assigning the line to the wcelname or to alarm description.
Code:
THIS EXAMPLE DOES not WORK,IT IS OMITTING SOME RECORDS AND LOGIC IS KILLING ME
#!/d/nmsopt/nokianms/bin/perl
@INFO=<DATA>;
filehandles_creation();
foreach $line(@INFO) {
next if $line =~ /^\s*$/;
$line=~ s/^\s+//; $line =~ s/\s+$//;
chomp($line);
# (09394) DXBRN01 EQUIPM 2007-01-17 08:20:55.96
if ($line =~ /(\W+)\s+(\w+)\s+(\w+)\s+(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2}.\d{2})/){
$flagnewalarm =1 and writealarm();
$rncid=$2;
$type=$3;
$date=$4;
$timealarm=$5;
}
#*** ALARM WBTS-3146 WCEL-1
if ($line =~ /(\W+)\s+ALARM\s+WBTS-(\d+)\s+(WCEL-(\d+)|)/){
$class=$1;
$wbts=$2;
$wcel=$3;
if ($wcel =~ /WCEL-/) {
$wcel=~ s/WCEL-//;
}else{
$wcel= "NA";
}
print "CLASS:$1->WBTS-$2->WCEL->$wcel\n";
$wcelnamenext=1;
}
if ( ($line !~ /(\W+)\s+ALARM\s+WBTS-(\d+)\s+(WCEL-(\d+)|)/) and ($wcelnamenext==1)){
if ($wcel eq "NA"){
$wcelname=$line;
$alarmdescription="NA";
$wcelnamenext=0;
print "FOUND WCELNAME:$wcelname\n";
}
if ($wcel ne "NA"){
$wcelname="NA";
$alarmdescription=$line;
$wcelnamenext=0;
print "NOWCELNAMEDESC:$wcelname\n";
}
}
if ($line =~ /(\d{4})\s+(.+)/){
$alarmnumber=$1;
$alarmdescription=$2;
}
$alarmdescription.= "->" .$line if ($flagnewalarm == 0 and $alarmdescription ne "" and $line !~ /(\d{4})\s+(.+)/) and $line !~ /LISTING|COMMAND EXECUTION FAILED|COMMAND EXECUTED|HANDLING COMMAND|ZEOL|PROGRAM VERSION|MML|NO MATCHING|\>|\</;
}
close ZAAOLFILE;
# #################################################################
# Sub filehandles_creation
# #################################################################
sub filehandles_creation{
$zaao_wcel="WCEL_ALARMS.csv";
open ZAAOFILE, ">$zaao_wcel" or die "Can't open $zaao_wcel: $!\n";
print ZAAOFILE "RNCID,WBTS,WCEL,WCELNAME,WBTSNAME,CLASS,TYPE,DATE,TIME,ALARM NUMBER,DESCRIPTION\n";
}
sub writealarm {
if ($flagnewalarm == 1) {
print ZAAOFILE "$rncid,$wbts,$wcel,$wcelname,$class,$type,$date,$timealarm,$alarmnumber,$alarmdescription\n" if ($rncid ne "");
print "$rncid,$wbts,$wcel,$wcelname,$class,$type,$date,$timealarm,$alarmnumber,$alarmdescription\n" if ($rncid ne "");
$sitename=$rncid=$wbtsid=$wcel=$wcelname=$class=$type=$date=$timealarm=$alarmindex=$alarmnumber=$alarmdescription="";
$flagnewalarm=0;
}
}
__DATA__
ZAAO:WCEL;
LOADING PROGRAM VERSION 4.9-0
RNC DXBRN01 2007-01-29 14:18:02
ACTIVE ALARMS
(25400) 6DXBRN01 QUAL 2007-01-23 14:20:30.10
** ALARM WBTS-3019
3117 FAILURE IN SAAL UNI SIGNALLING LINK ACTIVATION
A2SPRB ICSU-4
0043 0001 003E
(25860) 5DXBRN01 EQUIPM 2007-01-29 10:12:37.95
** ALARM WBTS-3018
7401 EXTERNAL AL 1
OBH_QX OMU-1
Power Sytem 1 Load / Battery Disconnected
(25825) 1DXBRN01 EQUIPM 2007-01-29 10:11:40.62
*** ALARM WBTS-3146 WCEL-1
DXB3146
7653 CELL FAULTY
OBH_QX OMU-1
02 03 01 0702WPAD 01 00
LPA input signal level is too high
(11709) 2DXBRN01 EQUIPM 2007-01-27 12:27:59.43
*** ALARM WBTS-3148 WCEL-6
DXB3148
7653 CELL FAULTY
OBH_QX OMU-0
02 04 01 0664WTRB 01 02
WTR RT-Bus fault
(25588) 3DXBRN01 QUAL 2007-01-19 12:46:13.67
** ALARM WBTS-3109 WCEL-7
DXB3109
7761 RNW O&M SCENARIO FAILURE
REZ_QX OMU-0
11 81 13288d FFFF FFFF 0000
(25809) 4DXBRN01 QUAL 2007-01-15 18:34:24.00
** ALARM WBTS-3109 WCEL-8
DXB3109
7771 WCDMA CELL OUT OF USE
REK_QX OMU-0
0080 13288d
NBAP link failure
(25400) DXBRN01 QUAL 2007-01-23 14:20:30.10
** ALARM WBTS-3019
3117 FAILURE IN SAAL UNI SIGNALLING LINK ACTIVATION
A2SPRB ICSU-4
0043 0001 003E
(25825) DXBRN01 EQUIPM 2007-01-29 10:11:40.62
*** ALARM WBTS-3146 WCEL-1
DXB3146
7653 CELL FAULTY
OBH_QX OMU-1
02 03 01 0702WPAD 01 00
LPA input signal level is too high
(11709) DXBRN01 EQUIPM 2007-01-27 12:27:59.43
*** ALARM WBTS-3148 WCEL-2
DXB3148
7653 CELL FAULTY
OBH_QX OMU-0
02 04 01 0664WTRB 01 02
WTR RT-Bus fault
(25829) DXBRN01 EQUIPM 2007-01-29 10:11:50.29
** ALARM WBTS-3010
DXB3010
7410 EXTERNAL AL 10
OBH_QX OMU-1
Rectifier 2 Low Voltage / Symetry Fault
(25831) DXBRN01 EQUIPM 2007-01-29 10:11:51.83
** ALARM WBTS-3010
DXB3010
7407 EXTERNAL AL 7
OBH_QX OMU-1
Rectifier 2 Load / Battery Disconnected
(10698) DXBRN01 QUAL 2007-01-03 18:44:17.81
** ALARM WBTS-3011
3117 FAILURE IN SAAL UNI SIGNALLING LINK ACTIVATION
A2SPRB ICSU-2
0047 0001 003E
(25691) DXBRN01 QUAL 2007-01-20 05:03:06.83
** ALARM WBTS-3012
DXB3012
7761 RNW O&M SCENARIO FAILURE
VEX_Q2 OMU-0
0B 0A 14611d 001D 0001 0048
AAL2 path unblock not accomplished
(25586) DXBRN01 QUAL 2007-01-19 12:43:59.51
** ALARM WBTS-3015
DXB3015
7778 WCDMA BTS DEDICATED MEASUREMENT FAILURE
REK_QX OMU-0
13288d 0002
(25859) DXBRN01 EQUIPM 2007-01-29 10:12:36.41
** ALARM WBTS-3018
DXB3018
7407 EXTERNAL AL 7
OBH_QX OMU-1
Power Sytem 2 Load / Battery Disconnected
(25860) DXBRN01 EQUIPM 2007-01-29 10:12:37.95
** ALARM WBTS-3018
DXB3018
7401 EXTERNAL AL 1
OBH_QX OMU-1
Power Sytem 1 Load / Battery Disconnected
dmazzini
GSM System and Telecomm Consultant