Hi list - how would I do following.
I've got a file with over 500 blocks like following. I need to parse the file consisting of blocks starting with CLASS end Ending with END. Inside those block is the information I need to extract. For all lines lines inside each block starting with 1: to 11: I need to extract the values inside the " " and put it in one line into a new file.
I did it in a shell script and the script ran for 4,5 hours. So I like to rewrite in perl.
CLASS IM_15004
SELECT
1: ATTR(=,$ENTERPRISE) , VALUE PREFIX, "1.3.6.1.4.1.232" ) ;
2: $SPECIFIC = 15004;
3: ATTR(=, "sysName") ;
4: ATTR(=, "cpqClusterNodeName");
MAP
sub_source = HP_Insight_Manager;
specificTrap = $V2;
severity = FATAL;
hostname=$V3;
hpq_ClusterNodeName = $V4;
hpq_eventID = $V2;
msg = "Cluster Node Failed";
hpq_info = PRINTF ( "Cluster service on %s has failed.", $V4);
END
CLASS IM_15005
SELECT
1: ATTR(=,$ENTERPRISE) , VALUE(PREFIX, "1.3.6.1.4.1.232" ) ;
2: $SPECIFIC = 15005;
3: ATTR(=, "sysName") ;
4: ATTR(=, "cpqClusterResourceName");
MAP
sub_source = HP_Insight_Manager;
specificTrap = $V2;
severity = CRITICAL;
hostname=$V3;
hpq_ClusterResourceName = $V4;
hpq_eventID = $V2;
msg = "Cluster Resource Degraded";
hpq_info = PRINTF ( "Cluster resource %s has become degraded.", $V4);
END
I've got a file with over 500 blocks like following. I need to parse the file consisting of blocks starting with CLASS end Ending with END. Inside those block is the information I need to extract. For all lines lines inside each block starting with 1: to 11: I need to extract the values inside the " " and put it in one line into a new file.
I did it in a shell script and the script ran for 4,5 hours. So I like to rewrite in perl.
CLASS IM_15004
SELECT
1: ATTR(=,$ENTERPRISE) , VALUE PREFIX, "1.3.6.1.4.1.232" ) ;
2: $SPECIFIC = 15004;
3: ATTR(=, "sysName") ;
4: ATTR(=, "cpqClusterNodeName");
MAP
sub_source = HP_Insight_Manager;
specificTrap = $V2;
severity = FATAL;
hostname=$V3;
hpq_ClusterNodeName = $V4;
hpq_eventID = $V2;
msg = "Cluster Node Failed";
hpq_info = PRINTF ( "Cluster service on %s has failed.", $V4);
END
CLASS IM_15005
SELECT
1: ATTR(=,$ENTERPRISE) , VALUE(PREFIX, "1.3.6.1.4.1.232" ) ;
2: $SPECIFIC = 15005;
3: ATTR(=, "sysName") ;
4: ATTR(=, "cpqClusterResourceName");
MAP
sub_source = HP_Insight_Manager;
specificTrap = $V2;
severity = CRITICAL;
hostname=$V3;
hpq_ClusterResourceName = $V4;
hpq_eventID = $V2;
msg = "Cluster Resource Degraded";
hpq_info = PRINTF ( "Cluster resource %s has become degraded.", $V4);
END