Compare certain lines and determine the difference in time
Posted on 2004-10-22
I have a large file that I need to periodically grep though for certain field. To ensure the transactions are occurring in a timely matter.
The begging of a transaction is marked with “req > 210 :” and the end of a transaction is marked with “** Status :” The key to line up the correct beginning transaction to the correct ending transaction is random number, is maintains the same number through the transaction. Ie
[18/Aug/2004:11:45:00 -0500][24-I] req > 210 :
[18/Aug/2004:11:45:03 -0500][24-I] ** Status :
The key here would be 24-I. There would be other transaction lines in between the these two lines. Because the transaction number may be reused I need to match the first pair, than find the difference in seconds (this case 3) and do X if greater then 1 second.