as of now i am using this below code
awk -F'[=|"|<|>|,]' '{for(i=1;i<=NF;i++){
if($i=="Alert id") {
if(id!="")
if(dt!="" && fx == "false"){ printf "NAME=%s\nFIXED=%s\nDATE=%s\nAlDefID=%d\nResId=%d\nReason=%s\n\n", nm,fx,dt,alDFid,rId,reson; }
id=($i=="Alert id")?$(i+2):id; }
nm=($i==" name")?$(i+2):nm;
fx=($i==" fixed")?$(i+2):fx;
dt=($i~/^ [0-9]+-/)?$i" "$(i+1):dt;
alDFid=($i==" alertDefinitionId")?$(i+2):alDFid;
rId=($i==" resourceId")?$(i+2):rId;
reson=($i==" reason")?$(i+2):reson;
}
}END{
if(dt!="" && fx == "false"){
printf "NAME=%s\nFIXED=%s\nDATE=%s\nAlDefID=%d\nResId=%d\nReason=%s\n", nm,fx,dt,alDFid,rId,reson;
}
}' alerts.xml >alertsExtracted.txt
but it is failing to display complete string for below inputs for REASON field
<Alert id="10615" name="Turret-IQ/MAX-101001-NotAvailable-P" alertDefinitionId="17473" resourceId="11720" ctime="1362464100000" fixed="false" reason="If Availability != 100.0% (actual value = 0.0%)">
</Alert>
<Alert id="10602" name="APP-MS-lib_license_common-150040-licenseSchemaTampered-S" alertDefinitionId="16315" resourceId="11424" ctime="1362398245776" fixed="false" reason="If Event/Log Level(ANY) and matching substring "licenseSchemaTampered" Log: : 3 days, 1:57:16.57, 1.3.6.1.4.1.1453.4.9.1.3.0.1, License Entity Tampered., SET License Entity Tampered : 2003,, licenseSchemaTampered, 2013-03-04,06:57:25.7,--5:0, HIGH, , License Entity Tampered due to change of value(s AND Event/Log Level(ANY) and matching substring "HIGH" Log: : 3 days, 1:57:16.57, 1.3.6.1.4.1.1453.4.9.1.3.0.1, License Entity Tampered., SET License Entity Tampered : 2003,, licenseSchemaTampered, 2013-03-04,06:57:25.7,--5:0, HIGH, , License Entity Tampered due to change of value(s AND Event/Log Level(ANY) and matching substring "lib_license_common" Log: : 3 days, 1:57:16.57, 1.3.6.1.4.1.1453.4.9.1.3.0.1, License Entity Tampered., SET License Entity Tampered : 2003,, licenseSchemaTampered, 2013-03-04,06:57:25.7,--5:0, HIGH, 10.19.123.105, License Entity Tampered due to change of value(s"/>
the output is coming as
NAME=APP-MS-lib_license_common-150040-licenseSchemaTampered-S
FIXED=false
DATE= 2013-03-04 06:57:25.7
Description= License Entity Tampered.
PRIORITY=HIGH
RESOURCE NAME=-pri-105
Reason=If Event/Log Level(ANY) and matching substring "licenseSchemaTampered" Log: : 3 days
NAME=CCM-Platform-106006-LinuxServerLostConnection-P
FIXED=false
DATE= 2013-03-04 06:47:25.7
Description= Linux Server lost connection (missed one polling) Resolution hint: Check network connection
PRIORITY=MED
RESOURCE NAME=204
Reason=If Availability < 100.0% (actual value
i am interested in the modification of only Reason field to provide complete output as below
NAME=APP-MS-lib_license_common-150040-licenseSchemaTampered-S
FIXED=false
DATE= 2013-03-04 06:57:25.7
Description= License Entity Tampered. PRIORITY=HIGH
RESOURCE NAME=-pri-105
Reason=If Event/Log Level(ANY) and matching substring "licenseSchemaTampered" Log: : 3 days
NAME=CCM-Platform-106006-LinuxServerLostConnection-P
FIXED=false
DATE= 2013-03-04 06:47:25.7
Description= Linux Server lost connection (missed one polling) Resolution hint: Check network connection
PRIORITY=MED
RESOURCE NAME=204
Reason=If Availability != 100.0% (actual value = 0.0%)
is it possible?