How to add custom parameters in CDR from routing

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(Created page with "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'''. ===D...")
 
(In file)
 
(18 intermediate revisions by one user not shown)
Line 1: Line 1:
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'''.
+
If you need to have custom parameters in CDR, they must be set in routing.
  
===Database account===
+
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'''.
  
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.
+
It is assumed that you have set an account in Yate, if you write your CDR in the database.
  
 
===Enable parameters===
 
===Enable parameters===
Line 15: Line 15:
 
===Routing===
 
===Routing===
  
If the routing it is done from regexroute.conf:
+
If the routing it is done from regexroute.conf. Route all calls through sip and set copyparams parameters with your parameters names and their values:
  
^.*$=sip/sip:\0@127.0.0.1;copyparams=name_param1; name_param2
+
^.*$=sip/sip:\0@127.0.0.1;copyparams=name_param1,name_param2;name_param1=value1;name_param2=value2;
  
If you decide to do the routing from an external script the params will be set in message object like this:
+
If you decide to do the routing from an external script, you add this custom params in call.route message when routing the call.
 +
 
 +
You have to install handler for [[call.route]] and add your parameters like this:
  
 
  $m->params["name_param1"] = $value1;
 
  $m->params["name_param1"] = $value1;
Line 25: Line 27:
 
  $m->params["copyparams"] = "name_param1,name_param2";
 
  $m->params["copyparams"] = "name_param1,name_param2";
  
===Write CDR in database===
+
===Write CDR ===
  
To write CDR in the database module register can be used.
+
====In database====
  
 +
To write CDR in the database, module [[register]] can be used.
  
 +
The queries are in PostGreSQL.
 +
 +
You can see [[Register_Database_Schema|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
 +
 +
[default]
 +
;your database account
 +
account=my_pgsql_db
 +
 +
[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}', name_param1='${name_param1}',name_param2='${name_param2}'\
 +
WHERE chan='${chan}' AND billid='${billid}'\
 +
 +
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}'
 +
 +
====In file====
 +
 +
To write CDR in file use [[CDR_File_Module|cdrfile.conf]]:
 +
 +
[general]
 +
file=/var/log/yate-cdr.csv
 +
 +
; comma-separated (.csv)
 +
format=${time},"${billid}","${chan}","${address}","${caller}","${called}",${billtime},${ringtime},${duration},"${direction}","${status}",\
 +
"${reason}","${name_param1}","${name_param2}"
  
  
 
'''See also'''
 
'''See also'''
  
* [[Modules#Database_Drivers|database drivers]]
+
* [[Modules#Database_Drivers|Database drivers]]
 
* [[CDR_Build_Module|cdrbuild module]]
 
* [[CDR_Build_Module|cdrbuild module]]
 
* [[Register|Register module]]
 
* [[Register|Register module]]
* [[]]
+
* [[Regular_expressions|Regexroute module]]
 +
 
 +
[[Category:Routing]] [[Category:Register]] [[Category:Customer parameters]] [[Category:CDR]]

Latest revision as of 16:44, 31 October 2013

If you need to have custom parameters in CDR, they must be set in 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.

It is assumed that you have set an account in Yate, if you write your CDR in the database.

Contents

[edit] Enable parameters

The parameters must be enabled from cdrbuild.conf:

[parameters]
name_param1=true;
name_param2=true;

[edit] Routing

If the routing it is done from regexroute.conf. Route all calls through sip and set copyparams parameters with your parameters names and their values:

^.*$=sip/sip:\0@127.0.0.1;copyparams=name_param1,name_param2;name_param1=value1;name_param2=value2;

If you decide to do the routing from an external script, you add this custom params in call.route message when routing the call.

You have to install handler for call.route and add your parameters like this:

$m->params["name_param1"] = $value1;
$m->params["name_param2"] = $value2;
$m->params["copyparams"] = "name_param1,name_param2";

[edit] Write CDR

[edit] 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

[default]
;your database account
account=my_pgsql_db

[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}', name_param1='${name_param1}',name_param2='${name_param2}'\
WHERE chan='${chan}' AND billid='${billid}'\

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}'

[edit] In file

To write CDR in file use cdrfile.conf:

[general]
file=/var/log/yate-cdr.csv

; comma-separated (.csv)
format=${time},"${billid}","${chan}","${address}","${caller}","${called}",${billtime},${ringtime},${duration},"${direction}","${status}",\
"${reason}","${name_param1}","${name_param2}"


See also

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers