Filip Jenicek
2015-Aug-03 14:29 UTC
[asterisk-users] Modifying CDR values from a hangup extension in Asterisk 13
Hi, I'm trying to migrate from Asterisk 1.8 to Asterisk 13 and can't figure this one out. I'm pretty sure the question has been already asked, but I failed to find a solution. Can you modify CDR values in an h-extension? My cdr.conf contains: [general] enable=yes unanswered=yes endbeforehexten=yes initiatedseconds=no batch=no The diaplan contains a simple "h" extension exten => h,1,NoOp(${CDR(userfield)}) exten => h,n,Set(CDR(userfield)=changed) exten => h,n,NoOp(${CDR(userfield)}) In the same context I execute: exten => 10,1,Set(CDR(userfield)=empty) exten => 10,n,Dial(SIP/10) The "h" extension outputs two lines with userfield set to "empty". I would expect the second one to be "changed". It seems that I can read the CDR values, but I can't change them. Is it a bug or a design thing? Am I missing something? Thank you, Filip
jg
2015-Aug-03 14:36 UTC
[asterisk-users] Modifying CDR values from a hangup extension in Asterisk 13
> I'm trying to migrate from Asterisk 1.8 to Asterisk 13 and can't figure this one out. I'm > pretty sure the question has been already asked, but I failed to find a solution. > > Can you modify CDR values in an h-extension? > > My cdr.conf contains: > [general] > enable=yes > unanswered=yes > endbeforehexten=yes > initiatedseconds=no > batch=no > > The diaplan contains a simple "h" extension > exten => h,1,NoOp(${CDR(userfield)}) > exten => h,n,Set(CDR(userfield)=changed) > exten => h,n,NoOp(${CDR(userfield)}) > > In the same context I execute: > exten => 10,1,Set(CDR(userfield)=empty) > exten => 10,n,Dial(SIP/10) > > The "h" extension outputs two lines with userfield set to "empty". I would expect the second > one to be "changed". It seems that I can read the CDR values, but I can't change them. Is it a > bug or a design thing? Am I missing something?I am not working with h-extensions myself, but the docs (https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Configuration_cdr) say something like this: |endbeforehexten| <https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Configuration_cdr#Asterisk13Configuration_cdr-general_endbeforehexten> |Boolean| |1| |false| Don't produce CDRs while executing hangup logic This would indicate that at least writing is disabled. jg -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20150803/745f189c/attachment.html>
Filip Jenicek
2015-Aug-04 14:16 UTC
[asterisk-users] Modifying CDR values from a hangup extension in Asterisk 13
With endbeforehexten=no I actually get two CDR entries. One for the call and a second one for the "h" extension. "","13","10","sip-locals","""13"" <13>","SIP/13-00000006","SIP/10-00000007","Dial","SIP/10","2015-08-04 06:28:44","2015-08-04 06:28:45","2015-08-04 06:28:47",3,1,"ANSWERED","DOCUMENTATION","1438669724.6","empty" "","13","h","sip-locals","""13"" <13>","SIP/13-00000006","","NoOp","changed","2015-08-04 06:28:47","2015-08-04 06:28:47","2015-08-04 06:28:47",0,0,"ANSWERED","DOCUMENTATION","1438669724.6","changed" The first one contains the call itself. There are durations, CDR variables set during the call, etc. The second one contains only things configured in the "h" extension. With endbeforehexten=yes, the cdr contains: "","13","10","sip-locals","""13"" <13>","SIP/13-00000006","SIP/10-00000007","Dial","SIP/10","2015-08-04 06:28:44","2015-08-04 06:28:45","2015-08-04 06:28:47",3,1,"ANSWERED","DOCUMENTATION","1438669724.6","empty" There is only the call, nothing from the "h" extension. I forgot to mention that I'm using Asterisk 13.1-cert2. Modifying CDR records in the "h" extension used to work fine with Asterisk 1.8. By analyzing the code I must confirm that the endbeforehexten option behaves exactly according to its description: As each CDR for a channel is finished, its end time is updated and the CDR is finalized. When a channel is hung up and hangup logic is present (in the form of a hangup handler or the <literal>h</literal> extension), a new CDR is generated for the channel. Any statistics are gathered from this new CDR. By enabling this option, no new CDR is created for the dialplan logic that is executed in <literal>h</literal> extensions or attached hangup handler subroutines. The default value is <literal>yes</literal>, indicating that a CDR will be generated during hangup logic.</para> I tried to delay the "h" extension by several seconds and I found out, that the CDR record is sent to the cdr backend later. Unfortunately, it is not modifiable from the "h" extension, because the cdr_object is already in the finalized table. Is there a way how to modify the CDR without hacking the code? How bad idea is it to comment the (it_cdr->fn_table == &finalized_state_fn_table) tests in ast_cdr_setuserfield and ast_cdr_setvar and thus allow the "h" extension write to a finalized CDR? Is there any chance the feature was left out by an accident and if so, is there a plan to add it again? My extensions.conf: exten => h,1,NoOp(${CDR(userfield)}) exten => h,n,Set(CDR(userfield)=changed) exten => h,n,NoOp(${CDR(userfield)}) exten => h,n,System(sleep 5) exten => h,n,NoOp(${CDR(userfield)}) exten => 10,1,Set(CDR(userfield)=empty) exten => 10,n,Dial(SIP/10) Detailed log: http://pastebin.com/fZ9RAhL4 On 08/03/2015 04:36 PM, jg wrote:> >> I'm trying to migrate from Asterisk 1.8 to Asterisk 13 and can't >> figure this one out. I'm pretty sure the question has been already >> asked, but I failed to find a solution. >> >> Can you modify CDR values in an h-extension? >> >> My cdr.conf contains: >> [general] >> enable=yes >> unanswered=yes >> endbeforehexten=yes >> initiatedseconds=no >> batch=no >> >> The diaplan contains a simple "h" extension >> exten => h,1,NoOp(${CDR(userfield)}) >> exten => h,n,Set(CDR(userfield)=changed) >> exten => h,n,NoOp(${CDR(userfield)}) >> >> In the same context I execute: >> exten => 10,1,Set(CDR(userfield)=empty) >> exten => 10,n,Dial(SIP/10) >> >> The "h" extension outputs two lines with userfield set to "empty". I >> would expect the second one to be "changed". It seems that I can read >> the CDR values, but I can't change them. Is it a bug or a design >> thing? Am I missing something? > I am not working with h-extensions myself, but the docs > (https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Configuration_cdr) > say something like this: > > |endbeforehexten| > <https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Configuration_cdr#Asterisk13Configuration_cdr-general_endbeforehexten> > > > > |Boolean| > > > > |1| > > > > |false| > > > > Don't produce CDRs while executing hangup logic > > > This would indicate that at least writing is disabled. > > jg > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20150804/8088a218/attachment.html>
Possibly Parallel Threads
- Modifying CDR values from a hangup extension in Asterisk 13
- Modifying CDR values from a hangup extension in Asterisk 13
- Asterisk13 don't execute h exten inside macros
- Asterisk 11 - Change CDR in hangup exten [Was: CDR values changed in hangup handler not saved]
- Error saving cdr at h exten in Asterisk13