Re: [asterisk-users] AMI and CDR(answer)

2014-10-17 Thread Murthy Gandikota


From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Friday, October 17, 2014 10:46 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

 

 

On Thu, Oct 16, 2014 at 4:12 PM, Murthy Gandikota 
wrote:

in cdr.c

void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)

{

struct ast_cdr *duplicate;

struct ast_flags flags = { 0 };

 

if (_flags)

ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);

 

for ( ; cdr ; cdr = cdr->next) {

/* Detach if post is requested */

if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) ||
!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {

if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED))
{

ast_cdr_end(cdr);

if ((duplicate =
ast_cdr_dup_unique_swap(cdr))) {

ast_cdr_detach(duplicate);

}

ast_set_flag(cdr, AST_CDR_FLAG_POSTED);

}

 

/* enable CDR only */

if (ast_test_flag(&flags,
AST_CDR_FLAG_POST_ENABLE)) {

ast_clear_flag(cdr,
AST_CDR_FLAG_POST_DISABLED);

continue;

}

 

/* clear variables */

if (!ast_test_flag(&flags,
AST_CDR_FLAG_KEEP_VARS)) {

ast_cdr_free_vars(cdr, 0);

}

 

/* Reset to initial state */

ast_clear_flag(cdr, AST_FLAGS_ALL);

memset(&cdr->start, 0, sizeof(cdr->start));

memset(&cdr->end, 0, sizeof(cdr->end));

memset(&cdr->answer, 0, sizeof(cdr->answer));

cdr->billsec = 0;

cdr->duration = 0;

ast_cdr_start(cdr);

cdr->disposition = AST_CDR_NOANSWER;

}

}

}

If this line:

memset(&cdr->answer, 0, sizeof(cdr->answer));

 

is commented away, should work.

 

 

 

I don't think you need to change the Asterisk source for this
(particularly since it is supposed to be wiping the answer time there).

If you want to keep the original answer time, use a custom field in your
CDR, and set it prior to resetting:

exten => Set(CDR(orig_answer)=${CDR(answer)})

exten => ResetCDR(v)

Note the usage of 'v' to keep the custom variable that you just set.


-- 

Matthew Jordan

Digium, Inc. | Engineering Manager

445 Jan Davis Drive NW - Huntsville, AL 35806 - USA

Check us out at: http://digium.com & http://asterisk.org

 

 

I agree with a caveat. As I mentioned before, strftime can be used
instead of CDR(answer) for the answer time. It will be like any other
user defined variable.

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] AMI and CDR(answer)

2014-10-17 Thread Matthew Jordan
On Thu, Oct 16, 2014 at 4:12 PM, Murthy Gandikota 
wrote:

>in cdr.c
>
> void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)
>
> {
>
> struct ast_cdr *duplicate;
>
> struct ast_flags flags = { 0 };
>
>
>
> if (_flags)
>
> ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);
>
>
>
> for ( ; cdr ; cdr = cdr->next) {
>
> /* Detach if post is requested */
>
> if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) ||
> !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
>
> if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) {
>
> ast_cdr_end(cdr);
>
> if ((duplicate =
> ast_cdr_dup_unique_swap(cdr))) {
>
> ast_cdr_detach(duplicate);
>
> }
>
> ast_set_flag(cdr, AST_CDR_FLAG_POSTED);
>
> }
>
>
>
> /* enable CDR only */
>
> if (ast_test_flag(&flags,
> AST_CDR_FLAG_POST_ENABLE)) {
>
> ast_clear_flag(cdr,
> AST_CDR_FLAG_POST_DISABLED);
>
> continue;
>
> }
>
>
>
> /* clear variables */
>
> if (!ast_test_flag(&flags,
> AST_CDR_FLAG_KEEP_VARS)) {
>
> ast_cdr_free_vars(cdr, 0);
>
> }
>
>
>
> /* Reset to initial state */
>
> ast_clear_flag(cdr, AST_FLAGS_ALL);
>
> memset(&cdr->start, 0, sizeof(cdr->start));
>
> memset(&cdr->end, 0, sizeof(cdr->end));
>
> memset(&cdr->answer, 0, sizeof(cdr->answer));
>
> cdr->billsec = 0;
>
> cdr->duration = 0;
>
> ast_cdr_start(cdr);
>
> cdr->disposition = AST_CDR_NOANSWER;
>
> }
>
> }
>
> }
>
> If this line:
>
> memset(&cdr->answer, 0, sizeof(cdr->answer));
>
>
>
> is commented away, should work.
>
>
>
>
>

I don't think you need to change the Asterisk source for this (particularly
since it is supposed to be wiping the answer time there).

If you want to keep the original answer time, use a custom field in your
CDR, and set it prior to resetting:

exten => Set(CDR(orig_answer)=${CDR(answer)})
exten => ResetCDR(v)

Note the usage of 'v' to keep the custom variable that you just set.

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] AMI and CDR(answer)

2014-10-16 Thread Murthy Gandikota
in cdr.c

void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)

{

struct ast_cdr *duplicate;

struct ast_flags flags = { 0 };

 

if (_flags)

ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);

 

for ( ; cdr ; cdr = cdr->next) {

/* Detach if post is requested */

if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) ||
!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {

if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED))
{

ast_cdr_end(cdr);

if ((duplicate =
ast_cdr_dup_unique_swap(cdr))) {

ast_cdr_detach(duplicate);

}

ast_set_flag(cdr, AST_CDR_FLAG_POSTED);

}

 

/* enable CDR only */

if (ast_test_flag(&flags,
AST_CDR_FLAG_POST_ENABLE)) {

ast_clear_flag(cdr,
AST_CDR_FLAG_POST_DISABLED);

continue;

}

 

/* clear variables */

if (!ast_test_flag(&flags,
AST_CDR_FLAG_KEEP_VARS)) {

ast_cdr_free_vars(cdr, 0);

}

 

/* Reset to initial state */

ast_clear_flag(cdr, AST_FLAGS_ALL);

memset(&cdr->start, 0, sizeof(cdr->start));

memset(&cdr->end, 0, sizeof(cdr->end));

memset(&cdr->answer, 0, sizeof(cdr->answer));

cdr->billsec = 0;

cdr->duration = 0;

ast_cdr_start(cdr);

cdr->disposition = AST_CDR_NOANSWER;

}

}

}

If this line:

memset(&cdr->answer, 0, sizeof(cdr->answer));

 

is commented away, should work.

 

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Thursday, October 16, 2014 11:24 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

Hi Matthew,

Now that you helped me figure out the root cause of my problem, I am
wondering if there is a safe way to store CDR without altering the
non-custom fields (the converse of v option).

 

Thanks

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Thursday, October 16, 2014 10:44 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

Apparently we are calling ResetCDR (not ForkCDR) in the Asterisk 11.5.1
That is causing the CDR(answer) to be erased between context. My bad.

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Thursday, October 16, 2014 9:45 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

Suppose we have a dialplan as follows and sip.conf is set to forward the
call to [start] context, the CDR(diposition) in [start] context will be
"ANSWER" and in [next] will be "NO ANSWER". Right?

 

[start]

exten = s,1,answer()

same =>n,gotoif($[${SOMEVAR} = SOME_VAL]?next)

same =>n, hangup()

 

[next]

exten = s,1, VERBOSE(WE ARE HERE)

same =>n,hangup()

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Thursday, October 16, 2014 8:55 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

 

 

On Wed, Oct 15, 2014 at 9:31 PM, Murthy Gandikota 
wrote:

Thanks, Matthew. I think CDR(answer) is, in the end, not very useful to
me if it changes from context to context. Suppose from AMI we generate a
status

 

I'm not sure what you mean by "changes from context to context". The
answer time on a CDR is reflective of when the channel was answered.
That can be altered if you choose to alter it in the dialplan via
ForkCDR, but generally, that time is conveyed from one CDR to another.

A specific example would help here.

 

event, what will be the CDR(answer)? I see that sometimes it is
returned
as the literal "Production" instead of a Date/Time or a blank
value.

 

I don't know what you mean here either. What version of Asterisk are you
using? Can you provide an example where you get said literal back, as
well as the dialplan that pr

Re: [asterisk-users] AMI and CDR(answer)

2014-10-16 Thread Murthy Gandikota
Hi Matthew,

Now that you helped me figure out the root cause of my problem, I am
wondering if there is a safe way to store CDR without altering the
non-custom fields (the converse of v option).

 

Thanks

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Thursday, October 16, 2014 10:44 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

Apparently we are calling ResetCDR (not ForkCDR) in the Asterisk 11.5.1
That is causing the CDR(answer) to be erased between context. My bad.

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Thursday, October 16, 2014 9:45 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

Suppose we have a dialplan as follows and sip.conf is set to forward the
call to [start] context, the CDR(diposition) in [start] context will be
"ANSWER" and in [next] will be "NO ANSWER". Right?

 

[start]

exten = s,1,answer()

same =>n,gotoif($[${SOMEVAR} = SOME_VAL]?next)

same =>n, hangup()

 

[next]

exten = s,1, VERBOSE(WE ARE HERE)

same =>n,hangup()

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Thursday, October 16, 2014 8:55 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

 

 

On Wed, Oct 15, 2014 at 9:31 PM, Murthy Gandikota 
wrote:

Thanks, Matthew. I think CDR(answer) is, in the end, not very useful to
me if it changes from context to context. Suppose from AMI we generate a
status

 

I'm not sure what you mean by "changes from context to context". The
answer time on a CDR is reflective of when the channel was answered.
That can be altered if you choose to alter it in the dialplan via
ForkCDR, but generally, that time is conveyed from one CDR to another.

A specific example would help here.

 

event, what will be the CDR(answer)? I see that sometimes it is
returned
as the literal "Production" instead of a Date/Time or a blank
value.

 

I don't know what you mean here either. What version of Asterisk are you
using? Can you provide an example where you get said literal back, as
well as the dialplan that produces this behavior?

 

I
am only puzzled that no one created a patch for the first
timestamp when
a call is answered. If I get some free time, I will try to
create one.




-- 

Matthew Jordan

Digium, Inc. | Engineering Manager

445 Jan Davis Drive NW - Huntsville, AL 35806 - USA

Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] AMI and CDR(answer)

2014-10-16 Thread Murthy Gandikota
Apparently we are calling ResetCDR (not ForkCDR) in the Asterisk 11.5.1
That is causing the CDR(answer) to be erased between context. My bad.

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Thursday, October 16, 2014 9:45 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

Suppose we have a dialplan as follows and sip.conf is set to forward the
call to [start] context, the CDR(diposition) in [start] context will be
"ANSWER" and in [next] will be "NO ANSWER". Right?

 

[start]

exten = s,1,answer()

same =>n,gotoif($[${SOMEVAR} = SOME_VAL]?next)

same =>n, hangup()

 

[next]

exten = s,1, VERBOSE(WE ARE HERE)

same =>n,hangup()

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Thursday, October 16, 2014 8:55 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

 

 

On Wed, Oct 15, 2014 at 9:31 PM, Murthy Gandikota 
wrote:

Thanks, Matthew. I think CDR(answer) is, in the end, not very useful to
me if it changes from context to context. Suppose from AMI we generate a
status

 

I'm not sure what you mean by "changes from context to context". The
answer time on a CDR is reflective of when the channel was answered.
That can be altered if you choose to alter it in the dialplan via
ForkCDR, but generally, that time is conveyed from one CDR to another.

A specific example would help here.

 

event, what will be the CDR(answer)? I see that sometimes it is
returned
as the literal "Production" instead of a Date/Time or a blank
value.

 

I don't know what you mean here either. What version of Asterisk are you
using? Can you provide an example where you get said literal back, as
well as the dialplan that produces this behavior?

 

I
am only puzzled that no one created a patch for the first
timestamp when
a call is answered. If I get some free time, I will try to
create one.




-- 

Matthew Jordan

Digium, Inc. | Engineering Manager

445 Jan Davis Drive NW - Huntsville, AL 35806 - USA

Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] AMI and CDR(answer)

2014-10-16 Thread Murthy Gandikota
Suppose we have a dialplan as follows and sip.conf is set to forward the
call to [start] context, the CDR(diposition) in [start] context will be
"ANSWER" and in [next] will be "NO ANSWER". Right?

 

[start]

exten = s,1,answer()

same =>n,gotoif($[${SOMEVAR} = SOME_VAL]?next)

same =>n, hangup()

 

[next]

exten = s,1, VERBOSE(WE ARE HERE)

same =>n,hangup()

 



From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Thursday, October 16, 2014 8:55 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

 

 

On Wed, Oct 15, 2014 at 9:31 PM, Murthy Gandikota 
wrote:

Thanks, Matthew. I think CDR(answer) is, in the end, not very useful to
me if it changes from context to context. Suppose from AMI we generate a
status

 

I'm not sure what you mean by "changes from context to context". The
answer time on a CDR is reflective of when the channel was answered.
That can be altered if you choose to alter it in the dialplan via
ForkCDR, but generally, that time is conveyed from one CDR to another.

A specific example would help here.

 

event, what will be the CDR(answer)? I see that sometimes it is
returned
as the literal "Production" instead of a Date/Time or a blank
value.

 

I don't know what you mean here either. What version of Asterisk are you
using? Can you provide an example where you get said literal back, as
well as the dialplan that produces this behavior?

 

I
am only puzzled that no one created a patch for the first
timestamp when
a call is answered. If I get some free time, I will try to
create one.




-- 

Matthew Jordan

Digium, Inc. | Engineering Manager

445 Jan Davis Drive NW - Huntsville, AL 35806 - USA

Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] AMI and CDR(answer)

2014-10-16 Thread Matthew Jordan
On Wed, Oct 15, 2014 at 9:31 PM, Murthy Gandikota 
wrote:

> Thanks, Matthew. I think CDR(answer) is, in the end, not very useful to
> me if it changes from context to context. Suppose from AMI we generate a
> status
>

I'm not sure what you mean by "changes from context to context". The answer
time on a CDR is reflective of when the channel was answered. That can be
altered if you choose to alter it in the dialplan via ForkCDR, but
generally, that time is conveyed from one CDR to another.

A specific example would help here.


> event, what will be the CDR(answer)? I see that sometimes it is returned
> as the literal "Production" instead of a Date/Time or a blank value.


I don't know what you mean here either. What version of Asterisk are you
using? Can you provide an example where you get said literal back, as well
as the dialplan that produces this behavior?


> I
> am only puzzled that no one created a patch for the first timestamp when
> a call is answered. If I get some free time, I will try to create one.
>
>
-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] AMI and CDR(answer)

2014-10-15 Thread Murthy Gandikota
Thanks, Matthew. I think CDR(answer) is, in the end, not very useful to
me if it changes from context to context. Suppose from AMI we generate a
status
event, what will be the CDR(answer)? I see that sometimes it is returned
as the literal "Production" instead of a Date/Time or a blank value. I
am only puzzled that no one created a patch for the first timestamp when
a call is answered. If I get some free time, I will try to create one.

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Wednesday, October 15, 2014 3:28 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

On Wed, Oct 15, 2014 at 5:10 PM, Murthy Gandikota 
wrote:
> The CDR(disposition) is changing from context to context. Looks like
AGI
> and AMI are in agreement. Still, it is a mystery why the helpful
> Asterisk folks
> haven't given us a built-in variable for when the call was first
> answered.
>

AMI informs you when a channel is answered via a Newstate event [1].
If you receive such an event and the ChannelState/ChannelStateDesc is
6/Up, then the channel has been answered.

Alternatively, you can query a channel for its Answer time using
either the CDR function, which will return back the CDR's view of the
time the channel was answered. If the channel was not answered, then
not surprisingly, the value is empty. An example output is show below:

Response: Success
Variable: CDR(answer)
Value: 2014-10-15 17:21:29

As for why there isn't a "built-in variable":
(1) For queries, the information is already provided by other
mechanisms, such as the CDR function
(2) If you are monitoring the system, you can get exactly when the
channel was answered via the Newstate event
(3) No one (that I'm aware of) has provided such a patch. Asterisk is
open source. If you'd like to have something, write a patch, and
submit it back to the project. [2]

[1]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerEvent_News
tate
[2]
https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] AMI and CDR(answer)

2014-10-15 Thread Matthew Jordan
On Wed, Oct 15, 2014 at 5:10 PM, Murthy Gandikota  wrote:
> The CDR(disposition) is changing from context to context. Looks like AGI
> and AMI are in agreement. Still, it is a mystery why the helpful
> Asterisk folks
> haven't given us a built-in variable for when the call was first
> answered.
>

AMI informs you when a channel is answered via a Newstate event [1].
If you receive such an event and the ChannelState/ChannelStateDesc is
6/Up, then the channel has been answered.

Alternatively, you can query a channel for its Answer time using
either the CDR function, which will return back the CDR's view of the
time the channel was answered. If the channel was not answered, then
not surprisingly, the value is empty. An example output is show below:

Response: Success
Variable: CDR(answer)
Value: 2014-10-15 17:21:29

As for why there isn't a "built-in variable":
(1) For queries, the information is already provided by other
mechanisms, such as the CDR function
(2) If you are monitoring the system, you can get exactly when the
channel was answered via the Newstate event
(3) No one (that I'm aware of) has provided such a patch. Asterisk is
open source. If you'd like to have something, write a patch, and
submit it back to the project. [2]

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerEvent_Newstate
[2] https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] AMI and CDR(answer)

2014-10-15 Thread Murthy Gandikota
The CDR(disposition) is changing from context to context. Looks like AGI
and AMI are in agreement. Still, it is a mystery why the helpful
Asterisk folks
haven't given us a built-in variable for when the call was first
answered. 

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Wednesday, October 15, 2014 2:32 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

I traced CDR(disposition) which was set to "NO ANSWER". Apparently AMI
works the opposite of AGI in this case.

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Wednesday, October 15, 2014 1:08 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

Hi Mathew

The channel was answered. I have a small AGI script that would call the
getFullVariable("${CDR(answer)}") method in Java and print a Date/Time
string. When the AMI connection was on, a sound file is being played on.

May be you can help me in a different way. My goal is to obtain the
Date/Time when the caller was answered using "answer()" in the dialplan.
More specifically, when the NewChannelEvent is generated. I know I can
create a dialplan variable with strftime. But I would rather take 
advantage of the built-in readonly Asterisk variables before trying that
route.

I am grateful for your response and would appreciate additional help.

Thanks

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Wednesday, October 15, 2014 12:41 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

On Wed, Oct 15, 2014 at 1:44 PM, Murthy Gandikota 
wrote:
> Hi All
>
>
>
> I am unable to obtain CDR(answer) in AMI.
>
>
>
> Tried the following:
>
>
>
> $ telnet 127.0.0.1 5038
>
> Trying 127.0.0.1...
>
> Connected to localhost.
>
> Escape character is '^]'.
>
> Asterisk Call Manager/1.0
>
>
>
> Action: Login
>
> ActionID: 1
>
> Username: admin
>
> Secret: secret5
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(start)
>
>
>
> Response: Success
>
> Variable: CDR(start)
>
> Value: 2014-10-15 11:35:37
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(answer)
>
>
>
> Response: Success
>
> Variable: CDR(answer)
>
> Value:
>
>

Are you sure the channel is answered?

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] AMI and CDR(answer)

2014-10-15 Thread Murthy Gandikota
I traced CDR(disposition) which was set to "NO ANSWER". Apparently AMI
works the opposite of AGI in this case.

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Murthy
Gandikota
Sent: Wednesday, October 15, 2014 1:08 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

Hi Mathew

The channel was answered. I have a small AGI script that would call the
getFullVariable("${CDR(answer)}") method in Java and print a Date/Time
string. When the AMI connection was on, a sound file is being played on.

May be you can help me in a different way. My goal is to obtain the
Date/Time when the caller was answered using "answer()" in the dialplan.
More specifically, when the NewChannelEvent is generated. I know I can
create a dialplan variable with strftime. But I would rather take 
advantage of the built-in readonly Asterisk variables before trying that
route.

I am grateful for your response and would appreciate additional help.

Thanks

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Wednesday, October 15, 2014 12:41 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

On Wed, Oct 15, 2014 at 1:44 PM, Murthy Gandikota 
wrote:
> Hi All
>
>
>
> I am unable to obtain CDR(answer) in AMI.
>
>
>
> Tried the following:
>
>
>
> $ telnet 127.0.0.1 5038
>
> Trying 127.0.0.1...
>
> Connected to localhost.
>
> Escape character is '^]'.
>
> Asterisk Call Manager/1.0
>
>
>
> Action: Login
>
> ActionID: 1
>
> Username: admin
>
> Secret: secret5
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(start)
>
>
>
> Response: Success
>
> Variable: CDR(start)
>
> Value: 2014-10-15 11:35:37
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(answer)
>
>
>
> Response: Success
>
> Variable: CDR(answer)
>
> Value:
>
>

Are you sure the channel is answered?

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] AMI and CDR(answer)

2014-10-15 Thread Murthy Gandikota
Hi Mathew

The channel was answered. I have a small AGI script that would call the
getFullVariable("${CDR(answer)}") method in Java and print a Date/Time
string. When the AMI connection was on, a sound file is being played on.

May be you can help me in a different way. My goal is to obtain the
Date/Time when the caller was answered using "answer()" in the dialplan.
More specifically, when the NewChannelEvent is generated. I know I can
create a dialplan variable with strftime. But I would rather take 
advantage of the built-in readonly Asterisk variables before trying that
route.

I am grateful for your response and would appreciate additional help.

Thanks

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Wednesday, October 15, 2014 12:41 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

On Wed, Oct 15, 2014 at 1:44 PM, Murthy Gandikota 
wrote:
> Hi All
>
>
>
> I am unable to obtain CDR(answer) in AMI.
>
>
>
> Tried the following:
>
>
>
> $ telnet 127.0.0.1 5038
>
> Trying 127.0.0.1...
>
> Connected to localhost.
>
> Escape character is '^]'.
>
> Asterisk Call Manager/1.0
>
>
>
> Action: Login
>
> ActionID: 1
>
> Username: admin
>
> Secret: secret5
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(start)
>
>
>
> Response: Success
>
> Variable: CDR(start)
>
> Value: 2014-10-15 11:35:37
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(answer)
>
>
>
> Response: Success
>
> Variable: CDR(answer)
>
> Value:
>
>

Are you sure the channel is answered?

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] AMI and CDR(answer)

2014-10-15 Thread Matthew Jordan
On Wed, Oct 15, 2014 at 1:44 PM, Murthy Gandikota  wrote:
> Hi All
>
>
>
> I am unable to obtain CDR(answer) in AMI.
>
>
>
> Tried the following:
>
>
>
> $ telnet 127.0.0.1 5038
>
> Trying 127.0.0.1...
>
> Connected to localhost.
>
> Escape character is '^]'.
>
> Asterisk Call Manager/1.0
>
>
>
> Action: Login
>
> ActionID: 1
>
> Username: admin
>
> Secret: secret5
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(start)
>
>
>
> Response: Success
>
> Variable: CDR(start)
>
> Value: 2014-10-15 11:35:37
>
>
>
> Action: Getvar
>
> Channel: xxx
>
> Variable: CDR(answer)
>
>
>
> Response: Success
>
> Variable: CDR(answer)
>
> Value:
>
>

Are you sure the channel is answered?

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users