[Kamailio-Users] ACC module issue logging Reason: SIP header in missed_calls

Daniel-Constantin Mierla miconda at gmail.com
Thu Nov 20 17:58:47 CET 2008


Hello,

On 11/20/08 15:46, sergejf wrote:
> Hello Daniel,
>
> Thank you for your response. So if I understand well we should enable avp's
> in the onreply route:
>
> -  modparam("tm", "onreply_avp_mode", 1)
>
> reference the avp in the ACC db_extra:
>
> - modparam("acc", "db_extra",
> "from_uri=$fu;to_uri=$tu;request_uri=$ru;cause=$avp(i:25)") 
>
> and store the Reason: header in the avp used in conjunction with the ACC
> module:
>
> - $avp(i:25) = hdr(Reason);
>
>   
yes, this is one way to go.

> Would that work or do we need to store the Reason: header directly in the
> missed_calls table, bypassing the ACC module?
acc will do it if you configure as above.

Cheers,
Daniel

>  What functionality would we
> need to use in order to do that and is there any risk that ACC may overwrite
> the cause field in missed_calls after we store the Reason: header?
>
> Thanks in advance for shedding some light on that topic.
>
> Best Regards,
>
> Serge
>
>
> miconda wrote:
>   
>> Hello,
>>
>> the acc uses the SIP request to get the attributes for logging.
>>
>> It is why you get it for BYE (a sip request) and not for failed calls 
>> where the header is in reply.
>>
>> Anyhow, there are couple of solutions to get it:
>> - store the header in an avp (in route for BYE and in onreply_route for 
>> replies) and set tm parameter:
>> http://kamailio.org/docs/modules/1.4.x/tm.html#id2506328
>>
>> - if you don't have parallel forking, then you can use $var(...) instead 
>> of avp (a bit faster)
>>
>> Cheers,
>> Daniel
>>
>> On 11/19/08 01:07, sergejf wrote:
>>     
>>> We are trying to configure the ACC module to log the Reason: header found
>>> in
>>> SIP BYE and SIP 4xx messages sent by US carriers when making calls to the
>>> PSTN. 
>>>
>>> We have added a cause field (the Reason header contains the Q.850 cause
>>> code
>>> associated with telephony events, typically disconnect) to the acc and
>>> missed_calls tables (see tables description further below) and changed
>>> opensips.cfg to read that header and store it:
>>>
>>> modparam("acc", "db_flag", 2)
>>> modparam("acc", "db_missed_flag", 3)
>>> modparam("acc", "db_url", "mysql://root:password@localhost/opensips")
>>> modparam("acc", "db_extra",
>>> "from_uri=$fu;to_uri=$tu;request_uri=$ru;cause=$(hdr(Reason))")
>>>
>>> This works quite nicely for calls logged in the acc table, such as:
>>>
>>> mysql> select * from acc where date(time) = curdate() and (cause like
>>> '%850%') limit 1;
>>> +---------+--------+---------------+-----------------------+-----------------------------------------------------+----------+------------+---------------------+---------------------------------+---------------------------------+-----------------------------------+----------------+
>>> | id      | method | from_tag      | to_tag                | callid                                             
>>> | sip_code | sip_reason | time                | from_uri                       
>>> | to_uri                          | request_uri                       |
>>> cause          |
>>> +---------+--------+---------------+-----------------------+-----------------------------------------------------+----------+------------+---------------------+---------------------------------+---------------------------------+-----------------------------------+----------------+
>>> | 1903785 | BYE    | 627B7414-1509 | telstage-3e5-492294f9 |
>>> 492294f9-0127-00105838-0657a1e7-22e4c653 at 88.88.88.88 | 200      | Ok        
>>> | 2008-11-18 05:12:55 | sip:+5599999999 at 99.99.99.99 |
>>> sip:+15555555555 at 88.88.88.88:5060 | sip:88.88.88.88:5060;transport=udp |
>>> Q.850;cause=16 |
>>> +---------+--------+---------------+-----------------------+-----------------------------------------------------+----------+------------+---------------------+---------------------------------+---------------------------------+-----------------------------------+----------------+
>>> 1 row in set (1.58 sec)
>>>
>>> The cause field contains "Q.850;cause=16" taken from the Reason: header. 
>>>
>>> However, the same Reason: header is NOT logged for calls found in the
>>> missed_calls table:
>>>
>>> mysql> select * from missed_calls where date(time) = curdate() and
>>> sip_code
>>> = 480 limit 1;
>>> +---------+--------+------------------------+--------------+-----------------------------------------------------+----------+---------------------------+---------------------+---------------------------------+---------------------------------+---------------------------------+-------+
>>> | id      | method | from_tag               | to_tag       | callid                                             
>>> | sip_code | sip_reason                | time                | from_uri                       
>>> | to_uri                          | request_uri                     |
>>> cause
>>> |
>>> +---------+--------+------------------------+--------------+-----------------------------------------------------+----------+---------------------------+---------------------+---------------------------------+---------------------------------+---------------------------------+-------+
>>> | 1231364 | INVITE | telstage-5d06-492293b5 | 627682C8-40F |
>>> 492293b5-0154-0013be65-6d9882a2-bafcf3d3 at 88.88.88.88 | 480      |
>>> Temporarily Not Available | 2008-11-18 05:06:51 |
>>> sip:+15555555555 at 88.88.88.88:5060 | sip:+5599999999 at 63.63.63.63 |
>>> sip:69085599999999 at 200.0.0.0 |       |
>>> +---------+--------+------------------------+--------------+-----------------------------------------------------+----------+---------------------------+---------------------+---------------------------------+---------------------------------+---------------------------------+-------+
>>> 1 row in set (1.09 sec)
>>>
>>> Note that the cause field is empty, while the OpenSIPS logs clearly show
>>> a
>>> Reason: header present in the SIP 480 message:
>>>
>>> Nov 18 05:06:51 sip100 /usr/local/sbin/opensips[20355]:
>>> TRACE:ONREPLY_ROUTE:
>>> src(200.0.0.0:5060) dst(63.63.63.63:5060) msg(SIP/2.0 480 Temporarily Not
>>> Available^M Via: SIP/2.0/UDP
>>> 63.63.63.63;branch=z9hG4bK96cf.a009bc13.0,SIP/2.0/UDP
>>> 88.88.88.88:5060;branch=z9hG4bK492293b5-0154-0013be66-6d9882a2-bafcf3d3^M
>>> From: <sip:+15555555555 at 88.88.88.88:5060>;tag=telstage-5d06-492293b5^M
>>> To:
>>> sip:+5599999999 at 63.63.63.63;tag=627682C8-40F^M Date: Tue, 18 Nov 2008
>>> 10:06:45 GMT^M Call-ID:
>>> 492293b5-0154-0013be65-6d9882a2-bafcf3d3 at 88.88.88.88^M Server:
>>> Cisco-SIPGateway/IOS-12.x^M CSeq: 13960 INVITE^M Allow-Events:
>>> telephone-event^M Reason: Q.850;cause=18^M Content-Length: 0^M ^M )
>>>
>>> Is this a bug from the ACC module or a limitation, i.e. SIP 4xx messages
>>> are
>>> not handled in the same way as the BYE messages in the acc table?
>>>
>>> Any advice would be most appreciated!!
>>>
>>> Serge
>>>
>>> PS: here are the schemas we're using for the acc and missed_calls tables:
>>>
>>> mysql> describe acc;
>>> +-------------+------------------+------+-----+---------+----------------+
>>> | Field       | Type             | Null | Key | Default | Extra         
>>> |
>>> +-------------+------------------+------+-----+---------+----------------+
>>> | id          | int(10) unsigned | NO   | PRI | NULL    | auto_increment
>>> |
>>> | method      | varchar(16)      | NO   |     |         |               
>>> |
>>> | from_tag    | varchar(64)      | NO   |     |         |               
>>> |
>>> | to_tag      | varchar(64)      | NO   |     |         |               
>>> |
>>> | callid      | varchar(64)      | NO   | MUL |         |               
>>> |
>>> | sip_code    | varchar(3)       | NO   |     |         |               
>>> |
>>> | sip_reason  | varchar(32)      | NO   |     |         |               
>>> |
>>> | time        | datetime         | NO   |     |         |               
>>> |
>>> | from_uri    | varchar(64)      | NO   |     |         |               
>>> |
>>> | to_uri      | varchar(64)      | NO   |     |         |               
>>> |
>>> | request_uri | varchar(64)      | NO   |     |         |               
>>> |
>>> | cause       | varchar(60)      | YES  |     | NULL    |               
>>> |
>>> +-------------+------------------+------+-----+---------+----------------+
>>> 12 rows in set (0.00 sec)
>>>
>>> mysql> describe missed_calls;
>>> +-------------+------------------+------+-----+---------+----------------+
>>> | Field       | Type             | Null | Key | Default | Extra         
>>> |
>>> +-------------+------------------+------+-----+---------+----------------+
>>> | id          | int(10) unsigned | NO   | PRI | NULL    | auto_increment
>>> |
>>> | method      | varchar(16)      | NO   |     |         |               
>>> |
>>> | from_tag    | varchar(64)      | NO   |     |         |               
>>> |
>>> | to_tag      | varchar(64)      | NO   |     |         |               
>>> |
>>> | callid      | varchar(64)      | NO   | MUL |         |               
>>> |
>>> | sip_code    | varchar(3)       | NO   |     |         |               
>>> |
>>> | sip_reason  | varchar(32)      | NO   |     |         |               
>>> |
>>> | time        | datetime         | NO   |     |         |               
>>> |
>>> | from_uri    | varchar(64)      | NO   |     |         |               
>>> |
>>> | to_uri      | varchar(64)      | NO   |     |         |               
>>> |
>>> | request_uri | varchar(64)      | NO   |     |         |               
>>> |
>>> | cause       | varchar(60)      | YES  |     | NULL    |               
>>> |
>>> +-------------+------------------+------+-----+---------+----------------+
>>> 12 rows in set (0.00 sec)
>>>
>>>   
>>>       
>> -- 
>> Daniel-Constantin Mierla
>> http://www.asipto.com
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.kamailio.org
>> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
>>
>>
>>     
>
>   

-- 
Daniel-Constantin Mierla
http://www.asipto.com





More information about the Users mailing list