How to add custom parameters in CDR from routing
To copy parameters from routing in CDR they must be enabled in cdrbuild.conf first and then from routing file they are set in specific parameter called copyparams.
Contents |
Database account
It is assumed that you have set an account in Yate, in mysqldb.conf file or in pgsqldb.conf file to register your users and their CDRs in the database.
Enable parameters
The parameters must be enabled from cdrbuild.conf:
[parameters] name_param1=true; name_param2=true;
Routing
If the routing it is done from regexroute.conf:
^.*$=sip/sip:\0@127.0.0.1;copyparams=name_param1; name_param2
If you decide to do the routing from an external script the params will be set in message object like this:
$m->params["name_param1"] = $value1; $m->params["name_param2"] = $value2; $m->params["copyparams"] = "name_param1,name_param2";
Write CDR in database
To write CDR in the database, module register can be used.
The queries are in PostGreSQL.
You can see an example for cdr table on which you should add your new parameters as you named them ( e.g name_param1, name_param2).
register.conf
[general] call.cdr=yes [call.cdr] initquery=UPDATE cdr SET ended=true WHERE ended IS NULL OR NOT ended cdr_initialize=INSERT INTO cdr VALUES(TIMESTAMP 'EPOCH' + INTERVAL '${time} s','${chan}','${address}','${direction}','${billid}',\ '${caller}','${called}',INTERVAL '${duration} s' ,INTERVAL '${billtime} s',INTERVAL '${ringtime} s','${status}','${reason}',false,\ '${name_param1}', '${name_param2}') cdr_update=UPDATE cdr SET caller='${caller}',called='${called}',duration=INTERVAL '${duration} s',billtime=INTERVAL '${billtime} s',\ ringtime=INTERVAL '${ringtime} s',status='${status}',reason='${reason}' WHERE chan='${chan}' AND billid='${billid}'\ AND name_param1='${name_param1}' AND name_param2='${name_param2}' cdr_finalize=UPDATE cdr SET caller='${caller}', called='${called}', duration=INTERVAL '${duration} s',billtime=INTERVAL '${billtime} s',\ ringtime=INTERVAL,'${ringtime}s',status='${status}',reason='${reason}',ended=true,name_param1='${name_param1}', name_param2='${name_param2}'\ WHERE chan='${chan}' AND billid='${billid}'
See also