concurrent call tracking

Home » Asterisk Users » concurrent call tracking
Asterisk Users 4 Comments

On 11-05-11 12:57 PM, Skyler wrote:
> I would like to track/store concurrent call usage per user by
> day/week/month and get server totals by day/week/month. Google comes up with
> mostly info regarding concurrent call limits, though my goal is to calculate
> actual concurrent channel usage and add it into reporting. I’m using * 1.6.2
> + mysql – realtime (no gui). Any suggestions / open-source / AGI on where to
> start looking into implementing something like this?

Just use SNMP to get the channel usage. If you don’t want to use SNMP, then just
use something like GROUP(), GROUP_COUNT() and func_odbc to write channel usage
to the database. Something like….

[Outgoing]
exten => _NXXNXXXXXX,1,NoOp()
same => n,GoSub(subTotalCallCounter,start,1(outgoing))

[subTotalCallCounter]
exten => start,1,NoOp()
same => n,Set(GROUP(totalcalls)=${ARG1})
same => n,Set(ODBC_TOTAL_CALLS(${ARG1})=${GROUP_COUNT(${ARG1}@totalcalls)})
same => n,Return()

[Incoming]
exten => 4165551212,1,NoOp()
same => n,GoSub(subTotalCallCounter,start,1(incoming))

[LocalSets]
exten => _1XX,1,NoOp()
same => n,GoSub(subTotalCallCounter,start,1(internal))

func_odbc

4 thoughts on - concurrent call tracking

  • What I do is when ever a call comes in I update a table in MySQL to active = (active +1). On hang up I do active = (active -1).

    I have a cron that checks once a minute to see how many active and stores it along with epoch in db.

    I then have a graph that shows channel usage. If you want the code let me know.

  • How do you handle table locking in case more than 1 call arrives ‘at the
    same time?’

    How do you handle a crash?

    Using group() and group_count() with a bit of AMI to retrieve the count
    and stuff it in the database sounds like a ‘better practice.’

  • Thanks Dovid, if you don’t mind sharing the code and the dial plan side I’d
    like to take a look at it for sure. The dial plan example Leif replied with
    is pretty much what I was thinking, just didn’t have a clue how to go about
    it. 😉

    Haven’t figured out how I’m going to display the usage info either so if
    you don’t mind sharing the graph/code as well that would be sweet.

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Dovid Bender
    Sent: Wednesday, May 11, 2011 2:17 PM

    What I do is when ever a call comes in I update a table in MySQL to active =
    (active +1). On hang up I do active = (active -1).

    I have a cron that checks once a minute to see how many active and stores it
    along with epoch in db.

    I then have a graph that shows channel usage. If you want the code let me
    know.

  • Hi,

    this is my first post to mailing list, so sorry in case i’m doing something
    wrong.
    when i want to count concurent calls from particular user, i dont use any
    cron jobs or counters
    in dialplan, run query on cdr, something like:

    SEELCT dst, calldate, IF(action = ‘substract’, @count := @count – 1, @count
    := @count + 1)
    FROM
    (SELECT dst, calldate, ‘substract’ AS ‘action’
    FROM cdr
    WHERE calldate between ‘2011.05.12’ AND ‘2011.05.13’ AND
    src = “500”
    UNION
    SELECT dst, DATE_ADD(calldate, INTERVAL duration SECOND), ‘add’
    FROM cdr
    WHERE calldate between ‘2011.05.12’ AND ‘2011.05.13’ AND
    src = “500”)
    JOIN (SELECT @count := 0)
    ORDER BY calldate;