[asterisk-users] realtime queue callers

Atis Lezdins atis at iq-labs.net
Tue Apr 29 05:31:06 CDT 2008


On Tue, Apr 29, 2008 at 1:22 PM, Vieri <rentorbuy at yahoo.com> wrote:
>
>
>  --- Atis Lezdins <atis at iq-labs.net> wrote:
>
>  > On Mon, Apr 28, 2008 at 8:34 PM, Vieri
>  > <rentorbuy at yahoo.com> wrote:
>  > > How can I get a list of the callers within a
>  > specific
>  > >  queue at any given moment?
>  > >
>  > >  I need to get the caller IDs of all active calls
>  > in a
>  > >  queue then send them out via a udp socket to a
>  > >  listening application on the network (the only
>  > data I
>  > >  need to send are two fields: current timestamp
>  > and
>  > >  caller id of active queue calls).
>  > >
>  > >  I have almost all the elements to do this except
>  > the
>  > >  best method to retrieve "all active caller ids
>  > from a
>  > >  given queue". I was wondering if someone already
>  > did
>  > >  this.
>  > >
>  > >  I tried writing a script on the server which
>  > connects
>  > >  to the Manager API and receives queue events. I'm
>  > >  basically using the AgentCalled event but it
>  > seems
>  > >  clumsy to efficiently detect when the call has
>  > ended
>  > >  (connect or abandon) and thus update the remote
>  > UDP
>  > >  listening app.
>  > >
>  > >  I also tried another way by guessing which calls
>  > are
>  > >  active via tailing and grepping
>  > >  /var/log/asterisk/queue_log.
>  > >
>  > >  Finally, a third script method tried parsing the
>  > >  output of "show queue XXXX" right after
>  > "Callers:".
>  > >  Maybe this is all I really need for my purposes
>  > >  (although less efficient and less "real-time"
>  > than the
>  > >  queue events method because I would need to
>  > >  periodically poll the whole queue statistics) but
>  > I
>  > >  only get the originating channel and the wait
>  > time. I
>  > >  would require correlating the data to the
>  > caller's ID.
>  > >
>  > >  Has anyone already done something similar?
>  > >  A simple example/script/suggestion would be
>  > greatly
>  > >  appreciated.
>  >
>  > I'm not sure that this is what exactly You need, but
>  > I have a patch
>  > for app_queue
>  > that will store and update queue callers (as well as
>  > update lots of
>  > fields for queue members) in realtime mysql table.
>  > This allows to do
>  > many requests for current queue state simultenously,
>  > and moves load
>  > from asterisk to mysql (which can be on separate
>  > machine). So,
>  > generally to get active callers with all their
>  > callerid/channel info
>  > You will have to do just "SELECT * FROM
>  > queue_callers".
>  >
>  > It's not very finalized, so I haven't yet posted
>  > that to Digium for
>  > inclusion in next asterisk versions, but I intend to
>  > do that in
>  > future. It's been working stable on our production
>  > for several months.
>  >
>  > If You're interested, please reply, and I'll try to
>  > separate that
>  > patch out from other our patches.
>  > Currently I have it updated for 1.4.19, but also
>  > have some version for 1.4.14
>
>  Thanks Atis.
>  That patch sounds really neat. Hope it gets into *
>  soon.
>  Just a doubt: suppose the mysql daemon dies for some
>  reason. Will the patched app_queue still handle calls
>  and not hang?
>

It should, as asterisk throws INSERTs, UPDATEs and DELETEs for
changing data (queue callers and queue member status), plus it loads
existing queue members trough SELECT (as it's now with realtime queue
members, just some extra fields). So, I suppose if MySQL dies in
middle of operation, SELECT should fail and Asterisk should just
continue with what it has in memory. Btw, You should be able to also
use static or dynamic queue members (not realtime) in combination with
realtime queue calls.

Btw, I never experienced that MySQL dies, it's more often that Asterisk dies.

So, are You interested in applying this patch yourself?

Regards,
Atis


-- 
Atis Lezdins,
VoIP Project Manager / Developer,
atis at iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835



More information about the asterisk-users mailing list