forked from roramirez/qpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Port patches Asterisk 13.7.X for app_queue
Add Lastpause field of queue member http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=f299dc0d76a362a63222195da05af48a435d394f Fix preserved reason of pause when Asterisk is restared http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=378fed4900a308965a197fd4f29bd953c05efb46 Show reason of pause on CLI http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=f2a84b500d0706ce411940e72562118c263ab9be Added reason pause of member http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=92fa8d1e0ec9bd65622e6302508c01cd71381f63
- Loading branch information
Showing
1 changed file
with
255 additions
and
0 deletions.
There are no files selected for viewing
255 changes: 255 additions & 0 deletions
255
patches/asterisk/app_queue-pausereason_timelastpause-13.7.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
From 46a6cf6f29964e57be7800dfe3022cd8a1882a74 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= <[email protected]> | ||
Date: Tue, 26 Jan 2016 23:11:16 -0300 | ||
Subject: [PATCH] Port patches to 13.7.X version | ||
|
||
* app_queue: Add Lastpause field of queue member | ||
http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=f299dc0d76a362a63222195da05af48a435d394f | ||
|
||
* app_queue: Fix preserved reason of pause when Asterisk is restared | ||
http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=378fed4900a308965a197fd4f29bd953c05efb46 | ||
|
||
* app_queue: Show reason of pause on CLI | ||
http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=f2a84b500d0706ce411940e72562118c263ab9be | ||
|
||
* app_queue: Added reason pause of member | ||
http://git.asterisk.org/gitweb/?p=asterisk/asterisk.git;a=commit;h=92fa8d1e0ec9bd65622e6302508c01cd71381f63 | ||
|
||
--- | ||
apps/app_queue.c | 71 ++++++++++++++++++++++++++++++++++++++++++----------- | ||
1 files changed, 56 insertions(+), 15 deletions(-) | ||
|
||
diff --git a/apps/app_queue.c b/apps/app_queue.c | ||
index 5a8dcd2..9aacd57 100644 | ||
--- a/apps/app_queue.c | ||
+++ b/apps/app_queue.c | ||
@@ -1,7 +1,7 @@ | ||
/* | ||
* Asterisk -- An open source telephony toolkit. | ||
* | ||
- * Copyright (C) 1999 - 2006, Digium, Inc. | ||
+ * Copyright (C) 1999 - 2016, Digium, Inc. | ||
* | ||
* Mark Spencer <[email protected]> | ||
* | ||
@@ -982,6 +982,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") | ||
<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="Status"> | ||
<para>The numeric device state status of the queue member.</para> | ||
<enumlist> | ||
@@ -1002,6 +1005,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") | ||
<enum name="1"/> | ||
</enumlist> | ||
</parameter> | ||
+ <parameter name="PausedReason"> | ||
+ <para>If set when paused, the reason the queue member was paused.</para> | ||
+ </parameter> | ||
<parameter name="Ringinuse"> | ||
<enumlist> | ||
<enum name="0"/> | ||
@@ -1493,8 +1499,10 @@ struct member { | ||
int realtime; /*!< Is this member realtime? */ | ||
int status; /*!< Status of queue member */ | ||
int paused; /*!< Are we paused (not accepting calls)? */ | ||
+ 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 */ | ||
struct call_queue *lastqueue; /*!< Last queue we received a call */ | ||
unsigned int dead:1; /*!< Used to detect members deleted in realtime */ | ||
unsigned int delme:1; /*!< Flag to delete entry on reload */ | ||
@@ -2155,7 +2163,7 @@ static void queue_publish_member_blob(struct stasis_message_type *type, struct a | ||
|
||
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}", | ||
+ 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}", | ||
"Queue", q->name, | ||
"MemberName", mem->membername, | ||
"Interface", mem->interface, | ||
@@ -2164,8 +2172,10 @@ static struct ast_json *queue_member_blob_create(struct call_queue *q, struct me | ||
"Penalty", mem->penalty, | ||
"CallsTaken", mem->calls, | ||
"LastCall", (int)mem->lastcall, | ||
+ "LastPause", (int)mem->lastpause, | ||
"Status", mem->status, | ||
"Paused", mem->paused, | ||
+ "PausedReason", mem->reason_paused, | ||
"Ringinuse", mem->ringinuse); | ||
} | ||
|
||
@@ -2476,6 +2486,9 @@ static struct member *create_queue_member(const char *interface, const char *mem | ||
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)); | ||
@@ -6877,13 +6890,14 @@ static void dump_queue_members(struct call_queue *pm_queue) | ||
continue; | ||
} | ||
|
||
- ast_str_append(&value, 0, "%s%s;%d;%d;%s;%s", | ||
+ ast_str_append(&value, 0, "%s%s;%d;%d;%s;%s;%s", | ||
ast_str_strlen(value) ? "|" : "", | ||
cur_member->interface, | ||
cur_member->penalty, | ||
cur_member->paused, | ||
cur_member->membername, | ||
- cur_member->state_interface); | ||
+ cur_member->state_interface, | ||
+ cur_member->reason_paused); | ||
|
||
ao2_ref(cur_member, -1); | ||
} | ||
@@ -6960,7 +6974,7 @@ static int remove_from_queue(const char *queuename, const char *interface) | ||
* \retval RES_EXISTS queue exists but no members | ||
* \retval RES_OUT_OF_MEMORY queue exists but not enough memory to create member | ||
*/ | ||
-static int add_to_queue(const char *queuename, const char *interface, const char *membername, int penalty, int paused, int dump, const char *state_interface) | ||
+static int add_to_queue(const char *queuename, const char *interface, const char *membername, int penalty, int paused, int dump, const char *state_interface, const char *reason_paused) | ||
{ | ||
struct call_queue *q; | ||
struct member *new_member, *old_member; | ||
@@ -6977,6 +6991,9 @@ static int add_to_queue(const char *queuename, const char *interface, const char | ||
if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface, q->ringinuse))) { | ||
new_member->ringinuse = q->ringinuse; | ||
new_member->dynamic = 1; | ||
+ if (reason_paused) { | ||
+ ast_copy_string(new_member->reason_paused, reason_paused, sizeof(new_member->reason_paused)); | ||
+ } | ||
member_add_to_queue(q, new_member); | ||
queue_publish_member_blob(queue_member_added_type(), queue_member_blob_create(q, new_member)); | ||
|
||
@@ -7050,6 +7067,15 @@ static void set_queue_member_pause(struct call_queue *q, struct member *mem, con | ||
} | ||
|
||
mem->paused = paused; | ||
+ if (paused) { | ||
+ 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)); | ||
+ } | ||
+ | ||
ast_devstate_changed(mem->paused ? QUEUE_PAUSED_DEVSTATE : QUEUE_UNPAUSED_DEVSTATE, | ||
AST_DEVSTATE_CACHABLE, "Queue:%s_pause_%s", q->name, mem->interface); | ||
|
||
@@ -7325,6 +7351,7 @@ static void reload_queue_members(void) | ||
int penalty = 0; | ||
char *paused_tok; | ||
int paused = 0; | ||
+ char *reason_paused; | ||
struct ast_db_entry *db_tree; | ||
struct ast_db_entry *entry; | ||
struct call_queue *cur_queue; | ||
@@ -7371,6 +7398,7 @@ static void reload_queue_members(void) | ||
paused_tok = strsep(&member, ";"); | ||
membername = strsep(&member, ";"); | ||
state_interface = strsep(&member, ";"); | ||
+ reason_paused = strsep(&member, ";"); | ||
|
||
if (!penalty_tok) { | ||
ast_log(LOG_WARNING, "Error parsing persistent member string for '%s' (penalty)\n", queue_name); | ||
@@ -7392,9 +7420,10 @@ static void reload_queue_members(void) | ||
break; | ||
} | ||
|
||
- ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused); | ||
+ ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d ReasonPause: %s\n", | ||
+ queue_name, interface, membername, penalty, paused, reason_paused); | ||
|
||
- if (add_to_queue(queue_name, interface, membername, penalty, paused, 0, state_interface) == RES_OUTOFMEMORY) { | ||
+ if (add_to_queue(queue_name, interface, membername, penalty, paused, 0, state_interface, reason_paused) == RES_OUTOFMEMORY) { | ||
ast_log(LOG_ERROR, "Out of Memory when reloading persistent queue member\n"); | ||
break; | ||
} | ||
@@ -7591,7 +7620,7 @@ static int aqm_exec(struct ast_channel *chan, const char *data) | ||
} | ||
} | ||
|
||
- switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface)) { | ||
+ switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface, NULL)) { | ||
case RES_OKAY: | ||
if (ast_strlen_zero(args.membername) || !log_membername_as_agent) { | ||
ast_queue_log(args.queuename, ast_channel_uniqueid(chan), args.interface, "ADDMEMBER", "%s", ""); | ||
@@ -9135,10 +9164,20 @@ static char *__queues_show(struct mansession *s, int fd, int argc, const char * | ||
|
||
ast_str_append(&out, 0, " (ringinuse %s)", mem->ringinuse ? "enabled" : "disabled"); | ||
|
||
- ast_str_append(&out, 0, "%s%s%s%s%s%s%s%s%s (%s%s%s)", | ||
+ ast_str_append(&out, 0, "%s%s%s%s%s%s", | ||
mem->dynamic ? ast_term_color(COLOR_CYAN, COLOR_BLACK) : "", mem->dynamic ? " (dynamic)" : "", ast_term_reset(), | ||
- mem->realtime ? ast_term_color(COLOR_MAGENTA, COLOR_BLACK) : "", mem->realtime ? " (realtime)" : "", ast_term_reset(), | ||
- mem->paused ? ast_term_color(COLOR_BROWN, COLOR_BLACK) : "", mem->paused ? " (paused)" : "", ast_term_reset(), | ||
+ mem->realtime ? ast_term_color(COLOR_MAGENTA, COLOR_BLACK) : "", mem->realtime ? " (realtime)" : "", ast_term_reset()); | ||
+ if (mem->paused) { | ||
+ if (ast_strlen_zero(mem->reason_paused)) { | ||
+ 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 was %ld secs ago)%s", ast_term_color(COLOR_BROWN, COLOR_BLACK), | ||
+ mem->reason_paused, (long) (time(NULL) - mem->lastcall), ast_term_reset()); | ||
+ } | ||
+ } | ||
+ | ||
+ ast_str_append(&out, 0, " (%s%s%s)", | ||
ast_term_color( | ||
mem->status == AST_DEVICE_UNAVAILABLE || mem->status == AST_DEVICE_UNKNOWN ? | ||
COLOR_RED : COLOR_GREEN, COLOR_BLACK), | ||
@@ -9506,12 +9545,14 @@ static int manager_queues_status(struct mansession *s, const struct message *m) | ||
"Penalty: %d\r\n" | ||
"CallsTaken: %d\r\n" | ||
"LastCall: %d\r\n" | ||
+ "LastPause: %d\r\n" | ||
"Status: %d\r\n" | ||
"Paused: %d\r\n" | ||
+ "PausedReason: %s\r\n" | ||
"%s" | ||
"\r\n", | ||
q->name, mem->membername, mem->interface, mem->state_interface, mem->dynamic ? "dynamic" : "static", | ||
- mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText); | ||
+ mem->penalty, mem->calls, (int)mem->lastcall, (int)mem->lastpause, mem->status, mem->paused, mem->reason_paused, idText); | ||
++q_items; | ||
} | ||
ao2_ref(mem, -1); | ||
@@ -9587,7 +9628,7 @@ static int manager_add_queue_member(struct mansession *s, const struct message * | ||
paused = abs(ast_true(paused_s)); | ||
} | ||
|
||
- switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface)) { | ||
+ switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface, NULL)) { | ||
case RES_OKAY: | ||
if (ast_strlen_zero(membername) || !log_membername_as_agent) { | ||
ast_queue_log(queuename, "MANAGER", interface, "ADDMEMBER", "%s", paused ? "PAUSED" : ""); | ||
@@ -9665,7 +9706,7 @@ static int manager_pause_queue_member(struct mansession *s, const struct message | ||
interface = astman_get_header(m, "Interface"); | ||
paused_s = astman_get_header(m, "Paused"); | ||
queuename = astman_get_header(m, "Queue"); /* Optional - if not supplied, pause the given Interface in all queues */ | ||
- reason = astman_get_header(m, "Reason"); /* Optional - Only used for logging purposes */ | ||
+ reason = astman_get_header(m, "Reason"); /* Optional */ | ||
|
||
if (ast_strlen_zero(interface) || ast_strlen_zero(paused_s)) { | ||
astman_send_error(s, m, "Need 'Interface' and 'Paused' parameters."); | ||
@@ -9893,7 +9934,7 @@ static char *handle_queue_add_member(struct ast_cli_entry *e, int cmd, struct as | ||
state_interface = a->argv[11]; | ||
} | ||
|
||
- switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface)) { | ||
+ switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface, NULL)) { | ||
case RES_OKAY: | ||
if (ast_strlen_zero(membername) || !log_membername_as_agent) { | ||
ast_queue_log(queuename, "CLI", interface, "ADDMEMBER", "%s", ""); | ||
-- | ||
1.7.2.5 | ||
|