[asterisk-dev] asterisk log file analyses

Atis Lezdins atis at iq-labs.net
Thu Nov 12 12:28:19 CST 2009


On Thu, Nov 12, 2009 at 6:48 PM, Wolfgang Pichler <wpichler at yosd.at> wrote:
> Hello all,
>
> i am interested in a system for analysing asterisk log files
> (especialy the full log file). I think it would be perfect to have a
> small app which can pull out all log file lines which are related to a
> specific call.
>
> Or lets say - a web application - where you can select a time frame -
> it does display you all the calls which have been in this time frame -
> you do select a call - it does display you the complete log for only
> this call.
>
> I do remember that there was a discussion on this list before about
> the possibility to turn logging only on for specific calls... What
> happend to this idea ?
>
> What do you think - would an app like this be useful for others, or is
> it only me who like to have something like this ?
>
> One user question - how can i remove the color sequences so i can see
> my log again without all the ESC sequences with tail ?
>

Hi Wolfgang,

I'm currently doing more or less the same with the following:

Assign each call unique id, which is used at least once per thread
(for call level variables), for example:

macro init_channel() {
  if ("${call_id}" = "") {
    Set(__call_id=${UNIQUEID});
    NoOp(Initializing call_id to ${call_id});
  } else {
    NoOp(Call id already set to ${call_id});
  }
  ...

So, i call this macro every time call can change threads (transfer,
etc). This is supposed to be replaced with linked-id somewhere in
trunk.

Then just grep for all threads that output needed call id:

if [ "$1" == "" ]; then
  echo "Usage: fetch.sh <call_id>"
  exit 1;
fi

if [ "$2" == "" ]; then
LOG_FILE="cat /var/log/asterisk/full"
else
LOG_FILE="cat /var/log/asterisk/full.$2.gz | gunzip"
fi

A="$LOG_FILE | grep $1 > /tmp/callid.txt"
eval $A
cat /tmp/callid.txt | grep -o -P
"(?:ERROR|WARNING|VERBOSE|DEBUG)\[([0-9]*)\]" | grep -o "\[[0-9]*\]" |
uniq | sort | uniq > /tmp/callid_pids.txt
A="$LOG_FILE | grep -F -f /tmp/callid_pids.txt > callid_$1.log"
eval $A



-- 
Atis Lezdins,
VoIP Project Manager / Developer,
IQ Labs Inc,
atis at iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835



More information about the asterisk-dev mailing list