[SR-Users] Who can tell me how to get the dialog-based CDRs ?

Timo Reimann sr at foo-lounge.de
Wed Dec 21 11:51:25 CET 2011


Hey,


Am 21.12.2011 um 07:03 schrieb sunny_day:
> My object:    get the dialog-based CDRs
>  
> SIP proxy:   kamailio-3.2.0
>  
> My script:
>  
> loadmodule "dialog.so"
> ......
> modparam("dialog","dlg_flag",4)#Must be set to create the dialog associated to an initial request.
> modparam("dialog","db_url","mysql://xxx:xxx@localhost/albert")
> modparam("dialog","table_name","dialog")
> .......
> request_route{
>     if( is_method("INVITE") && !has_totag())
>     {
>            dlg_setflag(4);
>            dlg_var(start_time)=$TS;
>            dlg_var(caller)=$fU;
>            dlg_var(caller)=$tU;
>     } 
>     dlg_manage();
>     ......
>     # dispatch destinations to PSTN
>      route(PSTN);
>     # user location service
>       route(LOCATION);
>       route(RELAY);
> }
> .........
> route[WITHINDLG] {
>      if (has_totag()) {
>              # sequential request withing a dialog should
>              # take the path determined by record-routing
>      if (loose_route()) {
>               if (is_method("BYE")) {
>                     setflag(FLT_ACC); # do accounting ...
>                    setflag(FLT_ACCFAILED); # ... even if the transaction fails
>        
>                    sql_query("cd", "insert into cdr(caller,callee,start_time,duration) values($dlg_var(caller),$dlg_var(callee),$dlg_var(start_time),$DLG_lifetime)", "rd");
>                    sql_result_free("rd");   
>      }
>      if (is_method("ACK")) {
>      route(NATMANAGE); # ACK is forwarded statelessy
>     }
>     route(RELAY);
> }
> ........
>  
>  
> My issue is :
>  
>         The dialog records can be wrritten into the dialog table.  But , the sql_query can not executed. So the cdr table will not get the CDRs.  I don't know why. Who can help me ?
>         This is a simple script for testing. 
> 
>         Any suggestion will be appreciated.
> 
>         Thank you in advance.

It's very hard to help with any Kamailio error unless you provide the actual error message. Whatever the issue is with the sqlops module, Kamailio will tell you, so please tell us.

Until then, I can only speculate what's gone wrong: Did you possibly forget to specify the sqlcon module parameter? You need to setup the MySQL connection parameters in there. See

http://sip-router.org/docbook/sip-router/branch/master/modules_k/sqlops/sqlops.html#id2793249

for sqlcon's documentation and

http://sip-router.org/docbook/sip-router/branch/master/modules_k/sqlops/sqlops.html#id2794430

for the reference regarding sql_query(). Please note how that part states that "the result parameter should normally only be omitted when no result is expected (INSERT, UPDATE, DELETE)" (which is the case in your test script). In consequence, you won't need to free the result set which could be another source of error.


Finally, please note that the dialog module itself is capable of producing CDRs directly from the dialog machinery. It's yet lacking support for direct output to a database (AFAIK), however, so you'd have to post-process the CDR results (which are being written to file as of now) in order to get them persisted into a database.
For some reason, the CDR documentation I wrote seems to have disappeared from the git repository. I'll investigate that further and provide you with a link to the dialog-way-of-creating-CDRs when available (and desired from your side).


HTH,

--Timo


More information about the sr-users mailing list