[Home]

Summary:ASTERISK-01999: CDR billsec/duration should reflect queue holdtime
Reporter:davetroy (davetroy)Labels:
Date Opened:2004-07-12 17:06:40Date Closed:2011-06-07 14:05:09
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/app_queue
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:It would be very handy to have callers' queue hold time be reflected in the standard CDR as the difference between 'duration' and 'billsec'.  This appears to be doable via the following two small changes:

In app_queue.c, add a call to ast_cdr_answer:
/* If appropriate, log that we have a destination channel */
if (qe->chan->cdr) {
  ast_cdr_setdestchan(qe->chan->cdr, peer->name);
  ast_cdr_answer(qe->chan->cdr); /* Add this line*/
}

In cdr.c, simply comment out the condition that checks to see if the time has been set before it's reinitialized:
/*if (!cdr->answer.tv_sec && !cdr->answer.tv_usec) {*/
  gettimeofday(&cdr->answer, NULL);
/*}*/

While this seems to work, I imagine that the reason the checks on cdr->answer are in place are to prevent billable seconds from potentially being lost in complex extension lists with multiple Answer events.

So, is there a better/other way to do this, or is my solution OK? Perhaps have another ast_cdr_answer_force routine that bypasses the check, or something similar?

Have had a couple of people ask me about this.
Comments:By: Mark Spencer (markster) 2004-07-12 21:12:28

If you don't answer the line first, is that not how it behaves today?

By: Mark Spencer (markster) 2004-07-13 09:57:44

If you do need to answer the line first, you can try the ResetCDR application.

By: davetroy (davetroy) 2004-07-13 11:02:27

Am answering the line as the first step of an IVR tree; this seems to be widely recommended as a way of insuring the channel is initialized and ready to receive audio.  Is this unnecessary?

Supposing I don't 'Answer' the call first, I am not sure that there is anything internal to app_queue that initiates a CDR answer at the time the queue member actually answers the call.  I would think a 'ast_cdr_answer' call would be necessary to do that.

I'll check out ResetCDR; still not sure there's anything to set the answer time inside app_queue but I'll experiment now.

Thanks for the feedback.

By: davetroy (davetroy) 2004-07-13 13:00:54

ResetCDR does seem to have the desired effect.  What is triggering the CDR Answer event within the app_queue process?  Does this happen automatically when the caller and the queue member are joined together?

Thanks for the help.

For those trying to achieve this, here is a sample extension list that works:
Exten => s,1,Answer
Exten => s,2,Wait,1
Exten => s,3,BackGround(main1),45
Exten => s,4,SetCIDName(Menu Timeout)
Exten => s,5,ResetCDR
Exten => s,6,Queue(reception|t)

CDR will show 'duration' as the total duration of the call (from ResetCDR event forward) and 'billsec' will show total # of seconds after the queue member answers.