Getting Billsec

Hi

I’m trying to get the billsec in asterisk (elastix) dialplan after user hangup the call, But I think the dial plan code where I get the billsec in not executting, this the dial plan code:

;Dial 72 + external number
exten => _72X.,1,Set(OUTGOINGNUMBER=${EXTEN:2})
same => n,Verbose(Call start time: ${CDR(start)})
same => n,Dial(DAHDI/1/${OUTGOINGNUMBER}); Dial outgoingnumber for channel 1
exten => n,Hangup
exten => h,1,Noop(End)
exten => h,n,Noop(The call duration is: ${CDR(billsec)}); Print Billsec in console

This is the console output:

– Executing [h@from-internal:1] Macro(“SIP/8000-0000005a”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“SIP/8000-0000005a”, “1?endmixmoncheck”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] NoOp(“SIP/8000-0000005a”, “End of MIXMON check”) in new stack
– Executing [s@macro-hangupcall:10] GotoIf(“SIP/8000-0000005a”, “1?nomeetmemon”) in new stack
– Goto (macro-hangupcall,s,28)
– Executing [s@macro-hangupcall:28] NoOp(“SIP/8000-0000005a”, “End of MEETME check”) in new stack
– Executing [s@macro-hangupcall:29] GotoIf(“SIP/8000-0000005a”, “1?noautomon”) in new stack
– Goto (macro-hangupcall,s,34)
– Executing [s@macro-hangupcall:34] NoOp(“SIP/8000-0000005a”, “TOUCH_MONITOR_OUTPUT=”) in new stack
– Executing [s@macro-hangupcall:35] GotoIf(“SIP/8000-0000005a”, “1?noautomon2”) in new stack
– Goto (macro-hangupcall,s,41)
– Executing [s@macro-hangupcall:41] NoOp(“SIP/8000-0000005a”, “MONITOR_FILENAME=”) in new stack
– Executing [s@macro-hangupcall:42] GotoIf(“SIP/8000-0000005a”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,45)
– Executing [s@macro-hangupcall:45] GotoIf(“SIP/8000-0000005a”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,48)
– Executing [s@macro-hangupcall:48] GotoIf(“SIP/8000-0000005a”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,50)
– Executing [s@macro-hangupcall:50] AGI(“SIP/8000-0000005a”, “hangup.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/hangup.agi
<SIP/8000-0000005a>AGI Tx >> agi_request: hangup.agi
<SIP/8000-0000005a>AGI Tx >> agi_channel: SIP/8000-0000005a
<SIP/8000-0000005a>AGI Tx >> agi_language: en
<SIP/8000-0000005a>AGI Tx >> agi_type: SIP
<SIP/8000-0000005a>AGI Tx >> agi_uniqueid: 1425920338.140
<SIP/8000-0000005a>AGI Tx >> agi_version: 1.8.20.0
<SIP/8000-0000005a>AGI Tx >> agi_callerid: 8000
<SIP/8000-0000005a>AGI Tx >> agi_calleridname: device
<SIP/8000-0000005a>AGI Tx >> agi_callingpres: 0
<SIP/8000-0000005a>AGI Tx >> agi_callingani2: 0
<SIP/8000-0000005a>AGI Tx >> agi_callington: 0
<SIP/8000-0000005a>AGI Tx >> agi_callingtns: 0
<SIP/8000-0000005a>AGI Tx >> agi_dnid: 72226
<SIP/8000-0000005a>AGI Tx >> agi_rdnis: unknown
<SIP/8000-0000005a>AGI Tx >> agi_context: macro-hangupcall
<SIP/8000-0000005a>AGI Tx >> agi_extension: s
<SIP/8000-0000005a>AGI Tx >> agi_priority: 50
<SIP/8000-0000005a>AGI Tx >> agi_enhanced: 0.0
<SIP/8000-0000005a>AGI Tx >> agi_accountcode:
<SIP/8000-0000005a>AGI Tx >> agi_threadid: -1220240496
<SIP/8000-0000005a>AGI Tx >>
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(uniqueid)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (1425920338.140)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(answer)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (2015-03-09 12:29:01)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(src)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (8000)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(dst)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (72226)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(billsec)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (13)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(dstchannel)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (DAHDI/1-1)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(disposition)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (ANSWERED)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(accountcode)
<SIP/8000-0000005a>AGI Tx >> 200 result=0
<SIP/8000-0000005a>AGI Rx << GET VARIABLE CDR(channel)
<SIP/8000-0000005a>AGI Tx >> 200 result=1 (SIP/8000-0000005a)
<SIP/8000-0000005a>AGI Rx << GET VARIABLE DIAL_TRUNK
<SIP/8000-0000005a>AGI Tx >> 200 result=0
– <SIP/8000-0000005a>AGI Script hangup.agi completed, returning 0
– Executing [s@macro-hangupcall:51] Hangup(“SIP/8000-0000005a”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 51) exited non-zero on ‘SIP/8000-0000005a’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/8000-0000005a’
– Hanging up on ‘DAHDI/1-1’
– Hungup ‘DAHDI/1-1’
== Spawn extension (from-internal, 72226, 3) exited non-zero on 'SIP/8000-0000005a’
elatix28*CLI>

Please, Any ideas?

You appear to have defined your h extension in the wrong context and there is a matching h extension in a better context.

This looks like a complex dialplan; you really need to get support from its authors.

Thanks for answer david55.
I mentioned above that I’m trying to get the billsec after users hangup calls in an elastix 2.4 version, Well, I tried to get billsec in asterisk 11.8.1 version and it worked, this is the dialplan code for the asterisk sip extensions are located in context [sip-longdistance]:

[sip-longdistance]
exten => _1XXX,1,Dial(SIP/${EXTEN},15,Trt)
exten => _1XXX,2,Voicemail(${EXTEN}@default,u)
exten => _1XXX,n,Hangup
exten => h,1,Noop(End)
exten => h,n,Noop(The Billsec is: ${CDR(billsec)})

This is the console output:

== Using SIP RTP CoS mark 5
– Executing [1001@sip-longdistance:1] Dial(“SIP/1000-00000009”, “SIP/1001,15,Trt”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/1001
– SIP/1001-0000000a is ringing
– SIP/1001-0000000a answered SIP/1000-00000009
– Executing [h@sip-longdistance:1] NoOp(“SIP/1000-00000009”, “End”) in new stack
[color=#0000FF] – Executing [h@sip-longdistance:2] NoOp(“SIP/1000-00000009”, “The Billsec is: 2”) in new stack[/color]
== Spawn extension (sip-longdistance, 1001, 1) exited non-zero on ‘SIP/1000-00000009’

In elastix I edited the file “sip_additional.conf” (/etc/asterisk/) via console and add sip extensions:

[8020]
type=friend
username=8020
secret=1234
callerid=User <8020>
host=dynamic
disallow=all
allow=ilbc,ulaw
[color=#0000FF]context=sip-test[/color]
reinvite=no
canreinvite=yes
transfer=yes
;callgroup=1,3-4 ; We are in caller groups 1,3,4
pickupgroup=1
callgroup=1

I edited and created sip extension 8020 context “sip-test” in the elastix file “extensions.conf” (/etc/asterisk)

[b][from-internal-custom]
include => sip-test

[sip-test]
exten => _8XXX,1,Dial(SIP/${EXTEN},15,Trt)
exten => h,1,Noop(End)
exten => h,n,Noop(The Billsec is: ${CDR(billsec)})
;Dial variable by Dahdi channel 1
exten => _72X.,1,Set(OUTGOINGNUMBER=${EXTEN:2});
same => n,Verbose(Call start time: ${CDR(start)})
same => n,Dial(DAHDI/1/${OUTGOINGNUMBER});
exten => n,Hangup()[/b]

The elasix console output shows the billsec:

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [72236@sip-test:1] Set(“SIP/8020-00000002”, “OUTGOINGNUMBER=236”) in new stack
– Executing [72236@sip-test:2] Verbose(“SIP/8020-00000002”, “Call start time: 2015-03-11 08:50:00”) in new stack
Call start time: 2015-03-11 08:50:00
– Executing [72236@sip-test:3] Dial(“SIP/8020-00000002”, “DAHDI/1/236”) in new stack
– Called DAHDI/1/236
– Remote UNIX connection
– Remote UNIX connection disconnected
– DAHDI/1-1 answered SIP/8020-00000002
– Executing [h@sip-test:1] NoOp(“SIP/8020-00000002”, “End”) in new stack
[color=#0000FF] – Executing [h@sip-test:2] NoOp(“SIP/8020-00000002”, “The Billsec is: 7”) in new stack[/color]
– Hanging up on ‘DAHDI/1-1’
– Hungup ‘DAHDI/1-1’
== Spawn extension (sip-test, 72236, 3) exited non-zero on 'SIP/8020-00000002’
elatix28*CLI>

The problem is that If I update an extension via web the elastix file “sip_additional.conf” is going to be overwrited and the extesion 8020 create via console is going to be deleted,
Please, my question is in which elastix file can I create extension via console to avoid that? Or How can I include the context sip-test (context in dial plan) for being accessed by the context “from-internal”, this “from-internal” is the default context where extensions created via web are located

You need to use the extensions_override file to made the changes. For further help on elastix try in forum.elastix.org.