[OpenSIPS-Users] How to get call duration (AcctSessionTime ) in OPENSIPS

Bogdan-Andrei Iancu bogdan at voice-system.ro
Mon Aug 16 11:11:29 CEST 2010


Hi Tao,

In such a case, you have two options:

1) generate acc events in DB, use the mysql procedure (that comes with 
opensips CP) to get CDRs and use and external app to upload the CDRs 
from DB to RADIUS

2) use dialog support in opensips to calculate the call duration at BYE 
time -> use aaa_radius module to generate a custom RADIUS ACC request to 
your RADIUS server.

Regards,
Bogdan

Tao Vu Hoang wrote:
> -----Original Message-----
> From: users-bounces at lists.opensips.org [mailto:users-bounces at lists.opensips.org] On Behalf Of Bogdan-Andrei Iancu
> Sent: Tuesday, August 10, 2010 1:17 PM
> To: OpenSIPS users mailling list
> Subject: Re: [OpenSIPS-Users] How to get call duration ( AcctSessionTime ) in OPENSIPS
>
> Hi Tao,
>
> the accounting in opensips is transaction based and not call base -
> which means opensips will generate (for each call) a START and STOP acc
> events (when the call starts and when the call ends).
>
> There is no variable to automatically provide the call duration (as
> there is no call state) - each acc event has its own timestamp, so the
> RADIUS server can calculate the duration based on the INVITE and BYE
> timestamps.
>
> Regards,
> Bogdan
>
>
> Hi Bogdan!
>         I know i can calculate call duration based on INVITE and BYE 
> timestamps , but because i don't control radius ( steel belt radius ) so 
> i have to send
>
> AcctSessionTime = "Call Duration"  ( Because at gateway (PSTN) can send AcctSessionTime ).
>
>     Now i can have "Call Duration" = $Ts ( When i recived BYE )  -   start_time ( i get in table : dialog )
>
>     I get start_time in table dialog by :
> 	When i recived ACK i use avp_db_query to get start_time from table dialog in database :OPENSIPS
> 		avp_db_query("select start_time from dialog where callid='$ci'","$avp(s:time)");
>                  store_dlg_value("starttime","$avp(s:time)"); ===>  it has $dlg_val(starttime) = "start_time"  persistent in dialog
> 	
>          When i recived BYE, I execute : ($Ts - $dlg_val(starttime)) BUT result = NULL   ( $Ts = 1281435253&  $dlg_val(starttime) = 1281436257 )
>
>          I think because $Ts type timestamp not type Interger ==>  But i don't know how to convert type , can someone help me ?
>
>
>
>
>
>
>
>   
>> ----------------------------------------------------------------------
>> Message: 1
>> Date: Tue, 10 Aug 2010 15:57:41 +0300
>> From: Bogdan-Andrei Iancu<bogdan at voice-system.ro>
>> Subject: Re: [OpenSIPS-Users] How to get call duration (
>> 	AcctSessionTime	) in	OPENSIPS
>> To: OpenSIPS users mailling list<users at lists.opensips.org>
>> Message-ID:<4C614CC5.8050906 at voice-system.ro>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Hi Alex,
>>
>> Of course, if you use the dialog support - anyhow, we have a ready patch
>> for acc module to do accounting based on dialog support (directly CDRs).
>>
>> Regards,
>> Bogdan
>>
>> Alex Massover wrote:
>>    
>>     
>>> Hi,
>>>
>>> $DLG_lifetime will not work?
>>>
>>> -----Original Message-----
>>> From: users-bounces at lists.opensips.org [mailto:users-bounces at lists.opensips.org] On Behalf Of Bogdan-Andrei Iancu
>>> Sent: Tuesday, August 10, 2010 1:17 PM
>>> To: OpenSIPS users mailling list
>>> Subject: Re: [OpenSIPS-Users] How to get call duration ( AcctSessionTime ) in OPENSIPS
>>>
>>> Hi Tao,
>>>
>>> the accounting in opensips is transaction based and not call base -
>>> which means opensips will generate (for each call) a START and STOP acc
>>> events (when the call starts and when the call ends).
>>>
>>> There is no variable to automatically provide the call duration (as
>>> there is no call state) - each acc event has its own timestamp, so the
>>> RADIUS server can calculate the duration based on the INVITE and BYE
>>> timestamps.
>>>
>>> Regards,
>>> Bogdan
>>>
>>> Tao Vu Hoang wrote:
>>>
>>>      
>>>       
>>>> Hi All!
>>>>
>>>>       I configure Opensips send Accounting to Steel Belt Radius 4, but i
>>>> can't get call duration time ( AcctSessionTime ) , i don't know variable
>>>> of opensips container call duration time to definition in file :
>>>> opensips.cfg like this :
>>>>               modparam("acc", "aaa_extra",       "User-Name=$Au; \
>>>>                                          Calling-Station-Id=$from; \
>>>>                                          Called-Station-Id=$to; \
>>>>                                          Sip-Translated-Request-URI=$ru; \
>>>>                                          Sip-RPid=$avp(s:rpid); \
>>>>                                          Source-IP=$avp(s:source_ip); \
>>>>                                          Source-Port=$avp(s:source_port); \
>>>>                                          SIP-Proxy-IP=$avp(s:sip_proxy_ip); \
>>>>                                          Canonical-URI=$avp(s:can_uri); \
>>>>
>>>> Billing-Party=$avp(s:billing_party); \
>>>>
>>>> Divert-Reason=$avp(s:divert_reason); \
>>>>                                          User-Agent=$hdr(user-agent); \
>>>>                                          Contact=$hdr(contact); \
>>>>                                          Event=$hdr(event); \
>>>>                                          ENUM-TLD=$avp(s:enum_tld)")
>>>>
>>>>      I use Opensips 1.6.3 to use function :
>>>> get_dialog_info("start_time","$avp(s:starttime)","callid","$ci");
>>>> to get Startime&   Stoptime of one Call from table DIALOG in database
>>>> OPENIPS  but don't success, maybe i don't know how to use it.
>>>>       I also use module : EXEC to get  Starttime&   Stoptime  from
>>>> external cammand but don't success.
>>>> Can someone help me ?  Or recommend me how to get  call duaration
>>>> (AcctSessionTime).
>>>> Thanks a lot.
>>>>
>>>>
>>>>
>>>>
>>>>         


-- 
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
20 - 24 September 2010, Frankfurt, Germany
www.voice-system.ro




More information about the Users mailing list