mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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
This commit is contained in:
committed by
Friendly Automation
parent
3b1debb28b
commit
585c2d17bb
@@ -1479,6 +1479,7 @@ static int manager_debug = 0; /*!< enable some debugging code in the manager */
|
||||
static int authtimeout;
|
||||
static int authlimit;
|
||||
static char *manager_channelvars;
|
||||
static char *manager_disabledevents;
|
||||
|
||||
#define DEFAULT_REALM "asterisk"
|
||||
static char global_realm[MAXHOSTNAMELEN]; /*!< Default realm */
|
||||
@@ -7232,6 +7233,15 @@ int __ast_manager_event_multichan(int category, const char *event, int chancount
|
||||
va_list ap;
|
||||
int res;
|
||||
|
||||
if (!ast_strlen_zero(manager_disabledevents)) {
|
||||
if (strstr(manager_disabledevents, event)) {
|
||||
ast_debug(3, "AMI Event '%s' is globally disabled, skipping\n", event);
|
||||
/* Event is globally disabled */
|
||||
ao2_cleanup(sessions);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!any_manager_listeners(sessions)) {
|
||||
/* Nobody is listening */
|
||||
ao2_cleanup(sessions);
|
||||
@@ -8696,6 +8706,7 @@ static char *handle_manager_show_settings(struct ast_cli_entry *e, int cmd, stru
|
||||
ast_cli(a->fd, FORMAT, "Display connects:", AST_CLI_YESNO(displayconnects));
|
||||
ast_cli(a->fd, FORMAT, "Timestamp events:", AST_CLI_YESNO(timestampevents));
|
||||
ast_cli(a->fd, FORMAT, "Channel vars:", S_OR(manager_channelvars, ""));
|
||||
ast_cli(a->fd, FORMAT, "Disabled events:", S_OR(manager_disabledevents, ""));
|
||||
ast_cli(a->fd, FORMAT, "Debug:", AST_CLI_YESNO(manager_debug));
|
||||
#undef FORMAT
|
||||
#undef FORMAT2
|
||||
@@ -8916,10 +8927,10 @@ static struct ast_cli_entry cli_manager[] = {
|
||||
*/
|
||||
static void load_channelvars(struct ast_variable *var)
|
||||
{
|
||||
char *parse = NULL;
|
||||
AST_DECLARE_APP_ARGS(args,
|
||||
AST_APP_ARG(vars)[MAX_VARS];
|
||||
);
|
||||
char *parse = NULL;
|
||||
AST_DECLARE_APP_ARGS(args,
|
||||
AST_APP_ARG(vars)[MAX_VARS];
|
||||
);
|
||||
|
||||
ast_free(manager_channelvars);
|
||||
manager_channelvars = ast_strdup(var->value);
|
||||
@@ -8931,6 +8942,18 @@ static void load_channelvars(struct ast_variable *var)
|
||||
ast_channel_set_manager_vars(args.argc, args.vars);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Load the config disabledevents variable.
|
||||
*
|
||||
* \param var Config variable to load.
|
||||
*/
|
||||
static void load_disabledevents(struct ast_variable *var)
|
||||
{
|
||||
ast_free(manager_disabledevents);
|
||||
manager_disabledevents = ast_strdup(var->value);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Free a user record. Should already be removed from the list
|
||||
@@ -9045,6 +9068,7 @@ static void manager_shutdown(void)
|
||||
acl_change_stasis_unsubscribe();
|
||||
|
||||
ast_free(manager_channelvars);
|
||||
ast_free(manager_disabledevents);
|
||||
}
|
||||
|
||||
|
||||
@@ -9339,6 +9363,8 @@ static int __init_manager(int reload, int by_external_config)
|
||||
}
|
||||
} else if (!strcasecmp(var->name, "channelvars")) {
|
||||
load_channelvars(var);
|
||||
} else if (!strcasecmp(var->name, "disabledevents")) {
|
||||
load_disabledevents(var);
|
||||
} else {
|
||||
ast_log(LOG_NOTICE, "Invalid keyword <%s> = <%s> in manager.conf [general]\n",
|
||||
var->name, val);
|
||||
|
Reference in New Issue
Block a user