August 07, 2018 ONES Consultants
Introduction
This blog is to introduce some unique fields in Asterisk MySQL CDRs for identifying a call and asterisk instance.
Methodology
Following are the steps required:
Step # 1
Introduce following columns in database table `cdr`:
- ip_address
- call_id
- unique_identifier
ALTER TABLE `cdr` ADD `ip_address` VARCHAR(20) NULL; ALTER TABLE `cdr` ADD `call_id` VARCHAR(200) NULL;
ALTER TABLE `cdr` ADD `unique_identifier` VARCHAR (100) NULL ;
|
Step # 2
Add following section in asterisk file i.e. cdr_mysql.conf. It will
enable the CDR() function to recognize custom fields included in
asterisk MySQL CDRs.
[aliases]
ip_address = ip_address
call_id = call_id
unique_identifier = unique_identifier
|
Step # 3
Following is the dialplan (in file i.e. extensions.conf) to handle custom Asterisk MySQL CDRs.
[default-context]
exten => _X.,1,set(CDR(ip_address)=${SHELL(/sbin/ifconfig | /usr/bin/awk '/inet addr/{print substr($2,6)}' | /bin/grep -v '127.0.0.1' | /usr/bin/head -n1):0:-1})
exten => _X.,n,set(CDR(call_id)=${SIPCALLID})
exten => _X.,n,set(CDR(unique_identifier)=${UNIQUEID})
|
Step # 4
You need to restart asterisk or following commands to apply such changes.
$ /usr/sbin/asterisk -rx "module reload cdr_mysql.so"
$ /usr/sbin/asterisk -rx "dialplan reload"
|
Conclusion:
It is the simplest way to introduce some of custom fields with custom names in existing mysql cdrs of Asterisk.
0 comments:
Post a comment
Please Enter your Comments Here.