[OpenSIPS-Users] acc multileg accounting for standard columns and avp_db_query approach

Jayesh Nambiar jayesh.voip at gmail.com
Mon Nov 28 11:57:09 CET 2011


Hi All,
I use failure_routes to failover the calls to multiple carriers. So if 1st
carrier rejects the call, I route it to another carrier for the call to get
completed. Now, I need the accounting of first carrier also in the acc
table. Basically I need to know that this call was rejected from the 1st
carrier and got connected on the second carrier. I am able to insert all
the carrier related details in the acc table using multi-leg info
parameter. But I get stuck on the standard acc columns like sip_code,
sip_reason, to_tag etc.
When the call gets connected on second carrier, the sip_code and sip_reason
for the first row also shows 200 OK when in reality the sip_code and
sip_reason for the first attempt was 503 Service Unavailable. Is it
possible to maintain those standard values also in some variable/AVPs and
insert appropriate values in appropriate rows??

I also tried a different approach of not using acc module and using
avp_db_query for accounting on reply_routes. Basically this will insert a
record for every initial INVITE and all BYEs after a reply for the method
is received. Something like this gives me more control on what is to be
inserted according to my requirements:

if(loose_route()) {
if(is_method("BYE")) {
   t_on_reply("1");
}
   t_relay();
}

if(is_method("INVITE")) {
    <my logic>
    t_on_reply("1");
    t_relay();
}

onreply_route[1] {
   if(status =~ [2-6][0-9][0-9]) {
       avp_db_query("insert into acc (sip_method,
sip_to_tag,sip_callid,sip_code,sip_reason, calling_party, called_party,
source_ip, dst_ip) values ('$rm', '$tt', '$ci', '$rs', '$rr', '$fU',
'$avp(called_party)', '$avp(source_ip)', '$avp(dst_ip)' )");
   }
}
I set the appropriate AVPs like $avp(called_party), $avp(dst_ip) etc after
the initial INVITEs according to my requirements. These are my questions:

1) First and foremost will this method insert proper INVITE and BYE for
accounting purpose?
2) How much roughly will be the penalty on efficiency as compared to using
the acc module?
3) Can AVP module take advantage of parameters like query_buffer_time and
query_flush_time for performance reasons?
4) Can I use prepared_statements while inserting using avp_db_query for
performance reasons?

Any help and suggestions regarding the above queries are very much
appreciated.
Thanks in advance.

--- Jayesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20111128/c92d0df6/attachment-0001.htm>


More information about the Users mailing list