[asterisk-users] CDR: Add Dialed Number Identifierfield (DNID) field into MySQL

Sean Brady sbrady at gtfservices.com
Mon Mar 15 18:48:56 CDT 2010




> I have read 2 solutions....

> (a) Changing the Dial plan and capturing DNID and inserting it into
> one of the existing column in CDR table.

> (b) Copy new CDR related .c & .h files which have added the
> functionality of recording DNID into MySQL.
> For this, CDR table structure needs to be changed and a new field has
> be created in CDR table.

> But I am still not very sure on how to go about doing this.
> Since I only have a production server, I do not have the options of
> experimenting.
> Can someone help with a step-by-step?

> Thx
> Sanjay




>> On Mon, Mar 15, 2010 at 3:08 PM, Lee Archer <Lee.Archer at thebigword.com> wrote:
>> Isn't the use of DNID separate to the userfield?  I'd like to have this
>> working also.
>>
>> Lee
>>
>> -----Original Message-----
>> From: asterisk-users-bounces at lists.digium.com
>> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Alex
>> Balashov
>> Sent: 15 March 2010 08:34
>> To: Asterisk Users Mailing List - Non-Commercial Discussion
>> Subject: Re: [asterisk-users] CDR: Add Dialed Number Identifierfield
>> (DNID) field into MySQL
>>
>> Use the userfield.
>>
>> On 03/15/2010 04:25 AM, RSCL Mumbai wrote:
>>
>>> Hi,
>>>
>>> I would like to see the DNID in my MySQL CDR logs.
>>>
>>> I have read one big thread in the Asterisk Developer List, but I could
>>> not figure out how to implement it ?
>>> Is there a simple step-by-step.


If this is Asterisk 1.6.*, then you can use the adaptive ODBC, which is configured using /etc/asterisk/cdr_adaptive_odbc.conf.  If you compiled Asterisk with samples, you will find a sample file that has pretty much everything that you need.  From there, simply set the fieldname that you wish to write to the CDR, like this:

; Using Adaptive ODBC CDR's, sets the caller ID DNID to the CDR's custom field named "DNID"
Set(CDR(DNID)=${CALLERID(DNID)})

Personally, I like to set the DNID to a variable, just in case, when the inbound call first hits Asterisk from the trunk.  This probably isn't necessary, but I am always afraid that the CALLERID(DNID) value will change with a transfer or a channel redirect, which we use.  From there I write the variable to the CDR.

For more information on the adaptive concept, please see http://www.asterisk.org/node/48492.  There is also more detail from Tilghman Lesher here: http://www.mail-archive.com/asterisk-users@lists.digium.com/msg210573.html

It's very elegant in it's design and it works like a champ- we use it in production.

If you are using Asterisk 1.4.*, you can use the the CDR's userfield. This is an optional, user defined field that can store just about whatever data you wish depending on the data type defined in the database.  You will have to google around to find out more information on how to enable it, although I believe that it's an option in the /etc/asterisk/cdr.conf configuration file that you are using.  

Again, if you are using Asterisk 1.6.* I would strongly recommend that you take advantage of the Adaptive CDR system.  


More information about the asterisk-users mailing list