Hi,
I have a log file that looks like below and I am wanting to know if there is a better way of parsing it from how I am doing it right now.
I am looking for when an application service is OFFLINE and ONLINE. This log file is getting written into every 30 minutes
25_06_2013_01:00
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.mnl1.mnl1_app.svc
1 ONLINE ONLINE mnl1db912
ora.mnl2.mnl2_app.svc
1 ONLINE ONLINE mnl1db911
ora.mnl3.mnl3_app.svc
1 ONLINE ONLINE mnl1db911
2 OFFLINE OFFLINE mnl1db912
3 OFFLINE OFFLINE mnl1db913
...
...
...
25_06_2013_08:30
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.mnl1.mnl1_app.svc
1 ONLINE ONLINE mnl1db912
ora.mnl2.mnl2_app.svc
1 ONLINE ONLINE mnl1db911
ora.mnl3.mnl3_app.svc
1 ONLINE ONLINE mnl1db911
2 ONLINE ONLINE mnl1db912
3 ONLINE ONLINE mnl1db913
From the sample excerpts above, I pass a service to check as the first argument for example, ./x.sh ora.mnl3.mnl3_app.svc which was OFFLINE at 0100 and ONLINE at 0830.
At the moment, what I am doing is reading each line, and checking if they are in the date format or ora.mnl3.mnl3_app.svc, if I found ora.mnl3.mnl3_app.svc, I then check for the next consecutive lines that starts with a white space and check if they have ONLINE or OFFLINE on it. I dontinue on from the start to the end of the log.
Is there any better way of doing this? Any advice much appreciated? Thanks in advance.