Search for specific call in asterisk log files

Posted by chiborg on Server Fault See other posts from Server Fault or by chiborg
Published on 2010-04-21T15:21:25Z Indexed on 2010/04/21 15:23 UTC
Read the original article Hit count: 220

Filed under:
|
|

In my Asterisk log file, I have a line like this (truncated):

Executing [123@mycontext:1] Set("SIP/myhost-b7111840", "__INCOMINGCLI=4711")

Now I want to do the following filtering while looking at the log file with tail -f:

  1. Match lines with a specific value for "INCOMINGCLI", storing the call ID (the "SIP/myhost-b7111840" part)
  2. Output all subsequent lines that contain the call ID.
  3. As a bonus, having a grep-like option like -A would be nice.

I could do that easily in various programming languages, but how would I do it with standard UNIX commands like sed or awk? Can it be done with these commands?

© Server Fault or respective owner

Related posts about asterisk

Related posts about log-files