[asterisk-dev] Some wild thoughts about logging

Atis Lezdins atis at iq-labs.net
Tue Sep 9 14:37:49 CDT 2008


On Tue, Sep 9, 2008 at 9:45 PM, Johan Wilfer <johan at wilfer.se> wrote:
> Atis Lezdins skrev:
>> On Tue, Sep 9, 2008 at 4:22 PM, Russell Bryant <russell at digium.com> wrote:
>>
>>> Johan Wilfer wrote:
>>>
>>>> What if we could tie (almost) every event that got logged to the specific
>>>> call id? Sip history dump, notice's, whatever. Then you could dump it
>>>> into a database, and when
>>>> the customer calls again you could easily find the relevant information
>>>> from the log. As of now I spend some
>>>> amount of time in my /var/asterisk/logs/ comparing call numbers and try
>>>> to understand what my customer did.
>>>>
>>>> Also - you could easily delete info that is too old to be saved and so on.
>>>>
>>>> What do you think? Let's do some brainstorming..
>>>> Is this possible and how can it be implemented?
>>>>
>>> This would absolutely be useful, and has been discussed a number of
>>> times.  The first step is a _huge_ one, and that is to add an argument
>>> to all of the calls to ast_log and ast_verbose to include the relevant
>>> ast_channel if there is one.  Then, logging mechanisms could take
>>> advantage of having access to channel data.
>>>
>>> I guess we could make the API changes in trunk, and then have the mass
>>> conversion be a janitor project ...
>>>
>>>
>>
>> I think trunk has linked_id, so logs can be filtered by that. I
>> currently have dialplan-implemented linked_id which is basically first
>> uniqueid for call. Then a simple script helps me retrieve necessary
>> log:
>>
>> #!/bin/bash
>>
>> 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 -F $1 > /tmp/callid.txt"
>> eval $A
>> cat /tmp/callid.txt | grep -o -P
>> "(?:ERROR|WARNING|VERBOSE|DEBUG)\[([0-9]*)\]" | grep -o "\[[0-9]*\]" |
>> uniq | s
>> A="$LOG_FILE | grep -F -f /tmp/callid_pids.txt > callid_$1.log"
>> eval $A
>>
>> rm /tmp/callid.txt
>> rm /tmp/callid_pids.txt
>>
> Wow. Would this work with 1.4 as well?

Yes. All it needs is:

Set(__call_id=${UNIQUEID})

at initialization of first channel. Then you would want to print that
within each channel that's created and involves dialplan. As i use it
in CDR records, it's anyway in every channel's log.

Then just grep log for this id (get it from CDR) find what PIDs use
it, and then grep for those PIDs. Only disadvantage is that PIDs
sometimes repeat within a day. I expect that it would work basically
the same with linked_id in trunk.

I have also nice web interface showing link to log viewer directly
from call log (which is CDR based, but very CEL like):
http://ftp.iq-labs.net/screenshots/cdr_view.jpg
http://ftp.iq-labs.net/screenshots/log_view.jpg

Btw, i just saw your reply on SIP debug, that's the hardest part, as
it doesn't have any process id's in front. I haven't implemented it in
my log viewer, but i supoose that it can be achieved by using grep's
-A argument.


Regards,
Atis

--
Atis Lezdins,
VoIP Project Manager / Developer,
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