Unable to get billsecs of B-leg while originate call

We are using originate to call an extension in which we execute the Dial function through an AGI script, and want to get vital information from CDR,
we are able to get start-time, end-time but billsecs are 0 ?
we had tried forkCDR and ResetCDR but not getting billsecs ,Is there any other possible way or we are missing something?

The billsecs value is not calculated and set until the call is completely closed out and done. There is the “endbeforehexten” option in cdr.conf which can be used to do this before the “h” extension is executed. When are you trying to get this information?

1 Like

We are trying to get it in the agi script after the Dial function exits.

It is not available at that time. The Dial application does provide “ANSWEREDTIME” and “DIALEDTIME” dialplan variables with information, though.

Yes i checked ANSWERDTIME too , they still coming “0” though

From my experience, the AGI is attached to a dead channel. billsec does not exist for this socket connection. The calculation of billsec is handled outside of the old channel.

As previously mentioned by @jcolp, you can find billsec with the h: Hangup extension.

 ...
 same => n,agi(dial.script)
 same => n,Hangup()

exten => h,1,NoOp(Hangup)
 same => n,DumpChan()
 same => n,agi(hangup.script)

@jcolp @poing Tried as you were suggested using h extension,but nothing seems to work
below is our configuration and output logs.

[my]
exten =>_X.,1,Noop("####### my context ######")
        same => n,Noop(${EXTEN})
        same => n,Set(AGISIGHUP=no)
        same => n,AGI(/home/my-pc/Documents/py-bulkcalling/bulkCall.py,${EXTEN})
        same => n,Noop(${CDR(start)} ${CDR(billsec)})
        same => n,Hangup()
exten => h,1,noop(HangUp)
        same => n,DumpChan()

[play]
exten => s,1,Noop("####### play started ####")
        same => n,Set(AGISIGHUP=no)
        ;same => n,Set(GOSUB_RESULT=CONTINUE) 
        same => n,AGI(/home/my-pc/Documents/py-bulkcalling/play.py,${ARG1})
        same => n,Noop(${CDR(billsec)})
        same => n,Set(SHARED(billbabu,${ARG2})=${CDR(billsec)})
        same => n,noop(${SHARED(billbabu,${ARG2})})


Dumping Info For Channel: Local/101|1|1|101|dir-intro.gsm@my-00000006;2:
================================================================================
Info:
Name=               Local/101|1|1|101|dir-intro.gsm@my-00000006;2
Type=               Local
UniqueID=           1536565101.31
LinkedID=           1536565101.30
CallerIDNum=        6679910
CallerIDName=       (N/A)
ConnectedLineIDNum= 101|1|1|101|dir-intro.gsm
ConnectedLineIDName=(N/A)
DNIDDigits=         (N/A)
RDNIS=              (N/A)
Parkinglot=         
Language=           en
State=              Up (6)
Rings=              0
NativeFormat=       (slin)
WriteFormat=        slin
ReadFormat=         slin
RawWriteFormat=     slin
RawReadFormat=      slin
WriteTranscode=     No 
ReadTranscode=      No 
1stFileDescriptor=  -1
Framesin=           4 
Framesout=          3 
TimetoHangup=       0
ElapsedTime=        0h0m11s
BridgeID=           (Not bridged)
Context=            my
Extension=          h
Priority=           2
CallGroup=          
PickupGroup=        
Application=        DumpChan
Data=               (Empty)
Blocking_in=        (Not Blocking)

Variables:
AGISTATUS=HANGUP
DIALSTATUS=ANSWER
DIALEDTIME=10
ANSWEREDTIME=0
DIALEDPEERNUMBER=101
DIALEDPEERNAME=PJSIP/101-00000006
AGISIGHUP=no
================================================================================

Dumpchan() is called properly after the call. Replace it with the the vital information you want to get.

...
  same => n,NoOp(${CDR(start)} ${CDR(billsec)})
  same => n,Hangup()
exten => h,1,noop(HangUp)
  same => n,DumpChan()

We’re not going to spell it out for you!

@poing my issue is i am getting ANSWERTIME=0.

I thought you wanted ${CDR(billsec)}, but you’ve been looking for it in the wrong place. Never payed any attention to ANSWERTIME, so not sure what to use it for.

I think they were looking for ANSWERTIME because they could not get a useful value for BILLSEC. BILLSEC is end time - ANSWERTIME
.

There’s nothing like Bill sec/time.You need to look at start time and end time and do the calculation.