CDR Start Time and Answer Time is the Same


I have managed to save my asterisk CDR to MySQL Database via ODBC. My problem is CDR Start Time and Answer time is always the same. Do I need to modify my dialplan to insert the correct start time and answer time in MySQL? I have a basic dialplan like below. Please help

exten => _1XX,1,Answer
exten => _1XX,n,NoOP(Internal-Call)
exten => _1XX,n,Dial(SIP/${EXTEN},30,r)
exten => _1XX,n,Voicemail(${EXTEN}@voicemails)
exten => _1XX,n,Hangup()

Have you done a sanity check and looked at cdr-custom or something else to verify things first?

That’s because you answer the call immediately. I can see no reason for doing that here, so I assume it is the result of cut and paste coding. However, at least with the old CDR implementation, you could reset the CDR after the Answer.

1 Like

Hi david551,

Even if I let the phone ring for 10 secs before answering the result is still the same. Any hint on where should I troubleshoot this?


I’ve already answered.

Don’t answer the call prematurely, or if you can’t avoid that, reset the CDR after you have answered it.

As was told before dont answer the call or tried

1 Like

Sorry but for me isn’t clear where I need to put exactlly the ResetCDR()
In my dialplan I have 2 macros:


exten => s,1,AGI(,7777,dongle0)
same => n,Set(CDR(start_)=${SHELL(date "+%H:%M:%S %d.%b.%Y")})
same => n,set(CDR(codec1)=${CHANNEL(audioreadformat)})
same => n,set(CDR(codec2)=${CHANNEL(audiowriteformat)})



exten => s,1,System(STRFTIME(${EPOCH},%d.%m.%Y %H:%M:%S))
same => n,NoOp(SendedCID = ${CALLERID(num)})
same => n,set(CDR(duration_)=${CDR(duration)})
same => n,Set(CDR(answer_)=${SHELL(date "+%H:%M:%S %d.%b.%Y")})
same => n,Set(CDR(end_)=${SHELL(date "+%H:%M:%S %d.%b.%Y")})

and incoming and outgoing:

exten => s,1,Macro(before-call-066)
same => n,Dial(SIP/7777)
same => n,Hangup()

exten => h,1,Verbose(Macro after call)
same => n,Macro(after-incoming_CALL-066); Uvek ide h posle hangup-a
same => n(not_simple),Hangup()
exten => _0[1,2,3,6,800].,1,Macro(before-call-066);
same => n,Set(Called_number=${EXTEN});
same => n,Dial(Dongle/dongle0/${EXTEN});
same => n,Hangup()

exten => h,1,Verbose(Macro after call)
same => n,Macro(after-outgoing_CALL-066)
same => n,Hangup()

From the CLI: core show function CDR is explained:

For example, CDRs may not be modified after the ‘Dial’ application has

Now if I put after DIAL how he will see when it was answered?
And if I put before, how he know after how many second someone pick up the phone?
Can someone help me where I need to put commands:

same => n,Set(CDR(answer_)=${SHELL(date "+%H:%M:%S %d.%b.%Y")})




Anywhere after you’ve answered the call prematurely, but before you have done anything that will generate the B side answer. It may have to go near the former, if you are interested in logging the time between call arrival and B leg answer, or later, if you only want the B leg ring time, not the time used on whatever required you to answer early.

Theory…it is clear, but in practice I do not understand where…

You seem to have hijacked someone else’s thread. In terms of the original posting, either side of the Noop would be equal.

Your dial plan is complex and I can’t immediately see where the call is being answered. However the latest possible place is immediately before the Dial.

1 Like