Skip to content

Commit 585c2d1

Browse files
InterLinked1Friendly Automation
authored and
Friendly Automation
committed
ami: Allow events to be globally disabled.
The disabledevents setting has been added to the general section in manager.conf, which allows users to specify events that should be globally disabled and not sent to any AMI listeners. This allows for processing of these AMI events to end sooner and, for frequent AMI events such as Newexten which users may not have any need for, allows them to not be processed. Additionally, it also cleans up core debug as previously when debug was 3 or higher, the debug was constantly spammed by "Analyzing AMI event" messages along with a complete dump of the event contents (often for Newexten). ASTERISK-29853 #close Change-Id: Id42b9a3722a1f460d745cad1ebc47c537fd4f205
1 parent 3b1debb commit 585c2d1

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

configs/samples/manager.conf.sample

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,18 @@ bindaddr = 0.0.0.0
7979
; on a action=waitevent request (actually its httptimeout-10)
8080
; c) httptimeout is also the amount of time the webserver keeps
8181
; a http session alive after completing a successful action
82+
;
83+
; disabledevents specifies AMI events which should be completely globally disabled.
84+
; These events will not be available to any AMI listeners. Use this to disable
85+
; frequent events which are not desired for any listeners. Default
86+
; is no events are globally disabled. Event names are case-sensitive.
87+
; Events disabled in stasis.conf do not also need to be disabled here.
88+
; If you don't want to completely disable an AMI event, also consider the
89+
; filter option available on a per-manager user basis to block unwanted
90+
; events from being received in a stream (as opposed to this option which
91+
; would prevent specified events from being generated at all).
8292

93+
;disabledevents = Newexten,Varset
8394

8495
;[mark]
8596
;secret = mysecret
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Subject: ami
2+
3+
AMI events can now be globally disabled using
4+
the disabledevents [general] setting.

main/manager.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ static int manager_debug = 0; /*!< enable some debugging code in the manager */
14791479
static int authtimeout;
14801480
static int authlimit;
14811481
static char *manager_channelvars;
1482+
static char *manager_disabledevents;
14821483

14831484
#define DEFAULT_REALM "asterisk"
14841485
static char global_realm[MAXHOSTNAMELEN]; /*!< Default realm */
@@ -7232,6 +7233,15 @@ int __ast_manager_event_multichan(int category, const char *event, int chancount
72327233
va_list ap;
72337234
int res;
72347235

7236+
if (!ast_strlen_zero(manager_disabledevents)) {
7237+
if (strstr(manager_disabledevents, event)) {
7238+
ast_debug(3, "AMI Event '%s' is globally disabled, skipping\n", event);
7239+
/* Event is globally disabled */
7240+
ao2_cleanup(sessions);
7241+
return 0;
7242+
}
7243+
}
7244+
72357245
if (!any_manager_listeners(sessions)) {
72367246
/* Nobody is listening */
72377247
ao2_cleanup(sessions);
@@ -8696,6 +8706,7 @@ static char *handle_manager_show_settings(struct ast_cli_entry *e, int cmd, stru
86968706
ast_cli(a->fd, FORMAT, "Display connects:", AST_CLI_YESNO(displayconnects));
86978707
ast_cli(a->fd, FORMAT, "Timestamp events:", AST_CLI_YESNO(timestampevents));
86988708
ast_cli(a->fd, FORMAT, "Channel vars:", S_OR(manager_channelvars, ""));
8709+
ast_cli(a->fd, FORMAT, "Disabled events:", S_OR(manager_disabledevents, ""));
86998710
ast_cli(a->fd, FORMAT, "Debug:", AST_CLI_YESNO(manager_debug));
87008711
#undef FORMAT
87018712
#undef FORMAT2
@@ -8916,10 +8927,10 @@ static struct ast_cli_entry cli_manager[] = {
89168927
*/
89178928
static void load_channelvars(struct ast_variable *var)
89188929
{
8919-
char *parse = NULL;
8920-
AST_DECLARE_APP_ARGS(args,
8921-
AST_APP_ARG(vars)[MAX_VARS];
8922-
);
8930+
char *parse = NULL;
8931+
AST_DECLARE_APP_ARGS(args,
8932+
AST_APP_ARG(vars)[MAX_VARS];
8933+
);
89238934

89248935
ast_free(manager_channelvars);
89258936
manager_channelvars = ast_strdup(var->value);
@@ -8931,6 +8942,18 @@ static void load_channelvars(struct ast_variable *var)
89318942
ast_channel_set_manager_vars(args.argc, args.vars);
89328943
}
89338944

8945+
/*!
8946+
* \internal
8947+
* \brief Load the config disabledevents variable.
8948+
*
8949+
* \param var Config variable to load.
8950+
*/
8951+
static void load_disabledevents(struct ast_variable *var)
8952+
{
8953+
ast_free(manager_disabledevents);
8954+
manager_disabledevents = ast_strdup(var->value);
8955+
}
8956+
89348957
/*!
89358958
* \internal
89368959
* \brief Free a user record. Should already be removed from the list
@@ -9045,6 +9068,7 @@ static void manager_shutdown(void)
90459068
acl_change_stasis_unsubscribe();
90469069

90479070
ast_free(manager_channelvars);
9071+
ast_free(manager_disabledevents);
90489072
}
90499073

90509074

@@ -9339,6 +9363,8 @@ static int __init_manager(int reload, int by_external_config)
93399363
}
93409364
} else if (!strcasecmp(var->name, "channelvars")) {
93419365
load_channelvars(var);
9366+
} else if (!strcasecmp(var->name, "disabledevents")) {
9367+
load_disabledevents(var);
93429368
} else {
93439369
ast_log(LOG_NOTICE, "Invalid keyword <%s> = <%s> in manager.conf [general]\n",
93449370
var->name, val);

0 commit comments

Comments
 (0)