Calling and Called numbers in the CDRs

Hi, I have a question about the CDRs module. I activated the cdr-custom module by uncommenting one of the Master.csv lines in /etc/asterisk/cdr_custom.conf.

I’m testing a very simple scenario where a caller dials a DID, that forwards the call then to the callee.

Caller == 201012345678
DID == 201512345678
Callee == 201212345678

Strangely I see in the Master.csv file that the DID keeps popping up in the first few fields, and then the caller and callee numbers only appear in the src and dst channel fields.

Here’s the CDR line I’m talking about:

parallels@parallels-Parallels-Virtual-Platform:~$ tail -1 /var/log/asterisk/cdr-custom/Master.csv
“”“”" <201512345678>“,“201512345678”,“201512345678”,“from-internal”,“PJSIP/201012345678-0000000c”,“PJSIP/mytrunk-0000000d”,“Dial”,“PJSIP/201212345678@mytrunk”,“2023-03-29 03:10:03”,”“,“2023-03-29 03:10:09”,“6”,“0”,“BUSY”,“DOCUMENTATION”,”“,“1680052203.16”,”",12

Strangely the first field is empty, although it should be the clid field according to the configuration file (I didn’t change it by the way:

Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration,f)})},${CSV_QUOTE(${CDR(billsec,f)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)}

Can someone help me do the following please:

  1. Show the Caller number in one field
  2. Show the DID number in another field
  3. Show the Callee number in a third field
  4. Show the trunk contact IP address in different fields (one for the incoming call and another for the outgoing call)

Thank you in advance.

parallels@parallels-Parallels-Virtual-Platform:~$ tail -1 /var/log/asterisk/cdr-custom/Master.csv 
""""" <201512345678>","201512345678","201512345678","from-internal","PJSIP/201012345678-0000000c","PJSIP/mytrunk-0000000d","Dial","PJSIP/201212345678@mytrunk","2023-03-29 03:10:03","","2023-03-29 03:10:09","6","0","BUSY","DOCUMENTATION","","1680052203.16","",12

DID is into a concept defined by SIP, or by Asterisk. Although it really stands for direct in dialing, although is often used to refer to the number the provider received from the PSTN. You, however, appear to be using it in relation to an outgoing call. As it is Direct IN Dialing, it has no meaning for an outgoing call.

I have seen it misused to refer to account used to make an outgoing call.

So the first thing you need to do is explain what you mean by DID, preferably in SIP terms.

Really we need to see your dialpan, as, with typical dial plans the dst field would be similar to the number in the dial string, and also the endpoint definition for 201012345678, as that could also be setting the caller ID, as could the phone, itself.

Hi David, apologies I couldn’t respond to this earlier.

The DID concept you mentioned is correct, it’s normally used for inward calling where the caller doesn’t really know where the call is ultimately going to, and it’s usually a seemingly local number so that the caller isn’t charged an international call (if the callee is overseas).

Now this is out of the way, I’ll try to explain what I’m trying to achieve on my Asterisk box.

I have a few DIDs from a DID provider, which are all configured to send/terminate the calls onto my Asterisk box.

I have a MySQL database on the Asterisk box that contains a mapping between some of those DIDs and the actual “far end” numbers I want to dial out the calls to.

So basically, my Asterisk box is acting as a call forwarding agent. Someone dials one of my DIDs, the call reaches my Asterisk box, and it then gets forwarded to the real B-number which is outside my network (so it’s another SIP leg).

What I was asking about in my initial case, was how I could show all these numbers in the CDRs. I was able to achieve this by creating a new CDR variable in the dialplan, and referencing this in my CDR conf file.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.