Summary:ASTERISK-09294: updatecdr in agents.conf is not working
Reporter:Rob M (nyt)Labels:
Date Opened:2007-04-21 05:50:02Date Closed:2011-06-07 14:07:25
Versions:Frequency of
Environment:Attachments:( 0) 9573.patch
Description:Apparently there were changes made to the way cdr functions (I noticed the changes took affect when I upgraded around Dec 12 2006).

with updatecdr enabled, this is how it used to look:
(3XXX are SIP IDs, 4XXX are agent IDs.  My test agent is 4198)

4198         (test agent) available at '3198@queue' (musiconhold is 'default')

""Agent Name Edited" <4129>","4129","EDITEDNUMBER","internal-real","SIP/3046-68c3","Zap/1-1"
,"Dial","Zap/g1/EDITEDNUMBER||WT","2006-04-08 21:28:38","2006-04-08 21:29:07","2006-04-08 2

Now, with updatecdr enabled still (it changes the callerid name from what sip specifies, to the agent name now, but nothing else)

""test agent" <3198>","3198","4116","internal-real","SIP/3198-082bfdb8","","VoiceMail","4116|u","2007-04-21 03:24:51","2007-04-21 03:24:51","2007-04-21 03:24:52","1","1","ANSWERED","DOCUMENTATION","","1177151091.17",""


Logged in as agent 4198, sip id 3198

fmtpbx:~/asterisk/asterisk-1.4-svn# grep updatecdr /etc/asterisk/agents.conf
; Define updatecdr. This is whether or not to change the source

exten => _X.,10,Set(CIDNUM=${AGENTBYCALLERID_${CALLERID(num)}})
exten => _X.,n,NoOp(${CDR(src)})
exten => _X.,n,Set(CALLERID(num)=${CIDNUM})
exten => _X.,n,resetCDR
exten => _X.,n,NoOp(${CDR(src)})

   -- Executing [4116@internal:10] Set("SIP/3198-082c4630", "CIDNUM=4198") in new stack
   -- Executing [4116@internal:11] NoOp("SIP/3198-082c4630", "3198") in new stack
   -- Executing [4116@internal:12] Set("SIP/3198-082c4630", "CALLERID(num)=4198") in new stack
   -- Executing [4116@internal:13] ResetCDR("SIP/3198-082c4630", "") in new stack
   -- Executing [4116@internal:14] NoOp("SIP/3198-082c4630", "3198") in new stack
Comments:By: Rob M (nyt) 2007-05-04 11:20:04

Is there any update on this?  This breaks a lot of call tracking.

By: Steve Murphy (murf) 2007-05-17 14:04:39


There's been a lot of CDR activity in 1.4 since 1.4.2; could you perhaps
try the current svn version of 1.4, and see if the problem remains?

If so, I will try to duplicate the problem here and get it fixed.

By: Rob M (nyt) 2007-05-17 15:09:49

from SVN compiled this morning... same problem

""test agent" <3198>","3198","71516EDITEDIT","internal-real","SIP/3198-08299710","Zap/1-1","Dial","Zap/g1/151EDITEDIT||WT","2007-05-17 13:06:04","2007-05-17 13:06:19","2007-05-17 13:06:21","17","2","ANSWERED","DOCUMENTATION","","1179432364.1040","4198"

fmtpbx:~/asterisk/asterisk-1.4-svntest# grep updatecdr /etc/asterisk/agents.conf
; Define updatecdr. This is whether or not to change the source

By: Rob M (nyt) 2007-05-17 15:45:44

testing again with 64818... samep roblem.

""test agent" <3198>","3198","7151EDITEDIT","internal-real","SIP/3198-082bdfc8","Zap/1-1","Dial","Zap/g1/151EDITEDIT||WT","2007-05-17 13:44:48","2007-05-17 13:45:03","2007-05-17 13:45:06","18","3","ANSWERED","DOCUMENTATION","","1179434688.5","4198"

By: Eliel Sardanons (eliel) 2007-05-17 16:50:01

If I'm not wrong in 1.4 trunk updatecdr only change the chan->cdr->channel so it only changes the srcchannel of the CDR!.
And is only changed when you use AgentMonitorOutgoing(c) application to monitor with the 'c' option AND When the user logs in...
This are the only to places that chan_agent changes somthing with the updatecdr option.
Please tell me in wich version worked like you say. We can change the CallerID using the Dialplan and the srcchannel (channel) using AgentMonitorOutgoing but nothing else.

By: Steve Murphy (murf) 2007-05-17 16:50:20

OK, I **think** I know what might be happening. But to reproduce what you are doing, I'm going to need your extensions.conf, relevant config files, etc, so I can replicate the problem, and prove the fix... is this possible?

By: Rob M (nyt) 2007-05-17 17:11:09

This previously worked in 1.2.

The config files are basic.  Any outgoing call made from an agent logged in with agentcallbacklogin would have it updated in the cdr.  I've been using the CDR(userfield) to track outgoing agent calls since this broke.  All agents login from SIP phones and dial out over zap channels.

in 1.2 it looked like this:
clid, src, dst, channel
| "random agent" <4122>   | 4122       | 71EDITEDIT | SIP/3048-9b18    
now it comes out like this:
| "random agent" <3048>   | 3048       | 71EDITEDIT | SIP/3048-0830ee48    

Here is the outgoing pieces from the context these are in.

exten => _X.,1,Set(CALLEDEXTEN=${EXTEN})
exten => _X.,n,GotoIf($["${AGENTBYCALLERID_${CALLERID(num)}}" != ""]?10)
exten => _X.,n,Goto(internal-real,${CALLEDEXTEN},1)
exten => _X.,10,Set(CIDNUM=${AGENTBYCALLERID_${CALLERID(num)}})
exten => _X.,n,Set(CALLERID(name)=${AGENT(${CIDNUM}:name)})
exten => _X.,n,Set(CALLERID(number)=${CIDNUM})
exten => _X.,n,Set(CDR(userfield)=${CIDNUM})
exten => _X.,n,Goto(internal-real,${CALLEDEXTEN},1)

exten => _91NXXNXXXXXX,1,Dial(Zap/g1/${EXTEN:1},,WT)
exten => _91NXXNXXXXXX,2,Hangup
exten => _71NXXNXXXXXX,1,Dial(Zap/g1/${EXTEN:1},,WT)
exten => _71NXXNXXXXXX,2,Hangup

By: Rob M (nyt) 2007-05-20 19:24:09

Was that enough or was there anything else you needed?

By: Rob M (nyt) 2007-06-05 00:47:28

I tried this with r67073 and the issue persists...

By: Joshua C. Colp (jcolp) 2007-06-25 09:54:06

I have located the issue, but due to the changed CDR system really have no idea how to change it so I've emailed murf (who is the one who changed the CDR system) telling him what the problem is and seeing what we can change. The actual issue is that the changed CDR system does some merging of CDRs to give an end result, and in some scenarios this yields the altered CDR with an Agent/agent_id channel name discarded and not used.

By: Steve Murphy (murf) 2007-06-28 15:33:44

Hmmm. In a day or two, I'll get my license approved, I hope. Then you'll be able to upload my patch to cdr.c in 1.4, and tell me if it solves your problem. I can then merge it into 1.4 and make you smile!

By: Steve Murphy (murf) 2007-07-05 15:55:40

OK, guys, look like my license is good to go now, so please try applying the
patch, and let me know if it solves the problem.

By: Rob M (nyt) 2007-07-05 18:11:06

Applied patch to latest svn cleanly and rebuilt without errors.  I'll have to wait for a dead moment on the pbx to restart asterisk and test functionality.  I will post another update then.

Thanks for the patch!

By: Rob M (nyt) 2007-07-06 08:57:56

I have applied your patch to rev 73586.  It does not appear to work.

Here is the output from my cdr log, none of the information has been updated (from 3198 -> 4198, and the src channel is sip instead of agent)

""test agent" <3198>","3198","715162488400","internal-real","SIP/3198-082a1750","Zap/1-1","Dial","Zap/g1/15162488400||WT","2007-07-06 07:10:16","2007-07-06 07:10:32","2007-07-06 07:10:34","18","2","ANSWERED","DOCUMENTATION","","1183731016.243","4198"

4198         (test agent) available at '3198@queue' (musiconhold is 'default')

fmtpbx:~/asterisk/asterisk-1.4-svn# svn diff main/cdr.c
Index: main/cdr.c
--- main/cdr.c  (revision 73586)
+++ main/cdr.c  (working copy)
@@ -616,12 +616,16 @@
               ast_copy_string(to->dcontext, from->dcontext, sizeof(to->dcontext));
               from->dcontext[0] = 0; /* theft */
-       if (ast_strlen_zero(to->dstchannel) && !ast_strlen_zero(from->dstchannel)) {
+       if (strncasecmp(from->dstchannel,"Agent/",6) == 0) {
               ast_copy_string(to->dstchannel, from->dstchannel, sizeof(to->dstchannel));
+       } else if (ast_strlen_zero(to->dstchannel) && !ast_strlen_zero(from->dstchannel)) {
+               ast_copy_string(to->dstchannel, from->dstchannel, sizeof(to->dstchannel));
               from->dstchannel[0] = 0; /* theft */
-       if (ast_strlen_zero(to->channel) && !ast_strlen_zero(from->channel)) {
+       if (strncasecmp(from->channel,"Agent/",6) == 0) {
               ast_copy_string(to->channel, from->channel, sizeof(to->channel));
+       } else if (ast_strlen_zero(to->channel) && !ast_strlen_zero(from->channel)) {
+               ast_copy_string(to->channel, from->channel, sizeof(to->channel));
               from->channel[0] = 0; /* theft */
       if (ast_strlen_zero(to->src) && !ast_strlen_zero(from->src)) {

By: Steve Murphy (murf) 2007-07-09 14:56:58

OK, hang on; I'm a bit confused, I admit.

First of all, all updatecdr does is update the channel name to "Agent/whatever..."-- and that is all. Nothing else.

The suggested change should have worked at least for the channel name field;
and your testing shows it didn't, so back to the blackboard, I guess! (it
worked for another user, tho!).

What CDR backend are you using? the cdr_csv? Do you use any database?

The CDR code gives priority to the ANI field in CID structure... is ANI set?


By: Rob M (nyt) 2007-07-09 15:06:20

I'm using cdr-csv and mysql logging, its the same in either place.

If you see the log entry in the last note I added, you'll see it didn't update the channel with Agent/4198 for the outgoing call, but instead left it as SIP/3198 (nothing there is updated with the agent number, except userfield which I set in the dialplan).

""test agent" <3198>","3198","715162488400","internal-real","SIP/3198-082a1750","Zap/1-1","Dial","Zap/g1/15162488400||WT","2007-07-06 07:10:16","2007-07-06 07:10:32","2007-07-06 07:10:34","18","2","ANSWERED","DOCUMENTATION","","1183731016.243","4198"

I think that patch may have also broke something as I had reports of call logging issues, sorry I can't be more specific but I reverted the patch already to its previous state.

By: Rob M (nyt) 2007-07-31 19:31:43

Not to be a pain, but any update?  Anything else I can help to test?

By: Rob M (nyt) 2007-09-07 02:22:06

This is still broken in Asterisk SVN-branch-1.4-r81832

sip user 3198, agent # 4198
4198         (test agent) available at '3198@queue' (musiconhold is 'default')

""test agent" <3198>","3198","715169031948","internal-real","SIP/3198-082c9158","Zap/1-1","Dial","Zap/g1/15169031948||WT","2007-09-07 00:33:39","2007-09-07 00:33:55","2007-09-07 00:34:13","34","18","ANSWERED","DOCUMENTATION","","1189150419.6","4198"

By: Brandon Kruse (bkruse) 2007-10-30 09:37:11


Any update on this?

Is there anything that needs fixing?


By: Rob M (nyt) 2007-10-30 15:09:04

This was still broken last time I tested an SVN release.  I am unable to test on a live system again.  I suppose sometime I can setup a test system and see if it is still not working.

By: Steve Murphy (murf) 2007-10-31 11:00:47

nyt-- I doubt I will be able to replicate your environment easily. Let me know when you will be able to test any updates I'd do.

By: Rob M (nyt) 2007-10-31 13:59:11

i have a test machine i can work with, what build should i test?

By: Michiel van Baak (mvanbaak) 2008-02-01 17:24:02.000-0600

latest 1.4 svn and if you can the 1.6 beta please

By: jmls (jmls) 2008-02-17 13:03:36.000-0600

nyt, any news, or can we close ?

By: Joshua C. Colp (jcolp) 2008-03-19 12:54:47

I just spent the last half hour labbing this up and testing numerous ways. I can confirm that updatecdr is in fact working.