タイムスタンプを抽出して違いを見つける

タイムスタンプを抽出して違いを見つける

以下に示すように、大量のログがあります。

June   5 15:51:56.606  [3997]:   TR#153. State machine - state = CC_STATE_IDLE, event = EVT_ISDN_SETUP
June   5 15:51:56.607  [3997]:   TR#153):  SC registration SUCCESS.
June   5 15:52:00.368  [3997]:   TR#153. DSP:4 Channel:26 Type: Modem State: Data 
June   5 15:52:01.837  [3997]:   TR#153. Receive transaction data: prot 1 data length: 159.-------------------->>
June   5 15:52:02.073  [3997]:   TR#153. Send transaction data: 55 <<-------------------
June   5 15:52:04.361  [3997]:   TR#153):Disconnect initated by 32 process.
June   5 15:52:57.382  [3997]:   TR#153. State machine - state = CC_STATE_IDLE, event = EVT_ISDN_SETUP
June   5 15:52:57.383  [3997]:   TR#153):  SC registration SUCCESS.
June   5 15:53:01.327  [3997]:   TR#153. DSP:4 Channel:26 Type: Modem State: Data 
June   5 15:53:04.291  [3997]:   TR#153. Receive transaction data: prot 1 data length: 347.-------------------->>
June   5 15:53:05.071  [3997]:   TR#153. Send transaction data: 103 <<-------------------
June   5 15:53:06.209  [3997]:   TR#153. Receive transaction data: prot 1 data length: 24.-------------------->>
June   5 15:53:07.239  [3997]:   TR#153):Disconnect initated by 32 process.

私はイベント「EVT_ISDN_SETUP」と「Disconnect」の間の時間差、つまり各トランザクションの持続時間を見つけたいです。そのためには、まず対応する行からタイムスタンプを抽出し、その差を見つける必要があります。私はPerlコードを試しました。ここ1 つのインスタンスの差異を見つけようとしましたが、うまくいきました。私の仕事は、関心のあるイベント間のタイムスタンプを正常に取得し、Perl コードにフィードして、差異を TR#ID とともに印刷することです。

どうすればいいでしょうか?

答え1

仮定: パターンを含むすべての行にEVT_ISDN_SETUPパターンを含む行がありますDisconnect。アルゴリズムを貼り付けます:

  Get the time field for the line matching `EVT_ISDN_SETUP` pattern and put it to temp1 file
  Get the time field for the line matching `Disconnect`pattern and put it to another file say temp2.
  Using paste command put the content of both the files to another file say temp3.
  Read every line of the temp3 and pass first & 2nd field your perl script .

関連情報