--- app_queue.c.orig 2008-11-24 14:56:38.000000000 -0500 +++ app_queue.c 2008-11-24 14:56:56.000000000 -0500 @@ -764,6 +764,7 @@ int randomperiodicannounce; /*!< Are periodic announcments randomly chosen */ int roundingseconds; /*!< How many seconds do we round to? */ int holdtime; /*!< Current avg holdtime, based on an exponential average */ + int talktime; /*!< Current avg talktime, based on the same exponential average */ int callscompleted; /*!< Number of queue calls completed */ int callsabandoned; /*!< Number of queue calls abandoned */ int servicelevel; /*!< seconds setting for servicelevel*/ @@ -885,8 +886,8 @@ sl = 100 * ((float) qe->parent->callscompletedinsl / (float) qe->parent->callscompleted); snprintf(interfacevar, sizeof(interfacevar), - "QUEUENAME=%s,QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", - qe->parent->name, qe->parent->maxlen, int2strat(qe->parent->strategy), qe->parent->count, qe->parent->holdtime, qe->parent->callscompleted, + "QUEUENAME=%s,QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUETALKTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", + qe->parent->name, qe->parent->maxlen, int2strat(qe->parent->strategy), qe->parent->count, qe->parent->holdtime, qe->parent->talktime, qe->parent->callscompleted, qe->parent->callsabandoned, qe->parent->servicelevel, sl); pbx_builtin_setvar_multiple(qe->chan, interfacevar); @@ -3116,8 +3117,10 @@ * \brief update the queue status * \retval Always 0 */ -static int update_queue(struct call_queue *q, struct member *member, int callcompletedinsl) +static int update_queue(struct call_queue *q, struct member *member, int callcompletedinsl, int newtalktime) { + int oldtalktime; + struct member *mem; struct call_queue *qtmp; struct ao2_iterator queue_iter; @@ -3146,6 +3149,9 @@ q->callscompleted++; if (callcompletedinsl) q->callscompletedinsl++; + /* Calculate talktime using the same exponential average as holdtime code*/ + oldtalktime = q->talktime; + q->talktime = (((oldtalktime << 2) - oldtalktime) + newtalktime) >> 2; ao2_unlock(q); return 0; } @@ -3301,7 +3307,7 @@ new_chan->exten, new_chan->context, (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos); - update_queue(qe->parent, member, callcompletedinsl); + update_queue(qe->parent, member, callcompletedinsl, (time(NULL) - callstart)); if (!(datastore = ast_channel_datastore_find(new_chan, &queue_transfer_info, NULL))) { ast_log(LOG_WARNING, "Can't find the queue_transfer datastore.\n"); @@ -5091,8 +5097,8 @@ } snprintf(interfacevar, sizeof(interfacevar), - "QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", - q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->callscompleted, q->callsabandoned, q->servicelevel, sl); + "QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUETALKTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", + q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, q->callsabandoned, q->servicelevel, sl); pbx_builtin_setvar_multiple(chan, interfacevar); } @@ -5712,8 +5718,8 @@ sl = 0; if (q->callscompleted > 0) sl = 100 * ((float) q->callscompletedinsl / (float) q->callscompleted); - ast_str_append(&out, 0, ") in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds", - int2strat(q->strategy), q->holdtime, q->weight, + ast_str_append(&out, 0, ") in '%s' strategy (%ds holdtime, %ds talktime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds", + int2strat(q->strategy), q->holdtime, q->talktime, q->weight, q->callscompleted, q->callsabandoned,sl,q->servicelevel); do_print(s, fd, out->str); if (!ao2_container_count(q->members)) @@ -5918,10 +5924,11 @@ "Available: %d\r\n" "Callers: %d\r\n" "HoldTime: %d\r\n" + "TalkTime: %d\r\n" "LongestHoldTime: %d\r\n" "%s" "\r\n", - q->name, qmemcount, qmemavail, qchancount, q->holdtime, qlongestholdtime, idText); + q->name, qmemcount, qmemavail, qchancount, q->holdtime, q->talktime, qlongestholdtime, idText); } ao2_unlock(q); queue_unref(q); @@ -5968,6 +5975,7 @@ "Strategy: %s\r\n" "Calls: %d\r\n" "Holdtime: %d\r\n" + "TalkTime: %d\r\n" "Completed: %d\r\n" "Abandoned: %d\r\n" "ServiceLevel: %d\r\n" @@ -5975,7 +5983,7 @@ "Weight: %d\r\n" "%s" "\r\n", - q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->callscompleted, + q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, q->callsabandoned, q->servicelevel, sl, q->weight, idText); /* List Queue Members */ mem_iter = ao2_iterator_init(q->members, 0);