[Asterisk-code-review] app queue: Add Lastpause field of queue member (asterisk[master])
Rodrigo Ramirez Norambuena
asteriskteam at digium.com
Wed Feb 3 10:43:24 CST 2016
Rodrigo Ramirez Norambuena has uploaded a new change for review.
https://gerrit.asterisk.org/2155
Change subject: app_queue: Add Lastpause field of queue member
......................................................................
app_queue: Add Lastpause field of queue member
Add time when started a the last pause for a queue member for
QueueMemberStatus ami event.
Also show accumulate time in seconds when started a pause for a queue
member to CLI command 'queue show'.
ASTERISK-16394 #close
Change-Id: I4b12aa3b2efa8d02939db3e13712510b4879865c
---
M CHANGES
M apps/app_queue.c
2 files changed, 21 insertions(+), 6 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/55/2155/1
diff --git a/CHANGES b/CHANGES
index 173a411..74919b7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -200,6 +200,11 @@
-------------------
* Added field ReasonPause on QueueMemberStatus if set when paused, the reason
the queue member was paused.
+ * Added field LastPause on QueueMemberStatus for time when started the last
+ pause for a queue member.
+ * Show the time when started the last pause for queue member on CLI for command
+ 'queue show'.
+
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 13.7.0 to Asterisk 13.8.0 ------------
diff --git a/apps/app_queue.c b/apps/app_queue.c
index ac105e4..15f32fa 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1022,6 +1022,9 @@
<parameter name="LastCall">
<para>The time this member last took a call, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
</parameter>
+ <parameter name="LastPause">
+ <para>The time when started last paused the queue member.</para>
+ </parameter>
<parameter name="InCall">
<para>Set to 1 if member is in call. Set to 0 after LastCall time is updated.</para>
<enumlist>
@@ -1546,6 +1549,7 @@
char reason_paused[80]; /*!< Reason of paused if member is paused */
int queuepos; /*!< In what order (pertains to certain strategies) should this member be called? */
time_t lastcall; /*!< When last successful call was hungup */
+ time_t lastpause; /*!< When started the last pause */
unsigned int in_call:1; /*!< True if member is still in call. (so lastcall is not actual) */
struct call_queue *lastqueue; /*!< Last queue we received a call */
unsigned int dead:1; /*!< Used to detect members deleted in realtime */
@@ -2184,7 +2188,7 @@
static struct ast_json *queue_member_blob_create(struct call_queue *q, struct member *mem)
{
- return ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: i, s: i, s: i, s: i, s: i, s: i, s: s, s: i}",
+ return ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: i, s: i, s: i, s: i, s: i, s: i, s: i, s: s, s: i}",
"Queue", q->name,
"MemberName", mem->membername,
"Interface", mem->interface,
@@ -2193,6 +2197,7 @@
"Penalty", mem->penalty,
"CallsTaken", mem->calls,
"LastCall", (int)mem->lastcall,
+ "LastPause", (int)mem->lastpause,
"InCall", mem->in_call,
"Status", mem->status,
"Paused", mem->paused,
@@ -2514,6 +2519,9 @@
cur->ringinuse = ringinuse;
cur->penalty = penalty;
cur->paused = paused;
+ if (paused) {
+ time(&cur->lastpause); /* Update time of last pause */
+ }
ast_copy_string(cur->interface, interface, sizeof(cur->interface));
if (!ast_strlen_zero(state_interface)) {
ast_copy_string(cur->state_interface, state_interface, sizeof(cur->state_interface));
@@ -7139,6 +7147,7 @@
if (!ast_strlen_zero(reason)) {
ast_copy_string(mem->reason_paused, reason, sizeof(mem->reason_paused));
}
+ time(&mem->lastpause); /* update last pause field */
} else {
ast_copy_string(mem->reason_paused, "", sizeof(mem->reason_paused));
}
@@ -9321,11 +9330,11 @@
mem->in_call ? ast_term_color(COLOR_BROWN, COLOR_BLACK) : "", mem->in_call ? " (in call)" : "", ast_term_reset());
if (mem->paused) {
if (ast_strlen_zero(mem->reason_paused)) {
- ast_str_append(&out, 0, " %s(paused)%s",
- ast_term_color(COLOR_BROWN, COLOR_BLACK), ast_term_reset());
+ ast_str_append(&out, 0, " %s(paused was %ld secs ago)%s",
+ ast_term_color(COLOR_BROWN, COLOR_BLACK), (long) (time(NULL) - mem->lastpause), ast_term_reset());
} else {
- ast_str_append(&out, 0, " %s(paused:%s)%s", ast_term_color(COLOR_BROWN, COLOR_BLACK),
- mem->reason_paused, ast_term_reset());
+ ast_str_append(&out, 0, " %s(paused:%s was %ld secs ago)%s", ast_term_color(COLOR_BROWN, COLOR_BLACK),
+ mem->reason_paused, (long) (time(NULL) - mem->lastcall), ast_term_reset());
}
}
@@ -9697,6 +9706,7 @@
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
"LastCall: %d\r\n"
+ "LastPause: %d\r\n"
"InCall: %d\r\n"
"Status: %d\r\n"
"Paused: %d\r\n"
@@ -9704,7 +9714,7 @@
"%s"
"\r\n",
q->name, mem->membername, mem->interface, mem->state_interface, mem->dynamic ? "dynamic" : "static",
- mem->penalty, mem->calls, (int)mem->lastcall, mem->in_call, mem->status,
+ mem->penalty, mem->calls, (int)mem->lastcall, (int)mem->lastpause, mem->in_call, mem->status,
mem->paused, mem->reason_paused, idText);
++q_items;
}
--
To view, visit https://gerrit.asterisk.org/2155
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b12aa3b2efa8d02939db3e13712510b4879865c
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>
More information about the asterisk-code-review
mailing list