<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18030">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ami: Allow events to be globally disabled.<br><br>The disabledevents setting has been added to the general section<br>in manager.conf, which allows users to specify events that<br>should be globally disabled and not sent to any AMI listeners.<br><br>This allows for processing of these AMI events to end sooner and,<br>for frequent AMI events such as Newexten which users may not have<br>any need for, allows them to not be processed. Additionally, it also<br>cleans up core debug as previously when debug was 3 or higher,<br>the debug was constantly spammed by "Analyzing AMI event" messages<br>along with a complete dump of the event contents (often for Newexten).<br><br>ASTERISK-29853 #close<br><br>Change-Id: Id42b9a3722a1f460d745cad1ebc47c537fd4f205<br>---<br>M configs/samples/manager.conf.sample<br>A doc/CHANGES-staging/manager_disable.txt<br>M main/manager.c<br>3 files changed, 45 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/30/18030/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/manager.conf.sample b/configs/samples/manager.conf.sample</span><br><span>index 405e0d3..342f290 100644</span><br><span>--- a/configs/samples/manager.conf.sample</span><br><span>+++ b/configs/samples/manager.conf.sample</span><br><span>@@ -79,7 +79,18 @@</span><br><span> ; on a action=waitevent request (actually its httptimeout-10)</span><br><span> ; c) httptimeout is also the amount of time the webserver keeps</span><br><span> ; a http session alive after completing a successful action</span><br><span style="color: hsl(120, 100%, 40%);">+;</span><br><span style="color: hsl(120, 100%, 40%);">+; disabledevents specifies AMI events which should be completely globally disabled.</span><br><span style="color: hsl(120, 100%, 40%);">+; These events will not be available to any AMI listeners. Use this to disable</span><br><span style="color: hsl(120, 100%, 40%);">+; frequent events which are not desired for any listeners. Default</span><br><span style="color: hsl(120, 100%, 40%);">+; is no events are globally disabled. Event names are case-sensitive.</span><br><span style="color: hsl(120, 100%, 40%);">+; Events disabled in stasis.conf do not also need to be disabled here.</span><br><span style="color: hsl(120, 100%, 40%);">+; If you don't want to completely disable an AMI event, also consider the</span><br><span style="color: hsl(120, 100%, 40%);">+; filter option available on a per-manager user basis to block unwanted</span><br><span style="color: hsl(120, 100%, 40%);">+; events from being received in a stream (as opposed to this option which</span><br><span style="color: hsl(120, 100%, 40%);">+; would prevent specified events from being generated at all).</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+;disabledevents = Newexten,Varset</span><br><span> </span><br><span> ;[mark]</span><br><span> ;secret = mysecret</span><br><span>diff --git a/doc/CHANGES-staging/manager_disable.txt b/doc/CHANGES-staging/manager_disable.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..762ceca</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/manager_disable.txt</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: ami</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AMI events can now be globally disabled using</span><br><span style="color: hsl(120, 100%, 40%);">+the disabledevents [general] setting.</span><br><span>diff --git a/main/manager.c b/main/manager.c</span><br><span>index 588f144..f6feb8e 100644</span><br><span>--- a/main/manager.c</span><br><span>+++ b/main/manager.c</span><br><span>@@ -1479,6 +1479,7 @@</span><br><span> static int authtimeout;</span><br><span> static int authlimit;</span><br><span> static char *manager_channelvars;</span><br><span style="color: hsl(120, 100%, 40%);">+static char *manager_disabledevents;</span><br><span> </span><br><span> #define DEFAULT_REALM "asterisk"</span><br><span> static char global_realm[MAXHOSTNAMELEN]; /*!< Default realm */</span><br><span>@@ -7232,6 +7233,15 @@</span><br><span> va_list ap;</span><br><span> int res;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(manager_disabledevents)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strstr(manager_disabledevents, event)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "AMI Event '%s' is globally disabled, skipping\n", event);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Event is globally disabled */</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(sessions);</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (!any_manager_listeners(sessions)) {</span><br><span> /* Nobody is listening */</span><br><span> ao2_cleanup(sessions);</span><br><span>@@ -8696,6 +8706,7 @@</span><br><span> ast_cli(a->fd, FORMAT, "Display connects:", AST_CLI_YESNO(displayconnects));</span><br><span> ast_cli(a->fd, FORMAT, "Timestamp events:", AST_CLI_YESNO(timestampevents));</span><br><span> ast_cli(a->fd, FORMAT, "Channel vars:", S_OR(manager_channelvars, ""));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, FORMAT, "Disabled events:", S_OR(manager_disabledevents, ""));</span><br><span> ast_cli(a->fd, FORMAT, "Debug:", AST_CLI_YESNO(manager_debug));</span><br><span> #undef FORMAT</span><br><span> #undef FORMAT2</span><br><span>@@ -8916,10 +8927,10 @@</span><br><span> */</span><br><span> static void load_channelvars(struct ast_variable *var)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- char *parse = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- AST_DECLARE_APP_ARGS(args,</span><br><span style="color: hsl(0, 100%, 40%);">- AST_APP_ARG(vars)[MAX_VARS];</span><br><span style="color: hsl(0, 100%, 40%);">- );</span><br><span style="color: hsl(120, 100%, 40%);">+ char *parse = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_DECLARE_APP_ARGS(args,</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_ARG(vars)[MAX_VARS];</span><br><span style="color: hsl(120, 100%, 40%);">+ );</span><br><span> </span><br><span> ast_free(manager_channelvars);</span><br><span> manager_channelvars = ast_strdup(var->value);</span><br><span>@@ -8933,6 +8944,18 @@</span><br><span> </span><br><span> /*!</span><br><span> * \internal</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Load the config disabledevents variable.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param var Config variable to load.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static void load_disabledevents(struct ast_variable *var)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(manager_disabledevents);</span><br><span style="color: hsl(120, 100%, 40%);">+ manager_disabledevents = ast_strdup(var->value);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \internal</span><br><span> * \brief Free a user record. Should already be removed from the list</span><br><span> */</span><br><span> static void manager_free_user(struct ast_manager_user *user)</span><br><span>@@ -9045,6 +9068,7 @@</span><br><span> acl_change_stasis_unsubscribe();</span><br><span> </span><br><span> ast_free(manager_channelvars);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(manager_disabledevents);</span><br><span> }</span><br><span> </span><br><span> </span><br><span>@@ -9339,6 +9363,8 @@</span><br><span> }</span><br><span> } else if (!strcasecmp(var->name, "channelvars")) {</span><br><span> load_channelvars(var);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(var->name, "disabledevents")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ load_disabledevents(var);</span><br><span> } else {</span><br><span> ast_log(LOG_NOTICE, "Invalid keyword <%s> = <%s> in manager.conf [general]\n",</span><br><span> var->name, val);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18030">change 18030</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18030"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Id42b9a3722a1f460d745cad1ebc47c537fd4f205 </div>
<div style="display:none"> Gerrit-Change-Number: 18030 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>