Author Topic: Asterisk 1.4.8 - warnings about DeadAGI on a live channel  (Read 13463 times)

jf647

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
The QM docs indicate to run queueDial.agi like this:

exten   => s,n,DeadAGI(queueDial.agi|${ARG3}|${ARG2}|${QMOUTQDIAL}|${CUT(CHANNEL,,1)})

Asterisk 1.4.8 came out yesterday, and the changelog indicates that this is not recommended:

2007-07-17 20:33 +0000 [r75437]  Russell Bryant <russell@digium.com>

        * res/res_agi.c: (issue #10210) Reported by: juggie Patches:
          10210-1.4-grr.patch uploaded by juggie (license #24) Tested by:
          juggie, blitzrage Log a warning if someone uses DeadAGI on a live
          channel.

And now this appears on my console and in my logs when I use the above dialplan snippet:

    -- Executing [s@macro-dialout:21] DeadAGI("SIP/491-98cc7860", "queueDial.agi|416XXXXXXX|Zap/R3/416XXXXXXX|cs_out|SIP/491") in new stack
[Jul 18 08:04:01] WARNING[29182]: res_agi.c:2086 deadagi_exec: Running DeadAGI on a live channel will cause problems, please use AGI
    -- Launched AGI Script /var/lib/asterisk/agi-bin/queueDial.agi

So what should I change?  If I switch to AGI, then nothing gets logged after the CONNECT event - if I hang up while the other end is ringing, I see no ABANDON event, and if I hang up after talking with the other end, no COMPLETEAGENT event is seen.

This means that I'm now going to have outbound calls that never end, right?

1.4.8 is required due to four critical security advisories that were posted to asterisk-users yesterday, so not upgrading isn't viable.

This is the change that seemed to prompt them to add the warning:

2007-07-17 20:01 +0000 [r75401-75403]  Russell Bryant <russell@digium.com>

        * main/pbx.c: (closes issue #10209) Reported by: juggie Patches:
          10209-trunk-2.patch uploaded by juggie Tested by: juggie,
          blitzrage In ast_pbx_run(), mark a channel as hung up after an
          application returned -1, or when it runs out of extensions to
          execute. This is so that code can detect that this channel has
          been hung up for things like making sure DeadAGI is used on
          actual dead channels, and is beneficial for other things, like
          making sure someone doesn't try to start spying on a channel that
          is about to go away.

Here's a link to the bug that this change fixed: http://bugs.digium.com/view.php?id=10209


revolution

  • Newbie
  • *
  • Posts: 23
  • Karma: 1
    • AOL Instant Messenger - DigressionTheory
    • View Profile
Re: Asterisk 1.4.8 - warnings about DeadAGI on a live channel
« Reply #1 on: July 19, 2007, 15:20:12 »
yeah that was a pretty unpleasant surprise for me as well...

jf647

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: Asterisk 1.4.8 - warnings about DeadAGI on a live channel
« Reply #2 on: July 20, 2007, 16:25:47 »
I've re-implemented queueDial.agi using AEL.  I need to clean it up a bit, then I'll post it here.

jf647

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: Asterisk 1.4.8 - warnings about DeadAGI on a live channel
« Reply #3 on: July 20, 2007, 17:45:42 »
Ok, here's my reimplementation of queueDial.agi in AEL:

Code: [Select]
macro qmoutqdial( clid, dialstring, queue, agent )
{

        start_dial_time = ${EPOCH};
        QueueLog(${queue}|${UNIQUEID}|NONE|ENTERQUEUE||${clid});
        Dial(${dialstring},,gtWM(queuelog_connect_event^${queue}^${UNIQUEID}^${agent}^${start_dial_time}));
        end_dial_time = ${EPOCH};
        verb = COMPLETECALLER;
        Hangup;
        catch h {
                if( ${ISNULL(${end_dial_time})} ) {
                        end_dial_time = ${EPOCH};
                }
                switch(${DIALSTATUS}) {
                        case BUSY:
                        case NOANSWER:
                        case CHANUNAVAIL:
                        case CONGESTION:
                        case CANCEL:
                                wait_time = ${end_dial_time} - ${start_dial_time};
                                verb = ABANDON;
                                QueueLog(${queue}|${UNIQUEID}|NONE|ABANDON|1|1|${wait_time});
                                break;
                        case ANSWER:
                                wait_time = ${end_dial_time} - ${start_dial_time} - ${ANSWEREDTIME};
                                if( ${ISNULL(${verb})} ) {
                                        verb = COMPLETEAGENT;
                                }
                                QueueLog(${queue}|${UNIQUEID}|${agent}|${verb}|${wait_time}|${ANSWEREDTIME});
                                break;
                        default:
                                NoOp(don't know how to handle ${DIALSTATUS});
                                break;
                }
        }

}

macro queuelog_connect_event( queue, uniqueid, agent, start_dial_time )
{

        wait_time = ${EPOCH} - ${start_dial_time};
        QueueLog(${queue}|${uniqueid}|${agent}|CONNECT|${wait_time});

}

I have tested this with three types of calls typically made via the AGI script:

- agent hangs up before call connects
- call connects and agent hangs up
- call connects and caller hangs up

and it seems to work.

For those of you running 1.2 without the AEL2 patch, this is what it compiles to in extensions.conf format.  This is the functional equivalent, but as it's the deparsed output from what the above AEL compiles to, it's not meant to be pretty:

Code: [Select]
[macro-qmoutqdial]
exten => s,1,Set(clid=${ARG1})
exten => s,2,Set(dialstring=${ARG2})
exten => s,3,Set(queue=${ARG3})
exten => s,4,Set(agent=${ARG4})
exten => s,5,Set(start_dial_time=$[${EPOCH}])
exten => s,6,QueueLog(${queue}|${UNIQUEID}|NONE|ENTERQUEUE||${clid})
exten => s,7,Dial(${dialstring}||gtWM(queuelog_connect_event^${queue}^${UNIQUEID}^${agent}^${start_dial_time}))
exten => s,8,Set(end_dial_time=$[${EPOCH}])
exten => s,9,Set(verb=$[COMPLETECALLER])
exten => s,10,Hangup()
exten => h,1,GotoIf($[${ISNULL(${end_dial_time})} ]?2:3)
exten => h,2,Set(end_dial_time=$[${EPOCH}])
exten => h,3,NoOp(Finish if-catch-h-1-2)
exten => h,4,Goto(sw-3-${DIALSTATUS}|10)
exten => h,5,NoOp(Finish switch-catch-h-1-3)
exten => _sw-3-.,10,NoOp(don't know how to handle ${DIALSTATUS})
exten => _sw-3-.,11,Goto(h|5)
exten => sw-3-ANSWER,10,Set(wait_time=$[${end_dial_time} - ${start_dial_time} - ${ANSWEREDTIME}])
exten => sw-3-ANSWER,11,GotoIf($[${ISNULL(${verb})} ]?12:13)
exten => sw-3-ANSWER,12,Set(verb=$[COMPLETEAGENT])
exten => sw-3-ANSWER,13,NoOp(Finish if-sw-catch-h-1-ANSWER-3-4)
exten => sw-3-ANSWER,14,QueueLog(${queue}|${UNIQUEID}|${agent}|${verb}|${wait_time}|${ANSWEREDTIME})
exten => sw-3-ANSWER,15,Goto(h|5)
exten => sw-3-CANCEL,10,Set(wait_time=$[${end_dial_time} - ${start_dial_time}])
exten => sw-3-CANCEL,11,Set(verb=$[ABANDON])
exten => sw-3-CANCEL,12,QueueLog(${queue}|${UNIQUEID}|NONE|ABANDON|1|1|${wait_time})
exten => sw-3-CANCEL,13,Goto(h|5)
exten => sw-3-CONGESTION,10,Goto(sw-3-CANCEL|10)
exten => sw-3-CHANUNAVAIL,10,Goto(sw-3-CONGESTION|10)
exten => sw-3-NOANSWER,10,Goto(sw-3-CHANUNAVAIL|10)
exten => sw-3-BUSY,10,Goto(sw-3-NOANSWER|10)


[macro-queuelog_connect_event]
exten => s,1,Set(queue=${ARG1})
exten => s,2,Set(uniqueid=${ARG2})
exten => s,3,Set(agent=${ARG3})
exten => s,4,Set(start_dial_time=${ARG4})
exten => s,5,Set(wait_time=$[${EPOCH} - ${start_dial_time}])
exten => s,6,QueueLog(${queue}|${uniqueid}|${agent}|CONNECT|${wait_time})

I hope others find this useful and that it maybe makes it into QM as an alternative to queueDial.agi.  I must admit that I was never a fan of forking a process for every outbound call.

Regards

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Asterisk 1.4.8 - warnings about DeadAGI on a live channel
« Reply #4 on: August 01, 2007, 10:29:39 »
Looks great. If that's okay to you, we'll add the AEL version together with the next version of queueDial.agi.