Fetching timestamps from the logs.

Dear Experts,

I need some help to get the time stamps from the Unix logs. Basically I am want to analyze which step is taking more time. Please give me some inputs. Thanks a lot for your help.

I have got different codes for each for phase as we can see in the logs

00002 � UPDT Starting
00008 � UPDT ending
00199 � TPLD Starting
00907 � TPLD Ending

Input:

01182018 095440 Prod TPLD test_system-00199-Information (Z0000001) Begin FastLoad for table Z0000001 on Prod XXXXX5.
01182018 100009 Prod TPLD test_system-00199-Information (Z0000001) FastLoad for table Z0000001 on Prod XXXXX5 completed.
01182018 100010 Prod TPLD test_system-00907-Information (Z0000001) 17403078 records loaded to Z0000001 on Prod XXXXX5.
01182018 101127 Prod TPLD test_system-00902-Information (Z0000001) Finished Temporary Load Phase (Z0000001)
01182018 101324 Prod UPDT test_system-00901-Information (Z0000001) Started Update Phase (Z0000001)
01182018 101332 Prod UPDT test_system-00002-Information (Z0000001) Started OTHER (01) on table sample_table (Prod XXXXX5)
01182018 101336 Prod UPDT test_system-00008-Information (Z0000001) CIH/other_IH92_1.sql script successfull on sample_table table on
Prod XXXXX5
01182018 101340 Prod UPDT test_system-00002-Information (Z0000001) Started OTHER (02) on table sample_table (Prod XXXXX5)
01182018 102530 Prod UPDT test_system-00008-Information (Z0000001) CIH/other_IH92_2.sql script successfull on sample_table table on
Prod XXXXX5
01182018 102626 Prod UPDT test_system-00002-Information (Z0000001) Started INSERT (03) on table sample_table (Prod XXXXX5)
01182018 102959 Prod UPDT test_system-00008-Information (Z0000001) 17403694 record(s) INSERTed (03) into sample_table table on Prod
XXXXX5
01182018 112646 Prod UPDT test_system-00902-Information (Z0000001) Finished Update Phase (Z0000001)

Desired output:

FILE_NBR|PHASE|START_TIME|END_TIME|STEP
Z0000001|TPLD|01182018 095440|01182018 100010|NA
Z0000001|UPDT|01182018 101332|01182018 101336|01
Z0000001|UPDT|01182018 101340|01182018 102530|02
Z0000001|UPDT|01182018 102626|01182018 102959|03

What operating system are you using?

What shell are you using?

What have you tried to solve this problem on your own?

Given that you have two "TPLD Starting" events at the start of your log file (marked above in red) and one "TPLD Ending" event (marked in blue), why are the timestamps on the TPLD activity in your output from the two Starting events instead of the "START_TIME" coming from one of the Starting events and the "END_TIME" coming from the Ending event? If you have two starting events with only one ending event, why did you choose to use the first starting event timestamp instead of the second starting event timestamp? (I.e., if the activity was restarted, why not choose the restart time instead of the time that never completed?)

1 Like

I tried grep the lines for every phase but its becoming a complex program as I had different other phases as well.
I am using Linux and korn shell. Anytime 01182018 100009, 01182018 100010 works for me to know TPLD completion. 01182018 100009 more accurate, since 01182018 100010 has a different code I have choosed.

This doesn't actually tell us what you have tried. Can you post your attempts and output/errors into the thread wrapped in CODE tags please. Then we might be able to make suggestions.

Kind regards,
Robin

In addition to what Robin has already said, you need to explain MUCH more clearly how you want to specify rules that govern the extraction of the start and end times for TPLD events. You gave ambiguous requirements in your first post, but your sample output doesn't even meet those requirements. You say that are are using "a different code that I have choosed (sic)."

I have an awk script that seems to meet your written requirements, but it doesn't work at all in producing your desired output for TPLD transactions; it only produces your desired output for UPDT transactions.

Thanks for looking into it. I have corrected it later. Its my bad. I will try myself and let you know.