I have some log files that are logged in a Unix server by a front end application. These files have all the logging statements that starts with a timestamp value followed by the logging text. An example of how the logging is done in these files is shown below sample :
02 07:31:05.578 logging text........(I bolded the timestamp here because I will use it to explain this timestamp notation below)
02 07:31:05.579 logging text........
02 07:31:05.590 logging text........
02 07:31:05.591 logging text........
02 07:31:05.593 logging text........
Time stamp value explanation -
02 : Date Value (If date is July 02, so the value will be 02)
07 : Hours
31 : Minutes
05 : Seconds
578 : Milliseconds
Note : Kindly ignore if you are looking for the 'YYYY' i.e year field. For simplicity please stick to above format only.
What I have to achieve : I have to find out those exact two consecutive timestamps in a give file that has the maximum difference between them as compared to all other pairs of consecutive timestamps in the given file.
example : If you see above sample of logging text you will see the only pair of consecutive time stamp in the above sample having max difference is 02 07:31:05.579 and 02 07:31:05.590
I am looking for a shell script that I can run on the required file and get the output as the two consecutive timestamps that have the maximum difference.
Why I need it : There are many such log files that I need to monitor for the cases where there is a huge difference between the logging statements. This could potentially help me find out situations like SQL query is waiting for long for the transaction to happen due to locks, API request is not getting the response from the destination etc.
If anyone can also share any other posts to this question or any other efficient way that would be helpful.
Thank you everyone for reading and taking out your time. Please let me know if anymore information is required.