<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17793">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<br>to the general section in manager.conf,<br>which allows users to specify events that<br>should be globally disabled and not sent<br>to any AMI listeners.<br><br>This allows for processing of these AMI<br>events to end sooner and, for frequent<br>AMI events such as Newexten which users<br>may not have any need for, can result in<br>a performance boost. Additionally, it also<br>cleans up core debug as previously when<br>debug was 3 or higher, the debug was<br>constantly spammed by "Analyzing AMI<br>event" messages along with a complete dump<br>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, 41 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/93/17793/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..673b1c3 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,14 @@</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. If used to disable</span><br><span style="color: hsl(120, 100%, 40%);">+; frequent events which are not desired, this can boost performance. 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> </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 8307421..5755318 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>@@ -7238,6 +7239,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>@@ -8692,6 +8702,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>@@ -8912,10 +8923,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>@@ -8929,6 +8940,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>@@ -9041,6 +9064,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>@@ -9335,6 +9359,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/+/17793">change 17793</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/+/17793"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id42b9a3722a1f460d745cad1ebc47c537fd4f205 </div>
<div style="display:none"> Gerrit-Change-Number: 17793 </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>