<p>Kevin Harwell <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18029">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kevin Harwell: Looks good to me, approved; Approved for Submit
  Michael Bradeen: Looks good to me, but someone else must approve

</div><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;"><span>diff --git a/configs/samples/manager.conf.sample b/configs/samples/manager.conf.sample</span><br><span>index 989441a..f60c767 100644</span><br><span>--- a/configs/samples/manager.conf.sample</span><br><span>+++ b/configs/samples/manager.conf.sample</span><br><span>@@ -77,7 +77,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 da10996..cca4777 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>@@ -7237,6 +7238,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 (ast_in_delimited_string(event, manager_disabledevents, ',')) {</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>@@ -8701,6 +8711,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>@@ -8921,10 +8932,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>@@ -8938,6 +8949,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>@@ -9050,6 +9073,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>@@ -9344,6 +9368,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><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18029">change 18029</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/+/18029"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Id42b9a3722a1f460d745cad1ebc47c537fd4f205 </div>
<div style="display:none"> Gerrit-Change-Number: 18029 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>