1

What is the best way to get the call duration of B-leg in Asterisk?

A num--------(a-leg)------->Asterisk PBX--------(b-leg)-----------> B num

The simple dialplan is:

[bleg_duration]
exten => _X.,1,Answer()
 same => n,Wait(10)
 same => n,Dial(dahdi/G1/${B_NUM},30,gS(60))
 same => n,Noop(${CDR(billsec)})
 same => n,Noop(${DIALEDTIME}) ;Time for the call (seconds)
 same => n,Noop(${ANSWEREDTIME}) ;Time from dial to answer (seconds)
 same => n,Hangup()

so if A number call to that dialplan, it wait for 10 seconds before connect to B number. I would like to get the duration from when the B num is answered to when B num hangup. I think it's common need and but can't find the easy way to get it.

duccom
  • 134
  • 2
  • 16

1 Answers1

3

1) You can use forkCDR record.

2) You can dial via Local/ channel, second cdr record will have correct billsec.

3) You can save EPOCH(current time) and user it.

and yes, you still can use

${ANSWEREDTIME}: This is the amount of time for actual call.
arheops
  • 15,544
  • 1
  • 21
  • 27
  • Thanks for the answer. I believe that if I'm using ForkCDR() then CDR will be separated to 2 parts. How I can get the duration of each part? Or i understanding wrong? – duccom Nov 17 '16 at 10:22
  • Duration will be in billsec for second one. – arheops Nov 17 '16 at 14:30
  • i known, but how can i access the second one CDR? when i call CDR(billsec) it always show the first CDR duration. – duccom Nov 18 '16 at 07:23
  • You can access second cdr from second dialplan(afer Local call). You also can mark moment when call was answered by macro of dial M(macroname). – arheops Nov 18 '16 at 19:39