0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-06 14:35:32 +00:00

Remove family from alerts ()

* remove loading and storing families from alert configs

* remove families from silencers

* remove from alarm log

* start remove from alarm-notify.sh.in

* fix test alarm

* rebase

* remove from api/v1/alarm_log

* remove from alert stream

* remove from config stream

* remove from more

* remove from swagger for health api

* revert md changes

* remove from health cmd api test
This commit is contained in:
Emmanuel Vasilakis 2023-10-06 00:57:53 +03:00 committed by GitHub
parent c317e4d380
commit 9493fa8682
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 153 additions and 340 deletions

View file

@ -15,28 +15,22 @@ void destroy_aclk_alarm_configuration(struct aclk_alarm_configuration *cfg)
freez(cfg->alarm); freez(cfg->alarm);
freez(cfg->tmpl); freez(cfg->tmpl);
freez(cfg->on_chart); freez(cfg->on_chart);
freez(cfg->classification); freez(cfg->classification);
freez(cfg->type); freez(cfg->type);
freez(cfg->component); freez(cfg->component);
freez(cfg->os); freez(cfg->os);
freez(cfg->hosts); freez(cfg->hosts);
freez(cfg->plugin); freez(cfg->plugin);
freez(cfg->module); freez(cfg->module);
freez(cfg->charts); freez(cfg->charts);
freez(cfg->families);
freez(cfg->lookup); freez(cfg->lookup);
freez(cfg->every); freez(cfg->every);
freez(cfg->units); freez(cfg->units);
freez(cfg->green); freez(cfg->green);
freez(cfg->red); freez(cfg->red);
freez(cfg->calculation_expr); freez(cfg->calculation_expr);
freez(cfg->warning_expr); freez(cfg->warning_expr);
freez(cfg->critical_expr); freez(cfg->critical_expr);
freez(cfg->recipient); freez(cfg->recipient);
freez(cfg->exec); freez(cfg->exec);
freez(cfg->delay); freez(cfg->delay);
@ -44,11 +38,9 @@ void destroy_aclk_alarm_configuration(struct aclk_alarm_configuration *cfg)
freez(cfg->info); freez(cfg->info);
freez(cfg->options); freez(cfg->options);
freez(cfg->host_labels); freez(cfg->host_labels);
freez(cfg->p_db_lookup_dimensions); freez(cfg->p_db_lookup_dimensions);
freez(cfg->p_db_lookup_method); freez(cfg->p_db_lookup_method);
freez(cfg->p_db_lookup_options); freez(cfg->p_db_lookup_options);
freez(cfg->chart_labels); freez(cfg->chart_labels);
freez(cfg->summary); freez(cfg->summary);
} }
@ -66,14 +58,12 @@ char *generate_provide_alarm_configuration(size_t *len, struct provide_alarm_con
cfg->set_template_(data->cfg.tmpl); cfg->set_template_(data->cfg.tmpl);
if(data->cfg.on_chart) if(data->cfg.on_chart)
cfg->set_on_chart(data->cfg.on_chart); cfg->set_on_chart(data->cfg.on_chart);
if (data->cfg.classification) if (data->cfg.classification)
cfg->set_classification(data->cfg.classification); cfg->set_classification(data->cfg.classification);
if (data->cfg.type) if (data->cfg.type)
cfg->set_type(data->cfg.type); cfg->set_type(data->cfg.type);
if (data->cfg.component) if (data->cfg.component)
cfg->set_component(data->cfg.component); cfg->set_component(data->cfg.component);
if (data->cfg.os) if (data->cfg.os)
cfg->set_os(data->cfg.os); cfg->set_os(data->cfg.os);
if (data->cfg.hosts) if (data->cfg.hosts)
@ -84,27 +74,22 @@ char *generate_provide_alarm_configuration(size_t *len, struct provide_alarm_con
cfg->set_module(data->cfg.module); cfg->set_module(data->cfg.module);
if(data->cfg.charts) if(data->cfg.charts)
cfg->set_charts(data->cfg.charts); cfg->set_charts(data->cfg.charts);
if(data->cfg.families)
cfg->set_families(data->cfg.families);
if(data->cfg.lookup) if(data->cfg.lookup)
cfg->set_lookup(data->cfg.lookup); cfg->set_lookup(data->cfg.lookup);
if(data->cfg.every) if(data->cfg.every)
cfg->set_every(data->cfg.every); cfg->set_every(data->cfg.every);
if(data->cfg.units) if(data->cfg.units)
cfg->set_units(data->cfg.units); cfg->set_units(data->cfg.units);
if (data->cfg.green) if (data->cfg.green)
cfg->set_green(data->cfg.green); cfg->set_green(data->cfg.green);
if (data->cfg.red) if (data->cfg.red)
cfg->set_red(data->cfg.red); cfg->set_red(data->cfg.red);
if (data->cfg.calculation_expr) if (data->cfg.calculation_expr)
cfg->set_calculation_expr(data->cfg.calculation_expr); cfg->set_calculation_expr(data->cfg.calculation_expr);
if (data->cfg.warning_expr) if (data->cfg.warning_expr)
cfg->set_warning_expr(data->cfg.warning_expr); cfg->set_warning_expr(data->cfg.warning_expr);
if (data->cfg.critical_expr) if (data->cfg.critical_expr)
cfg->set_critical_expr(data->cfg.critical_expr); cfg->set_critical_expr(data->cfg.critical_expr);
if (data->cfg.recipient) if (data->cfg.recipient)
cfg->set_recipient(data->cfg.recipient); cfg->set_recipient(data->cfg.recipient);
if (data->cfg.exec) if (data->cfg.exec)
@ -132,7 +117,6 @@ char *generate_provide_alarm_configuration(size_t *len, struct provide_alarm_con
if (data->cfg.chart_labels) if (data->cfg.chart_labels)
cfg->set_chart_labels(data->cfg.chart_labels); cfg->set_chart_labels(data->cfg.chart_labels);
if (data->cfg.summary) if (data->cfg.summary)
cfg->set_summary(data->cfg.summary); cfg->set_summary(data->cfg.summary);

View file

@ -24,7 +24,6 @@ struct aclk_alarm_configuration {
char *plugin; char *plugin;
char *module; char *module;
char *charts; char *charts;
char *families;
char *lookup; char *lookup;
char *every; char *every;
char *units; char *units;

View file

@ -66,11 +66,8 @@ static alarms::v1::AlarmStatus aclk_alarm_status_to_proto(enum aclk_alarm_status
void destroy_alarm_log_entry(struct alarm_log_entry *entry) void destroy_alarm_log_entry(struct alarm_log_entry *entry)
{ {
//freez(entry->node_id);
//freez(entry->claim_id);
freez(entry->chart); freez(entry->chart);
freez(entry->name); freez(entry->name);
freez(entry->family);
freez(entry->config_hash); freez(entry->config_hash);
freez(entry->timezone); freez(entry->timezone);
freez(entry->exec_path); freez(entry->exec_path);
@ -89,32 +86,21 @@ static void fill_alarm_log_entry(struct alarm_log_entry *data, AlarmLogEntry *pr
{ {
proto->set_node_id(data->node_id); proto->set_node_id(data->node_id);
proto->set_claim_id(data->claim_id); proto->set_claim_id(data->claim_id);
proto->set_chart(data->chart); proto->set_chart(data->chart);
proto->set_name(data->name); proto->set_name(data->name);
if (data->family)
proto->set_family(data->family);
proto->set_when(data->when); proto->set_when(data->when);
proto->set_config_hash(data->config_hash); proto->set_config_hash(data->config_hash);
proto->set_utc_offset(data->utc_offset); proto->set_utc_offset(data->utc_offset);
proto->set_timezone(data->timezone); proto->set_timezone(data->timezone);
proto->set_exec_path(data->exec_path); proto->set_exec_path(data->exec_path);
proto->set_conf_source(data->conf_source); proto->set_conf_source(data->conf_source);
proto->set_command(data->command); proto->set_command(data->command);
proto->set_duration(data->duration); proto->set_duration(data->duration);
proto->set_non_clear_duration(data->non_clear_duration); proto->set_non_clear_duration(data->non_clear_duration);
proto->set_status(aclk_alarm_status_to_proto(data->status)); proto->set_status(aclk_alarm_status_to_proto(data->status));
proto->set_old_status(aclk_alarm_status_to_proto(data->old_status)); proto->set_old_status(aclk_alarm_status_to_proto(data->old_status));
proto->set_delay(data->delay); proto->set_delay(data->delay);
proto->set_delay_up_to_timestamp(data->delay_up_to_timestamp); proto->set_delay_up_to_timestamp(data->delay_up_to_timestamp);
proto->set_last_repeat(data->last_repeat); proto->set_last_repeat(data->last_repeat);
proto->set_silenced(data->silenced); proto->set_silenced(data->silenced);

View file

@ -992,7 +992,6 @@ struct alarm_entry {
STRING *chart; STRING *chart;
STRING *chart_context; STRING *chart_context;
STRING *chart_name; STRING *chart_name;
STRING *family;
STRING *classification; STRING *classification;
STRING *component; STRING *component;
@ -1037,7 +1036,6 @@ struct alarm_entry {
#define ae_chart_id(ae) string2str((ae)->chart) #define ae_chart_id(ae) string2str((ae)->chart)
#define ae_chart_name(ae) string2str((ae)->chart_name) #define ae_chart_name(ae) string2str((ae)->chart_name)
#define ae_chart_context(ae) string2str((ae)->chart_context) #define ae_chart_context(ae) string2str((ae)->chart_context)
#define ae_family(ae) string2str((ae)->family)
#define ae_classification(ae) string2str((ae)->classification) #define ae_classification(ae) string2str((ae)->classification)
#define ae_exec(ae) string2str((ae)->exec) #define ae_exec(ae) string2str((ae)->exec)
#define ae_recipient(ae) string2str((ae)->recipient) #define ae_recipient(ae) string2str((ae)->recipient)

View file

@ -310,7 +310,6 @@ static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) {
rc->rrdset->id, rc->rrdset->id,
rc->rrdset->context, rc->rrdset->context,
rc->rrdset->name, rc->rrdset->name,
rc->rrdset->family,
rc->classification, rc->classification,
rc->component, rc->component,
rc->type, rc->type,
@ -357,7 +356,6 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) {
rc->rrdset->id, rc->rrdset->id,
rc->rrdset->context, rc->rrdset->context,
rc->rrdset->name, rc->rrdset->name,
rc->rrdset->family,
rc->classification, rc->classification,
rc->component, rc->component,
rc->type, rc->type,

View file

@ -196,7 +196,6 @@ struct alert_config {
STRING *os; STRING *os;
STRING *host; STRING *host;
STRING *on; STRING *on;
STRING *families;
STRING *plugin; STRING *plugin;
STRING *module; STRING *module;
STRING *charts; STRING *charts;

View file

@ -37,9 +37,6 @@ bool rrdcalctemplate_check_rrdset_conditions(RRDCALCTEMPLATE *rt, RRDSET *st, RR
if (rt->charts_pattern && !simple_pattern_matches_string(rt->charts_pattern, st->name) && !simple_pattern_matches_string(rt->charts_pattern, st->id)) if (rt->charts_pattern && !simple_pattern_matches_string(rt->charts_pattern, st->name) && !simple_pattern_matches_string(rt->charts_pattern, st->id))
return false; return false;
if (rt->family_pattern && !simple_pattern_matches_string(rt->family_pattern, st->family))
return false;
if (rt->module_pattern && !simple_pattern_matches_string(rt->module_pattern, st->module_name)) if (rt->module_pattern && !simple_pattern_matches_string(rt->module_pattern, st->module_name))
return false; return false;
@ -100,9 +97,6 @@ static void rrdcalctemplate_free_internals(RRDCALCTEMPLATE *rt) {
expression_free(rt->warning); expression_free(rt->warning);
expression_free(rt->critical); expression_free(rt->critical);
string_freez(rt->family_match);
simple_pattern_free(rt->family_pattern);
string_freez(rt->plugin_match); string_freez(rt->plugin_match);
simple_pattern_free(rt->plugin_pattern); simple_pattern_free(rt->plugin_pattern);
@ -217,10 +211,6 @@ inline void rrdcalctemplate_delete_all(RRDHOST *host) {
} }
#define RRDCALCTEMPLATE_MAX_KEY_SIZE 1024 #define RRDCALCTEMPLATE_MAX_KEY_SIZE 1024
static size_t rrdcalctemplate_key(char *dst, size_t dst_len, const char *name, const char *family_match) {
return snprintfz(dst, dst_len, "%s/%s", name, (family_match && *family_match)?family_match:"*");
}
void rrdcalctemplate_add_from_config(RRDHOST *host, RRDCALCTEMPLATE *rt) { void rrdcalctemplate_add_from_config(RRDHOST *host, RRDCALCTEMPLATE *rt) {
if(unlikely(!rt->context)) { if(unlikely(!rt->context)) {
netdata_log_error("Health configuration for template '%s' does not have a context", rrdcalctemplate_name(rt)); netdata_log_error("Health configuration for template '%s' does not have a context", rrdcalctemplate_name(rt));
@ -238,7 +228,7 @@ void rrdcalctemplate_add_from_config(RRDHOST *host, RRDCALCTEMPLATE *rt) {
} }
char key[RRDCALCTEMPLATE_MAX_KEY_SIZE + 1]; char key[RRDCALCTEMPLATE_MAX_KEY_SIZE + 1];
size_t key_len = rrdcalctemplate_key(key, RRDCALCTEMPLATE_MAX_KEY_SIZE, rrdcalctemplate_name(rt), rrdcalctemplate_family_match(rt)); size_t key_len = snprintfz(key, RRDCALCTEMPLATE_MAX_KEY_SIZE, "%s", rrdcalctemplate_name(rt));
bool added = false; bool added = false;
dictionary_set_advanced(host->rrdcalctemplate_root_index, key, (ssize_t)(key_len + 1), rt, sizeof(*rt), &added); dictionary_set_advanced(host->rrdcalctemplate_root_index, key, (ssize_t)(key_len + 1), rt, sizeof(*rt), &added);

View file

@ -22,9 +22,6 @@ struct rrdcalctemplate {
STRING *context; STRING *context;
STRING *family_match;
SIMPLE_PATTERN *family_pattern;
STRING *plugin_match; STRING *plugin_match;
SIMPLE_PATTERN *plugin_pattern; SIMPLE_PATTERN *plugin_pattern;
@ -101,7 +98,6 @@ struct rrdcalctemplate {
#define rrdcalctemplate_classification(rt) string2str((rt)->classification) #define rrdcalctemplate_classification(rt) string2str((rt)->classification)
#define rrdcalctemplate_component(rt) string2str((rt)->component) #define rrdcalctemplate_component(rt) string2str((rt)->component)
#define rrdcalctemplate_type(rt) string2str((rt)->type) #define rrdcalctemplate_type(rt) string2str((rt)->type)
#define rrdcalctemplate_family_match(rt) string2str((rt)->family_match)
#define rrdcalctemplate_plugin_match(rt) string2str((rt)->plugin_match) #define rrdcalctemplate_plugin_match(rt) string2str((rt)->plugin_match)
#define rrdcalctemplate_module_match(rt) string2str((rt)->module_match) #define rrdcalctemplate_module_match(rt) string2str((rt)->module_match)
#define rrdcalctemplate_charts_match(rt) string2str((rt)->charts_match) #define rrdcalctemplate_charts_match(rt) string2str((rt)->charts_match)

View file

@ -273,7 +273,7 @@ void aclk_push_alert_event(struct aclk_sync_host_config *wc)
sql, sql,
"select aa.sequence_id, hld.unique_id, hld.alarm_id, hl.config_hash_id, hld.updated_by_id, hld.when_key, " "select aa.sequence_id, hld.unique_id, hld.alarm_id, hl.config_hash_id, hld.updated_by_id, hld.when_key, "
" hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, hld.delay_up_to_timestamp, hl.name, " " hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, hld.delay_up_to_timestamp, hl.name, "
" hl.chart, hl.family, hl.exec, hl.recipient, ha.source, hl.units, hld.info, hld.exec_code, hld.new_status, " " hl.chart, hl.exec, hl.recipient, ha.source, hl.units, hld.info, hld.exec_code, hld.new_status, "
" hld.old_status, hld.delay, hld.new_value, hld.old_value, hld.last_repeat, hl.chart_context, hld.transition_id, " " hld.old_status, hld.delay, hld.new_value, hld.old_value, hld.last_repeat, hl.chart_context, hld.transition_id, "
" hld.alarm_event_id, hl.chart_name, hld.summary " " hld.alarm_event_id, hl.chart_name, hld.summary "
" from health_log hl, aclk_alert_%s aa, alert_hash ha, health_log_detail hld " " from health_log hl, aclk_alert_%s aa, alert_hash ha, health_log_detail hld "
@ -331,64 +331,52 @@ void aclk_push_alert_event(struct aclk_sync_host_config *wc)
alarm_log.node_id = wc->node_id; alarm_log.node_id = wc->node_id;
alarm_log.claim_id = claim_id; alarm_log.claim_id = claim_id;
alarm_log.chart = strdupz((char *)sqlite3_column_text(res, 12)); alarm_log.chart = strdupz((char *)sqlite3_column_text(res, 12));
alarm_log.name = strdupz((char *)sqlite3_column_text(res, 11)); alarm_log.name = strdupz((char *)sqlite3_column_text(res, 11));
alarm_log.family = sqlite3_column_bytes(res, 13) > 0 ? strdupz((char *)sqlite3_column_text(res, 13)) : NULL;
//alarm_log.batch_id = wc->alerts_batch_id;
//alarm_log.sequence_id = (uint64_t) sqlite3_column_int64(res, 0);
alarm_log.when = (time_t) sqlite3_column_int64(res, 5); alarm_log.when = (time_t) sqlite3_column_int64(res, 5);
alarm_log.config_hash = sqlite3_uuid_unparse_strdupz(res, 3); alarm_log.config_hash = sqlite3_uuid_unparse_strdupz(res, 3);
alarm_log.utc_offset = wc->host->utc_offset; alarm_log.utc_offset = wc->host->utc_offset;
alarm_log.timezone = strdupz(rrdhost_abbrev_timezone(wc->host)); alarm_log.timezone = strdupz(rrdhost_abbrev_timezone(wc->host));
alarm_log.exec_path = sqlite3_column_bytes(res, 14) > 0 ? strdupz((char *)sqlite3_column_text(res, 14)) : alarm_log.exec_path = sqlite3_column_bytes(res, 13) > 0 ? strdupz((char *)sqlite3_column_text(res, 13)) :
strdupz((char *)string2str(wc->host->health.health_default_exec)); strdupz((char *)string2str(wc->host->health.health_default_exec));
alarm_log.conf_source = sqlite3_column_bytes(res, 15) > 0 ? strdupz((char *)sqlite3_column_text(res, 15)) : strdupz("");
alarm_log.conf_source = sqlite3_column_bytes(res, 16) > 0 ? strdupz((char *)sqlite3_column_text(res, 16)) : strdupz(""); char *edit_command = sqlite3_column_bytes(res, 15) > 0 ?
health_edit_command_from_source((char *)sqlite3_column_text(res, 15)) :
char *edit_command = sqlite3_column_bytes(res, 16) > 0 ?
health_edit_command_from_source((char *)sqlite3_column_text(res, 16)) :
strdupz("UNKNOWN=0=UNKNOWN"); strdupz("UNKNOWN=0=UNKNOWN");
alarm_log.command = strdupz(edit_command); alarm_log.command = strdupz(edit_command);
alarm_log.duration = (time_t) sqlite3_column_int64(res, 6); alarm_log.duration = (time_t) sqlite3_column_int64(res, 6);
alarm_log.non_clear_duration = (time_t) sqlite3_column_int64(res, 7); alarm_log.non_clear_duration = (time_t) sqlite3_column_int64(res, 7);
alarm_log.status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 20)); alarm_log.status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 19));
alarm_log.old_status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 21)); alarm_log.old_status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 20));
alarm_log.delay = (int) sqlite3_column_int(res, 22); alarm_log.delay = (int) sqlite3_column_int(res, 21);
alarm_log.delay_up_to_timestamp = (time_t) sqlite3_column_int64(res, 10); alarm_log.delay_up_to_timestamp = (time_t) sqlite3_column_int64(res, 10);
alarm_log.last_repeat = (time_t) sqlite3_column_int64(res, 25); alarm_log.last_repeat = (time_t) sqlite3_column_int64(res, 24);
alarm_log.silenced = ((sqlite3_column_int64(res, 8) & HEALTH_ENTRY_FLAG_SILENCED) || alarm_log.silenced = ((sqlite3_column_int64(res, 8) & HEALTH_ENTRY_FLAG_SILENCED) ||
(sqlite3_column_type(res, 15) != SQLITE_NULL && (sqlite3_column_type(res, 14) != SQLITE_NULL &&
!strncmp((char *)sqlite3_column_text(res, 15), "silent", 6))) ? !strncmp((char *)sqlite3_column_text(res, 14), "silent", 6))) ?
1 : 1 :
0; 0;
alarm_log.value_string = alarm_log.value_string =
sqlite3_column_type(res, 22) == SQLITE_NULL ?
strdupz((char *)"-") :
strdupz((char *)format_value_and_unit(
new_value_string, 100, sqlite3_column_double(res, 22), (char *)sqlite3_column_text(res, 16), -1));
alarm_log.old_value_string =
sqlite3_column_type(res, 23) == SQLITE_NULL ? sqlite3_column_type(res, 23) == SQLITE_NULL ?
strdupz((char *)"-") : strdupz((char *)"-") :
strdupz((char *)format_value_and_unit( strdupz((char *)format_value_and_unit(
new_value_string, 100, sqlite3_column_double(res, 23), (char *)sqlite3_column_text(res, 17), -1)); old_value_string, 100, sqlite3_column_double(res, 23), (char *)sqlite3_column_text(res, 16), -1));
alarm_log.value = (NETDATA_DOUBLE) sqlite3_column_double(res, 22);
alarm_log.old_value_string = alarm_log.old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 23);
sqlite3_column_type(res, 24) == SQLITE_NULL ?
strdupz((char *)"-") :
strdupz((char *)format_value_and_unit(
old_value_string, 100, sqlite3_column_double(res, 24), (char *)sqlite3_column_text(res, 17), -1));
alarm_log.value = (NETDATA_DOUBLE) sqlite3_column_double(res, 23);
alarm_log.old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 24);
alarm_log.updated = (sqlite3_column_int64(res, 8) & HEALTH_ENTRY_FLAG_UPDATED) ? 1 : 0; alarm_log.updated = (sqlite3_column_int64(res, 8) & HEALTH_ENTRY_FLAG_UPDATED) ? 1 : 0;
alarm_log.rendered_info = sqlite3_text_strdupz_empty(res, 18); alarm_log.rendered_info = sqlite3_text_strdupz_empty(res, 17);
alarm_log.chart_context = sqlite3_text_strdupz_empty(res, 26); alarm_log.chart_context = sqlite3_text_strdupz_empty(res, 25);
alarm_log.transition_id = sqlite3_uuid_unparse_strdupz(res, 27); alarm_log.transition_id = sqlite3_uuid_unparse_strdupz(res, 26);
alarm_log.event_id = (time_t) sqlite3_column_int64(res, 28); alarm_log.event_id = (time_t) sqlite3_column_int64(res, 27);
alarm_log.chart_name = sqlite3_text_strdupz_empty(res, 29); alarm_log.chart_name = sqlite3_text_strdupz_empty(res, 28);
alarm_log.summary = sqlite3_text_strdupz_empty(res, 30); alarm_log.summary = sqlite3_text_strdupz_empty(res, 29);
aclk_send_alarm_log_entry(&alarm_log); aclk_send_alarm_log_entry(&alarm_log);
@ -534,7 +522,7 @@ void aclk_send_alarm_configuration(char *config_hash)
#define SQL_SELECT_ALERT_CONFIG \ #define SQL_SELECT_ALERT_CONFIG \
"SELECT alarm, template, on_key, class, type, component, os, hosts, plugin," \ "SELECT alarm, template, on_key, class, type, component, os, hosts, plugin," \
"module, charts, families, lookup, every, units, green, red, calc, warn, crit, to_key, exec, delay, repeat, info," \ "module, charts, lookup, every, units, green, red, calc, warn, crit, to_key, exec, delay, repeat, info," \
"options, host_labels, p_db_lookup_dimensions, p_db_lookup_method, p_db_lookup_options, p_db_lookup_after," \ "options, host_labels, p_db_lookup_dimensions, p_db_lookup_method, p_db_lookup_options, p_db_lookup_after," \
"p_db_lookup_before, p_update_every, chart_labels, summary FROM alert_hash WHERE hash_id = @hash_id;" "p_db_lookup_before, p_update_every, chart_labels, summary FROM alert_hash WHERE hash_id = @hash_id;"
@ -596,7 +584,6 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash
alarm_config.plugin = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.plugin = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.module = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.module = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.charts = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.charts = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.families = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.lookup = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.lookup = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.every = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.every = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.units = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.units = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
@ -611,7 +598,7 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash
alarm_config.repeat = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.repeat = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.info = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.info = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.options = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); alarm_config.options = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
alarm_config.host_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 26 alarm_config.host_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 25
alarm_config.p_db_lookup_dimensions = NULL; alarm_config.p_db_lookup_dimensions = NULL;
alarm_config.p_db_lookup_method = NULL; alarm_config.p_db_lookup_method = NULL;
@ -619,26 +606,26 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash
alarm_config.p_db_lookup_after = 0; alarm_config.p_db_lookup_after = 0;
alarm_config.p_db_lookup_before = 0; alarm_config.p_db_lookup_before = 0;
if (sqlite3_column_bytes(res, 30) > 0) { if (sqlite3_column_bytes(res, 29) > 0) {
alarm_config.p_db_lookup_dimensions = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 27 alarm_config.p_db_lookup_dimensions = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 26
alarm_config.p_db_lookup_method = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 28 alarm_config.p_db_lookup_method = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 27
if (param != 29) if (param != 28)
netdata_log_error("aclk_push_alert_config_event: Unexpected param number %d", param); netdata_log_error("aclk_push_alert_config_event: Unexpected param number %d", param);
BUFFER *tmp_buf = buffer_create(1024, &netdata_buffers_statistics.buffers_sqlite); BUFFER *tmp_buf = buffer_create(1024, &netdata_buffers_statistics.buffers_sqlite);
buffer_data_options2string(tmp_buf, sqlite3_column_int(res, 29)); buffer_data_options2string(tmp_buf, sqlite3_column_int(res, 28));
alarm_config.p_db_lookup_options = strdupz((char *)buffer_tostring(tmp_buf)); alarm_config.p_db_lookup_options = strdupz((char *)buffer_tostring(tmp_buf));
buffer_free(tmp_buf); buffer_free(tmp_buf);
alarm_config.p_db_lookup_after = sqlite3_column_int(res, 30); alarm_config.p_db_lookup_after = sqlite3_column_int(res, 29);
alarm_config.p_db_lookup_before = sqlite3_column_int(res, 31); alarm_config.p_db_lookup_before = sqlite3_column_int(res, 30);
} }
alarm_config.p_update_every = sqlite3_column_int(res, 32); alarm_config.p_update_every = sqlite3_column_int(res, 31);
alarm_config.chart_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 33); alarm_config.chart_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 32);
alarm_config.summary = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 34); alarm_config.summary = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 33);
p_alarm_config.cfg_hash = strdupz((char *) config_hash); p_alarm_config.cfg_hash = strdupz((char *) config_hash);
p_alarm_config.cfg = alarm_config; p_alarm_config.cfg = alarm_config;
@ -806,7 +793,6 @@ void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_EN
alarm_log->chart = strdupz(ae_chart_id(ae)); alarm_log->chart = strdupz(ae_chart_id(ae));
alarm_log->name = strdupz(ae_name(ae)); alarm_log->name = strdupz(ae_name(ae));
alarm_log->family = strdupz(ae_family(ae));
alarm_log->batch_id = 0; alarm_log->batch_id = 0;
alarm_log->sequence_id = 0; alarm_log->sequence_id = 0;

View file

@ -97,8 +97,8 @@ failed:
*/ */
#define SQL_INSERT_HEALTH_LOG \ #define SQL_INSERT_HEALTH_LOG \
"INSERT INTO health_log (host_id, alarm_id, " \ "INSERT INTO health_log (host_id, alarm_id, " \
"config_hash_id, name, chart, family, exec, recipient, units, chart_context, last_transition_id, chart_name) " \ "config_hash_id, name, chart, exec, recipient, units, chart_context, last_transition_id, chart_name) " \
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?) " \ "VALUES (?,?,?,?,?,?,?,?,?,?,?) " \
"ON CONFLICT (host_id, alarm_id) DO UPDATE SET last_transition_id = excluded.last_transition_id, " \ "ON CONFLICT (host_id, alarm_id) DO UPDATE SET last_transition_id = excluded.last_transition_id, " \
"chart_name = excluded.chart_name RETURNING health_log_id; " "chart_name = excluded.chart_name RETURNING health_log_id; "
@ -154,43 +154,37 @@ static void sql_health_alarm_log_insert(RRDHOST *host, ALARM_ENTRY *ae) {
goto failed; goto failed;
} }
rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->family, 6); rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->exec, 6);
if (unlikely(rc != SQLITE_OK)) {
error_report("Failed to bind family parameter for SQL_INSERT_HEALTH_LOG");
goto failed;
}
rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->exec, 7);
if (unlikely(rc != SQLITE_OK)) { if (unlikely(rc != SQLITE_OK)) {
error_report("Failed to bind exec parameter for SQL_INSERT_HEALTH_LOG"); error_report("Failed to bind exec parameter for SQL_INSERT_HEALTH_LOG");
goto failed; goto failed;
} }
rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->recipient, 8); rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->recipient, 7);
if (unlikely(rc != SQLITE_OK)) { if (unlikely(rc != SQLITE_OK)) {
error_report("Failed to bind recipient parameter for SQL_INSERT_HEALTH_LOG"); error_report("Failed to bind recipient parameter for SQL_INSERT_HEALTH_LOG");
goto failed; goto failed;
} }
rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->units, 9); rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->units, 8);
if (unlikely(rc != SQLITE_OK)) { if (unlikely(rc != SQLITE_OK)) {
error_report("Failed to bind host_id parameter to store node instance information"); error_report("Failed to bind host_id parameter to store node instance information");
goto failed; goto failed;
} }
rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_context, 10); rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_context, 9);
if (unlikely(rc != SQLITE_OK)) { if (unlikely(rc != SQLITE_OK)) {
error_report("Failed to bind chart_context parameter for SQL_INSERT_HEALTH_LOG"); error_report("Failed to bind chart_context parameter for SQL_INSERT_HEALTH_LOG");
goto failed; goto failed;
} }
rc = sqlite3_bind_blob(res, 11, &ae->transition_id, sizeof(ae->transition_id), SQLITE_STATIC); rc = sqlite3_bind_blob(res, 10, &ae->transition_id, sizeof(ae->transition_id), SQLITE_STATIC);
if (unlikely(rc != SQLITE_OK)) { if (unlikely(rc != SQLITE_OK)) {
error_report("Failed to bind transition_id parameter for SQL_INSERT_HEALTH_LOG"); error_report("Failed to bind transition_id parameter for SQL_INSERT_HEALTH_LOG");
goto failed; goto failed;
} }
rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_name, 12); rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_name, 11);
if (unlikely(rc != SQLITE_OK)) { if (unlikely(rc != SQLITE_OK)) {
error_report("Failed to bind chart_name parameter for SQL_INSERT_HEALTH_LOG"); error_report("Failed to bind chart_name parameter for SQL_INSERT_HEALTH_LOG");
goto failed; goto failed;
@ -745,7 +739,7 @@ void sql_check_removed_alerts_state(RRDHOST *host)
*/ */
#define SQL_LOAD_HEALTH_LOG "SELECT hld.unique_id, hld.alarm_id, hld.alarm_event_id, hl.config_hash_id, hld.updated_by_id, " \ #define SQL_LOAD_HEALTH_LOG "SELECT hld.unique_id, hld.alarm_id, hld.alarm_event_id, hl.config_hash_id, hld.updated_by_id, " \
"hld.updates_id, hld.when_key, hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, " \ "hld.updates_id, hld.when_key, hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, " \
"hld.delay_up_to_timestamp, hl.name, hl.chart, hl.family, hl.exec, hl.recipient, ah.source, hl.units, " \ "hld.delay_up_to_timestamp, hl.name, hl.chart, hl.exec, hl.recipient, ah.source, hl.units, " \
"hld.info, hld.exec_code, hld.new_status, hld.old_status, hld.delay, hld.new_value, hld.old_value, " \ "hld.info, hld.exec_code, hld.new_status, hld.old_status, hld.delay, hld.new_value, hld.old_value, " \
"hld.last_repeat, ah.class, ah.component, ah.type, hl.chart_context, hld.transition_id, hld.global_id, hl.chart_name, hld.summary " \ "hld.last_repeat, ah.class, ah.component, ah.type, hl.chart_context, hld.transition_id, hld.global_id, hl.chart_name, hld.summary " \
"FROM health_log hl, alert_hash ah, health_log_detail hld " \ "FROM health_log hl, alert_hash ah, health_log_detail hld " \
@ -808,7 +802,7 @@ void sql_health_alarm_log_load(RRDHOST *host)
continue; continue;
} }
//need name, chart and family //need name and chart
if (sqlite3_column_type(res, 12) == SQLITE_NULL) { if (sqlite3_column_type(res, 12) == SQLITE_NULL) {
error_report("HEALTH [%s]: Got null name field. Ignoring it.", rrdhost_hostname(host)); error_report("HEALTH [%s]: Got null name field. Ignoring it.", rrdhost_hostname(host));
errored++; errored++;
@ -821,14 +815,8 @@ void sql_health_alarm_log_load(RRDHOST *host)
continue; continue;
} }
if (sqlite3_column_type(res, 14) == SQLITE_NULL) {
error_report("HEALTH [%s]: Got null family field. Ignoring it.", rrdhost_hostname(host));
errored++;
continue;
}
// Check if we got last_repeat field // Check if we got last_repeat field
time_t last_repeat = (time_t)sqlite3_column_int64(res, 26); time_t last_repeat = (time_t)sqlite3_column_int64(res, 25);
rc = dictionary_get(all_rrdcalcs, (char *) sqlite3_column_text(res, 13)); rc = dictionary_get(all_rrdcalcs, (char *) sqlite3_column_text(res, 13));
if(unlikely(rc)) { if(unlikely(rc)) {
@ -865,37 +853,36 @@ void sql_health_alarm_log_load(RRDHOST *host)
ae->name = string_strdupz((char *) sqlite3_column_text(res, 12)); ae->name = string_strdupz((char *) sqlite3_column_text(res, 12));
ae->chart = string_strdupz((char *) sqlite3_column_text(res, 13)); ae->chart = string_strdupz((char *) sqlite3_column_text(res, 13));
ae->family = string_strdupz((char *) sqlite3_column_text(res, 14));
ae->exec = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 15); ae->exec = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 14);
ae->recipient = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 16); ae->recipient = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 15);
ae->source = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 17); ae->source = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 16);
ae->units = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 18); ae->units = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 17);
ae->info = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 19); ae->info = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 18);
ae->exec_code = (int) sqlite3_column_int(res, 20); ae->exec_code = (int) sqlite3_column_int(res, 19);
ae->new_status = (RRDCALC_STATUS) sqlite3_column_int(res, 21); ae->new_status = (RRDCALC_STATUS) sqlite3_column_int(res, 20);
ae->old_status = (RRDCALC_STATUS)sqlite3_column_int(res, 22); ae->old_status = (RRDCALC_STATUS)sqlite3_column_int(res, 21);
ae->delay = (int) sqlite3_column_int(res, 23); ae->delay = (int) sqlite3_column_int(res, 22);
ae->new_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 24); ae->new_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 23);
ae->old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 25); ae->old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 24);
ae->last_repeat = last_repeat; ae->last_repeat = last_repeat;
ae->classification = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 27); ae->classification = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 26);
ae->component = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 28); ae->component = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 27);
ae->type = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 29); ae->type = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 28);
ae->chart_context = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 30); ae->chart_context = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 29);
if (sqlite3_column_type(res, 30) != SQLITE_NULL)
uuid_copy(ae->transition_id, *((uuid_t *)sqlite3_column_blob(res, 30)));
if (sqlite3_column_type(res, 31) != SQLITE_NULL) if (sqlite3_column_type(res, 31) != SQLITE_NULL)
uuid_copy(ae->transition_id, *((uuid_t *)sqlite3_column_blob(res, 31))); ae->global_id = sqlite3_column_int64(res, 31);
if (sqlite3_column_type(res, 32) != SQLITE_NULL) ae->chart_name = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 32);
ae->global_id = sqlite3_column_int64(res, 32); ae->summary = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 33);
ae->chart_name = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 33);
ae->summary = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 34);
char value_string[100 + 1]; char value_string[100 + 1];
string_freez(ae->old_value_string); string_freez(ae->old_value_string);
@ -943,11 +930,11 @@ void sql_health_alarm_log_load(RRDHOST *host)
* Store an alert config hash in the database * Store an alert config hash in the database
*/ */
#define SQL_STORE_ALERT_CONFIG_HASH "insert or replace into alert_hash (hash_id, date_updated, alarm, template, " \ #define SQL_STORE_ALERT_CONFIG_HASH "insert or replace into alert_hash (hash_id, date_updated, alarm, template, " \
"on_key, class, component, type, os, hosts, lookup, every, units, calc, families, plugin, module, " \ "on_key, class, component, type, os, hosts, lookup, every, units, calc, plugin, module, " \
"charts, green, red, warn, crit, exec, to_key, info, delay, options, repeat, host_labels, " \ "charts, green, red, warn, crit, exec, to_key, info, delay, options, repeat, host_labels, " \
"p_db_lookup_dimensions, p_db_lookup_method, p_db_lookup_options, p_db_lookup_after, " \ "p_db_lookup_dimensions, p_db_lookup_method, p_db_lookup_options, p_db_lookup_after, " \
"p_db_lookup_before, p_update_every, source, chart_labels, summary) values (?1,unixepoch(),?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12," \ "p_db_lookup_before, p_update_every, source, chart_labels, summary) values (?1,unixepoch(),?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12," \
"?13,?14,?15,?16,?17,?18,?19,?20,?21,?22,?23,?24,?25,?26,?27,?28,?29,?30,?31,?32,?33,?34,?35,?36,?37);" "?13,?14,?15,?16,?17,?18,?19,?20,?21,?22,?23,?24,?25,?26,?27,?28,?29,?30,?31,?32,?33,?34,?35,?36);"
int sql_store_alert_config_hash(uuid_t *hash_id, struct alert_config *cfg) int sql_store_alert_config_hash(uuid_t *hash_id, struct alert_config *cfg)
{ {
@ -1021,10 +1008,6 @@ int sql_store_alert_config_hash(uuid_t *hash_id, struct alert_config *cfg)
if (unlikely(rc != SQLITE_OK)) if (unlikely(rc != SQLITE_OK))
goto bind_fail; goto bind_fail;
rc = SQLITE3_BIND_STRING_OR_NULL(res, cfg->families, ++param);
if (unlikely(rc != SQLITE_OK))
goto bind_fail;
rc = SQLITE3_BIND_STRING_OR_NULL(res, cfg->plugin, ++param); rc = SQLITE3_BIND_STRING_OR_NULL(res, cfg->plugin, ++param);
if (unlikely(rc != SQLITE_OK)) if (unlikely(rc != SQLITE_OK))
goto bind_fail; goto bind_fail;
@ -1182,7 +1165,6 @@ int alert_hash_and_store_config(
DIGEST_ALERT_CONFIG_VAL(cfg->os); DIGEST_ALERT_CONFIG_VAL(cfg->os);
DIGEST_ALERT_CONFIG_VAL(cfg->host); DIGEST_ALERT_CONFIG_VAL(cfg->host);
DIGEST_ALERT_CONFIG_VAL(cfg->on); DIGEST_ALERT_CONFIG_VAL(cfg->on);
DIGEST_ALERT_CONFIG_VAL(cfg->families);
DIGEST_ALERT_CONFIG_VAL(cfg->plugin); DIGEST_ALERT_CONFIG_VAL(cfg->plugin);
DIGEST_ALERT_CONFIG_VAL(cfg->module); DIGEST_ALERT_CONFIG_VAL(cfg->module);
DIGEST_ALERT_CONFIG_VAL(cfg->charts); DIGEST_ALERT_CONFIG_VAL(cfg->charts);
@ -1284,7 +1266,7 @@ done:
#define SQL_SELECT_HEALTH_LOG \ #define SQL_SELECT_HEALTH_LOG \
"SELECT hld.unique_id, hld.alarm_id, hld.alarm_event_id, hl.config_hash_id, hld.updated_by_id, hld.updates_id, " \ "SELECT hld.unique_id, hld.alarm_id, hld.alarm_event_id, hl.config_hash_id, hld.updated_by_id, hld.updates_id, " \
"hld.when_key, hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, " \ "hld.when_key, hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, " \
"hld.delay_up_to_timestamp, hl.name, hl.chart, hl.family, hl.exec, hl.recipient, ah.source, " \ "hld.delay_up_to_timestamp, hl.name, hl.chart, hl.exec, hl.recipient, ah.source, " \
"hl.units, hld.info, hld.exec_code, hld.new_status, hld.old_status, hld.delay, hld.new_value, hld.old_value, " \ "hl.units, hld.info, hld.exec_code, hld.new_status, hld.old_status, hld.delay, hld.new_value, hld.old_value, " \
"hld.last_repeat, ah.class, ah.component, ah.type, hl.chart_context, hld.transition_id, hld.summary " \ "hld.last_repeat, ah.class, ah.component, ah.type, hl.chart_context, hld.transition_id, hld.summary " \
"FROM health_log hl, alert_hash ah, health_log_detail hld WHERE hl.config_hash_id = ah.hash_id and " \ "FROM health_log hl, alert_hash ah, health_log_detail hld WHERE hl.config_hash_id = ah.hash_id and " \
@ -1345,10 +1327,10 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 3)), config_hash_id); uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 3)), config_hash_id);
char transition_id[UUID_STR_LEN] = {0}; char transition_id[UUID_STR_LEN] = {0};
if (sqlite3_column_type(res, 31) != SQLITE_NULL) if (sqlite3_column_type(res, 30) != SQLITE_NULL)
uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 31)), transition_id); uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 30)), transition_id);
char *edit_command = sqlite3_column_bytes(res, 17) > 0 ? health_edit_command_from_source((char *)sqlite3_column_text(res, 17)) : strdupz("UNKNOWN=0=UNKNOWN"); char *edit_command = sqlite3_column_bytes(res, 16) > 0 ? health_edit_command_from_source((char *)sqlite3_column_text(res, 16)) : strdupz("UNKNOWN=0=UNKNOWN");
if (count) if (count)
buffer_sprintf(wb, ","); buffer_sprintf(wb, ",");
@ -1369,7 +1351,6 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
"\t\t\"name\": \"%s\",\n" "\t\t\"name\": \"%s\",\n"
"\t\t\"chart\": \"%s\",\n" "\t\t\"chart\": \"%s\",\n"
"\t\t\"context\": \"%s\",\n" "\t\t\"context\": \"%s\",\n"
"\t\t\"family\": \"%s\",\n"
"\t\t\"class\": \"%s\",\n" "\t\t\"class\": \"%s\",\n"
"\t\t\"component\": \"%s\",\n" "\t\t\"component\": \"%s\",\n"
"\t\t\"type\": \"%s\",\n" "\t\t\"type\": \"%s\",\n"
@ -1394,7 +1375,7 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
"\t\t\"updates_id\": %u,\n" "\t\t\"updates_id\": %u,\n"
"\t\t\"value_string\": \"%s\",\n" "\t\t\"value_string\": \"%s\",\n"
"\t\t\"old_value_string\": \"%s\",\n" "\t\t\"old_value_string\": \"%s\",\n"
"\t\t\"last_repeat\": \"%lu\",\n" "\t\t\"last_repeat\": %lu,\n"
"\t\t\"silenced\": \"%s\",\n", "\t\t\"silenced\": \"%s\",\n",
rrdhost_hostname(host), rrdhost_hostname(host),
host->utc_offset, host->utc_offset,
@ -1406,54 +1387,53 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
transition_id, transition_id,
sqlite3_column_text(res, 12), sqlite3_column_text(res, 12),
sqlite3_column_text(res, 13), sqlite3_column_text(res, 13),
sqlite3_column_text(res, 30), sqlite3_column_text(res, 29),
sqlite3_column_text(res, 14), sqlite3_column_text(res, 26) ? (const char *) sqlite3_column_text(res, 26) : (char *) "Unknown",
sqlite3_column_text(res, 27) ? (const char *) sqlite3_column_text(res, 27) : (char *) "Unknown", sqlite3_column_text(res, 27) ? (const char *) sqlite3_column_text(res, 27) : (char *) "Unknown",
sqlite3_column_text(res, 28) ? (const char *) sqlite3_column_text(res, 28) : (char *) "Unknown", sqlite3_column_text(res, 28) ? (const char *) sqlite3_column_text(res, 28) : (char *) "Unknown",
sqlite3_column_text(res, 29) ? (const char *) sqlite3_column_text(res, 29) : (char *) "Unknown",
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_PROCESSED)?"true":"false", (sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_PROCESSED)?"true":"false",
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_UPDATED)?"true":"false", (sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_UPDATED)?"true":"false",
(long unsigned int)sqlite3_column_int64(res, 10), (long unsigned int)sqlite3_column_int64(res, 10),
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_EXEC_FAILED)?"true":"false", (sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_EXEC_FAILED)?"true":"false",
sqlite3_column_text(res, 15) ? (const char *) sqlite3_column_text(res, 15) : string2str(host->health.health_default_exec), sqlite3_column_text(res, 14) ? (const char *) sqlite3_column_text(res, 14) : string2str(host->health.health_default_exec),
sqlite3_column_text(res, 16) ? (const char *) sqlite3_column_text(res, 16) : string2str(host->health.health_default_recipient), sqlite3_column_text(res, 15) ? (const char *) sqlite3_column_text(res, 15) : string2str(host->health.health_default_recipient),
sqlite3_column_int(res, 20), sqlite3_column_int(res, 19),
sqlite3_column_text(res, 17) ? (const char *) sqlite3_column_text(res, 17) : (char *) "Unknown", sqlite3_column_text(res, 16) ? (const char *) sqlite3_column_text(res, 16) : (char *) "Unknown",
edit_command, edit_command,
sqlite3_column_text(res, 18), sqlite3_column_text(res, 17),
(long unsigned int)sqlite3_column_int64(res, 6), (long unsigned int)sqlite3_column_int64(res, 6),
(long unsigned int)sqlite3_column_int64(res, 7), (long unsigned int)sqlite3_column_int64(res, 7),
(long unsigned int)sqlite3_column_int64(res, 8), (long unsigned int)sqlite3_column_int64(res, 8),
rrdcalc_status2string(sqlite3_column_int(res, 20)),
rrdcalc_status2string(sqlite3_column_int(res, 21)), rrdcalc_status2string(sqlite3_column_int(res, 21)),
rrdcalc_status2string(sqlite3_column_int(res, 22)), sqlite3_column_int(res, 22),
sqlite3_column_int(res, 23),
(long unsigned int)sqlite3_column_int64(res, 11), (long unsigned int)sqlite3_column_int64(res, 11),
(unsigned int)sqlite3_column_int64(res, 4), (unsigned int)sqlite3_column_int64(res, 4),
(unsigned int)sqlite3_column_int64(res, 5), (unsigned int)sqlite3_column_int64(res, 5),
sqlite3_column_type(res, 24) == SQLITE_NULL ? "-" : format_value_and_unit(new_value_string, 100, sqlite3_column_double(res, 24), (char *) sqlite3_column_text(res, 18), -1), sqlite3_column_type(res, 23) == SQLITE_NULL ? "-" : format_value_and_unit(new_value_string, 100, sqlite3_column_double(res, 23), (char *) sqlite3_column_text(res, 17), -1),
sqlite3_column_type(res, 25) == SQLITE_NULL ? "-" : format_value_and_unit(old_value_string, 100, sqlite3_column_double(res, 25), (char *) sqlite3_column_text(res, 18), -1), sqlite3_column_type(res, 24) == SQLITE_NULL ? "-" : format_value_and_unit(old_value_string, 100, sqlite3_column_double(res, 24), (char *) sqlite3_column_text(res, 17), -1),
(long unsigned int)sqlite3_column_int64(res, 26), (long unsigned int)sqlite3_column_int64(res, 25),
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_SILENCED)?"true":"false"); (sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_SILENCED)?"true":"false");
health_string2json(wb, "\t\t", "summary", (char *) sqlite3_column_text(res, 32), ",\n"); health_string2json(wb, "\t\t", "summary", (char *) sqlite3_column_text(res, 31), ",\n");
health_string2json(wb, "\t\t", "info", (char *) sqlite3_column_text(res, 19), ",\n"); health_string2json(wb, "\t\t", "info", (char *) sqlite3_column_text(res, 18), ",\n");
if(unlikely(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION)) { if(unlikely(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION)) {
buffer_strcat(wb, "\t\t\"no_clear_notification\": true,\n"); buffer_strcat(wb, "\t\t\"no_clear_notification\": true,\n");
} }
buffer_strcat(wb, "\t\t\"value\":"); buffer_strcat(wb, "\t\t\"value\":");
if (sqlite3_column_type(res, 23) == SQLITE_NULL)
buffer_strcat(wb, "null");
else
buffer_print_netdata_double(wb, sqlite3_column_double(res, 23));
buffer_strcat(wb, ",\n");
buffer_strcat(wb, "\t\t\"old_value\":");
if (sqlite3_column_type(res, 24) == SQLITE_NULL) if (sqlite3_column_type(res, 24) == SQLITE_NULL)
buffer_strcat(wb, "null"); buffer_strcat(wb, "null");
else else
buffer_print_netdata_double(wb, sqlite3_column_double(res, 24)); buffer_print_netdata_double(wb, sqlite3_column_double(res, 24));
buffer_strcat(wb, ",\n");
buffer_strcat(wb, "\t\t\"old_value\":");
if (sqlite3_column_type(res, 25) == SQLITE_NULL)
buffer_strcat(wb, "null");
else
buffer_print_netdata_double(wb, sqlite3_column_double(res, 25));
buffer_strcat(wb, "\n"); buffer_strcat(wb, "\n");
buffer_strcat(wb, "\t}"); buffer_strcat(wb, "\t}");

View file

@ -61,7 +61,6 @@ static bool prepare_command(BUFFER *wb,
uint32_t when, uint32_t when,
const char *alert_name, const char *alert_name,
const char *alert_chart_name, const char *alert_chart_name,
const char *alert_family,
const char *new_status, const char *new_status,
const char *old_status, const char *old_status,
NETDATA_DOUBLE new_value, NETDATA_DOUBLE new_value,
@ -118,10 +117,6 @@ static bool prepare_command(BUFFER *wb,
return false; return false;
buffer_sprintf(wb, " '%s'", buf); buffer_sprintf(wb, " '%s'", buf);
if (!sanitize_command_argument_string(buf, alert_family, n))
return false;
buffer_sprintf(wb, " '%s'", buf);
if (!sanitize_command_argument_string(buf, new_status, n)) if (!sanitize_command_argument_string(buf, new_status, n))
return false; return false;
buffer_sprintf(wb, " '%s'", buf); buffer_sprintf(wb, " '%s'", buf);
@ -565,7 +560,6 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
(unsigned long)ae->when, (unsigned long)ae->when,
ae_name(ae), ae_name(ae),
ae->chart?ae_chart_id(ae):"NOCHART", ae->chart?ae_chart_id(ae):"NOCHART",
ae->family?ae_family(ae):"NOFAMILY",
rrdcalc_status2string(ae->new_status), rrdcalc_status2string(ae->new_status),
rrdcalc_status2string(ae->old_status), rrdcalc_status2string(ae->old_status),
ae->new_value, ae->new_value,
@ -879,28 +873,26 @@ static void health_sleep(time_t next_run, unsigned int loop __maybe_unused) {
static SILENCE_TYPE check_silenced(RRDCALC *rc, const char *host, SILENCERS *silencers) { static SILENCE_TYPE check_silenced(RRDCALC *rc, const char *host, SILENCERS *silencers) {
SILENCER *s; SILENCER *s;
netdata_log_debug(D_HEALTH, "Checking if alarm was silenced via the command API. Alarm info name:%s context:%s chart:%s host:%s family:%s", netdata_log_debug(D_HEALTH, "Checking if alarm was silenced via the command API. Alarm info name:%s context:%s chart:%s host:%s",
rrdcalc_name(rc), (rc->rrdset)?rrdset_context(rc->rrdset):"", rrdcalc_chart_name(rc), host, (rc->rrdset)?rrdset_family(rc->rrdset):""); rrdcalc_name(rc), (rc->rrdset)?rrdset_context(rc->rrdset):"", rrdcalc_chart_name(rc), host);
for (s = silencers->silencers; s!=NULL; s=s->next){ for (s = silencers->silencers; s!=NULL; s=s->next){
if ( if (
(!s->alarms_pattern || (rc->name && s->alarms_pattern && simple_pattern_matches_string(s->alarms_pattern, rc->name))) && (!s->alarms_pattern || (rc->name && s->alarms_pattern && simple_pattern_matches_string(s->alarms_pattern, rc->name))) &&
(!s->contexts_pattern || (rc->rrdset && rc->rrdset->context && s->contexts_pattern && simple_pattern_matches_string(s->contexts_pattern, rc->rrdset->context))) && (!s->contexts_pattern || (rc->rrdset && rc->rrdset->context && s->contexts_pattern && simple_pattern_matches_string(s->contexts_pattern, rc->rrdset->context))) &&
(!s->hosts_pattern || (host && s->hosts_pattern && simple_pattern_matches(s->hosts_pattern, host))) && (!s->hosts_pattern || (host && s->hosts_pattern && simple_pattern_matches(s->hosts_pattern, host))) &&
(!s->charts_pattern || (rc->chart && s->charts_pattern && simple_pattern_matches_string(s->charts_pattern, rc->chart))) && (!s->charts_pattern || (rc->chart && s->charts_pattern && simple_pattern_matches_string(s->charts_pattern, rc->chart)))
(!s->families_pattern || (rc->rrdset && rc->rrdset->family && s->families_pattern && simple_pattern_matches_string(s->families_pattern, rc->rrdset->family)))
) { ) {
netdata_log_debug(D_HEALTH, "Alarm matches command API silence entry %s:%s:%s:%s:%s", s->alarms,s->charts, s->contexts, s->hosts, s->families); netdata_log_debug(D_HEALTH, "Alarm matches command API silence entry %s:%s:%s:%s", s->alarms,s->charts, s->contexts, s->hosts);
if (unlikely(silencers->stype == STYPE_NONE)) { if (unlikely(silencers->stype == STYPE_NONE)) {
netdata_log_debug(D_HEALTH, "Alarm %s matched a silence entry, but no SILENCE or DISABLE command was issued via the command API. The match has no effect.", rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Alarm %s matched a silence entry, but no SILENCE or DISABLE command was issued via the command API. The match has no effect.", rrdcalc_name(rc));
} else { } else {
netdata_log_debug(D_HEALTH, "Alarm %s via the command API - name:%s context:%s chart:%s host:%s family:%s" netdata_log_debug(D_HEALTH, "Alarm %s via the command API - name:%s context:%s chart:%s host:%s"
, (silencers->stype == STYPE_DISABLE_ALARMS)?"Disabled":"Silenced" , (silencers->stype == STYPE_DISABLE_ALARMS)?"Disabled":"Silenced"
, rrdcalc_name(rc) , rrdcalc_name(rc)
, (rc->rrdset)?rrdset_context(rc->rrdset):"" , (rc->rrdset)?rrdset_context(rc->rrdset):""
, rrdcalc_chart_name(rc) , rrdcalc_chart_name(rc)
, host , host
, (rc->rrdset)?rrdset_family(rc->rrdset):""
); );
} }
return silencers->stype; return silencers->stype;
@ -1151,7 +1143,6 @@ void *health_main(void *ptr) {
rc->rrdset->id, rc->rrdset->id,
rc->rrdset->context, rc->rrdset->context,
rc->rrdset->name, rc->rrdset->name,
rc->rrdset->family,
rc->classification, rc->classification,
rc->component, rc->component,
rc->type, rc->type,
@ -1419,7 +1410,6 @@ void *health_main(void *ptr) {
rc->rrdset->id, rc->rrdset->id,
rc->rrdset->context, rc->rrdset->context,
rc->rrdset->name, rc->rrdset->name,
rc->rrdset->family,
rc->classification, rc->classification,
rc->component, rc->component,
rc->type, rc->type,
@ -1507,7 +1497,6 @@ void *health_main(void *ptr) {
rc->rrdset->id, rc->rrdset->id,
rc->rrdset->context, rc->rrdset->context,
rc->rrdset->name, rc->rrdset->name,
rc->rrdset->family,
rc->classification, rc->classification,
rc->component, rc->component,
rc->type, rc->type,

View file

@ -71,7 +71,6 @@ ALARM_ENTRY* health_create_alarm_entry(
STRING *chart, STRING *chart,
STRING *chart_context, STRING *chart_context,
STRING *chart_id, STRING *chart_id,
STRING *family,
STRING *classification, STRING *classification,
STRING *component, STRING *component,
STRING *type, STRING *type,

View file

@ -9,7 +9,6 @@
#define HEALTH_ON_KEY "on" #define HEALTH_ON_KEY "on"
#define HEALTH_HOST_KEY "hosts" #define HEALTH_HOST_KEY "hosts"
#define HEALTH_OS_KEY "os" #define HEALTH_OS_KEY "os"
#define HEALTH_FAMILIES_KEY "families"
#define HEALTH_PLUGIN_KEY "plugin" #define HEALTH_PLUGIN_KEY "plugin"
#define HEALTH_MODULE_KEY "module" #define HEALTH_MODULE_KEY "module"
#define HEALTH_CHARTS_KEY "charts" #define HEALTH_CHARTS_KEY "charts"
@ -475,7 +474,6 @@ static inline void alert_config_free(struct alert_config *cfg)
string_freez(cfg->os); string_freez(cfg->os);
string_freez(cfg->host); string_freez(cfg->host);
string_freez(cfg->on); string_freez(cfg->on);
string_freez(cfg->families);
string_freez(cfg->plugin); string_freez(cfg->plugin);
string_freez(cfg->module); string_freez(cfg->module);
string_freez(cfg->charts); string_freez(cfg->charts);
@ -517,7 +515,6 @@ static int health_readfile(const char *filename, void *data) {
hash_os = 0, hash_os = 0,
hash_on = 0, hash_on = 0,
hash_host = 0, hash_host = 0,
hash_families = 0,
hash_plugin = 0, hash_plugin = 0,
hash_module = 0, hash_module = 0,
hash_charts = 0, hash_charts = 0,
@ -550,7 +547,6 @@ static int health_readfile(const char *filename, void *data) {
hash_on = simple_uhash(HEALTH_ON_KEY); hash_on = simple_uhash(HEALTH_ON_KEY);
hash_os = simple_uhash(HEALTH_OS_KEY); hash_os = simple_uhash(HEALTH_OS_KEY);
hash_host = simple_uhash(HEALTH_HOST_KEY); hash_host = simple_uhash(HEALTH_HOST_KEY);
hash_families = simple_uhash(HEALTH_FAMILIES_KEY);
hash_plugin = simple_uhash(HEALTH_PLUGIN_KEY); hash_plugin = simple_uhash(HEALTH_PLUGIN_KEY);
hash_module = simple_uhash(HEALTH_MODULE_KEY); hash_module = simple_uhash(HEALTH_MODULE_KEY);
hash_charts = simple_uhash(HEALTH_CHARTS_KEY); hash_charts = simple_uhash(HEALTH_CHARTS_KEY);
@ -1088,15 +1084,6 @@ static int health_readfile(const char *filename, void *data) {
} }
rt->type = string_strdupz(value); rt->type = string_strdupz(value);
} }
else if(hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY)) {
alert_cfg->families = string_strdupz(value);
string_freez(rt->family_match);
simple_pattern_free(rt->family_pattern);
rt->family_match = string_strdupz(value);
rt->family_pattern = simple_pattern_create(rrdcalctemplate_family_match(rt), NULL, SIMPLE_PATTERN_EXACT,
true);
}
else if(hash == hash_plugin && !strcasecmp(key, HEALTH_PLUGIN_KEY)) { else if(hash == hash_plugin && !strcasecmp(key, HEALTH_PLUGIN_KEY)) {
alert_cfg->plugin = string_strdupz(value); alert_cfg->plugin = string_strdupz(value);
string_freez(rt->plugin_match); string_freez(rt->plugin_match);

View file

@ -49,7 +49,6 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC
"\t\t\t\"config_hash_id\": \"%s\",\n" "\t\t\t\"config_hash_id\": \"%s\",\n"
"\t\t\t\"name\": \"%s\",\n" "\t\t\t\"name\": \"%s\",\n"
"\t\t\t\"chart\": \"%s\",\n" "\t\t\t\"chart\": \"%s\",\n"
"\t\t\t\"family\": \"%s\",\n"
"\t\t\t\"class\": \"%s\",\n" "\t\t\t\"class\": \"%s\",\n"
"\t\t\t\"component\": \"%s\",\n" "\t\t\t\"component\": \"%s\",\n"
"\t\t\t\"type\": \"%s\",\n" "\t\t\t\"type\": \"%s\",\n"
@ -83,7 +82,6 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC
, hash_id , hash_id
, rrdcalc_name(rc) , rrdcalc_name(rc)
, rrdcalc_chart_name(rc) , rrdcalc_chart_name(rc)
, (rc->rrdset)?rrdset_family(rc->rrdset):""
, rc->classification?rrdcalc_classification(rc):"Unknown" , rc->classification?rrdcalc_classification(rc):"Unknown"
, rc->component?rrdcalc_component(rc):"Unknown" , rc->component?rrdcalc_component(rc):"Unknown"
, rc->type?rrdcalc_type(rc):"Unknown" , rc->type?rrdcalc_type(rc):"Unknown"

View file

@ -21,7 +21,6 @@ inline ALARM_ENTRY* health_create_alarm_entry(
STRING *chart, STRING *chart,
STRING *chart_context, STRING *chart_context,
STRING *chart_name, STRING *chart_name,
STRING *family,
STRING *class, STRING *class,
STRING *component, STRING *component,
STRING *type, STRING *type,
@ -52,7 +51,6 @@ inline ALARM_ENTRY* health_create_alarm_entry(
uuid_generate_random(ae->transition_id); uuid_generate_random(ae->transition_id);
ae->global_id = now_realtime_usec(); ae->global_id = now_realtime_usec();
ae->family = string_dup(family);
ae->classification = string_dup(class); ae->classification = string_dup(class);
ae->component = string_dup(component); ae->component = string_dup(component);
ae->type = string_dup(type); ae->type = string_dup(type);
@ -134,7 +132,6 @@ inline void health_alarm_log_free_one_nochecks_nounlink(ALARM_ENTRY *ae) {
string_freez(ae->name); string_freez(ae->name);
string_freez(ae->chart); string_freez(ae->chart);
string_freez(ae->chart_context); string_freez(ae->chart_context);
string_freez(ae->family);
string_freez(ae->classification); string_freez(ae->classification);
string_freez(ae->component); string_freez(ae->component);
string_freez(ae->type); string_freez(ae->type);

View file

@ -58,7 +58,7 @@ if { [ "${1}" = "test" ] || [ "${2}" = "test" ]; } && [ "${#}" -le 2 ]; then
echo >&2 echo >&2
echo >&2 "# SENDING TEST ${x} ALARM TO ROLE: ${recipient}" echo >&2 "# SENDING TEST ${x} ALARM TO ROLE: ${recipient}"
"${0}" "${recipient}" "$(hostname)" 1 1 "${id}" "$(date +%s)" "test_alarm" "test.chart" "test.family" "${x}" "${last}" 100 90 "${0}" 1 $((0 + id)) "units" "this is a test alarm to verify notifications work" "new value" "old value" "evaluated expression" "expression variable values" 0 0 "${0}" "${recipient}" "$(hostname)" 1 1 "${id}" "$(date +%s)" "test_alarm" "test.chart" "${x}" "${last}" 100 90 "${0}" 1 $((0 + id)) "units" "this is a test alarm to verify notifications work" "new value" "old value" "evaluated expression" "expression variable values" 0 0 "" "" "Test" "command to edit the alarm=0=$(hostname)" "" "" "a test alarm"
#shellcheck disable=SC2181 #shellcheck disable=SC2181
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo >&2 "# FAILED" echo >&2 "# FAILED"
@ -239,31 +239,30 @@ else
when="${6}" # the timestamp this event occurred when="${6}" # the timestamp this event occurred
name="${7}" # the name of the alarm, as given in netdata health.d entries name="${7}" # the name of the alarm, as given in netdata health.d entries
chart="${8}" # the name of the chart (type.id) chart="${8}" # the name of the chart (type.id)
family="${9}" # the family of the chart status="${9}" # the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
status="${10}" # the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL old_status="${10}" # the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
old_status="${11}" # the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL value="${11}" # the current value of the alarm
value="${12}" # the current value of the alarm old_value="${12}" # the previous value of the alarm
old_value="${13}" # the previous value of the alarm src="${13}" # the line number and file the alarm has been configured
src="${14}" # the line number and file the alarm has been configured duration="${14}" # the duration in seconds of the previous alarm state
duration="${15}" # the duration in seconds of the previous alarm state non_clear_duration="${15}" # the total duration in seconds this is/was non-clear
non_clear_duration="${16}" # the total duration in seconds this is/was non-clear units="${16}" # the units of the value
units="${17}" # the units of the value info="${17}" # a short description of the alarm
info="${18}" # a short description of the alarm value_string="${18}" # friendly value (with units)
value_string="${19}" # friendly value (with units)
# shellcheck disable=SC2034 # shellcheck disable=SC2034
# variable is unused, but https://github.com/netdata/netdata/pull/5164#discussion_r255572947 # variable is unused, but https://github.com/netdata/netdata/pull/5164#discussion_r255572947
old_value_string="${20}" # friendly old value (with units), previously named "old_value_string" old_value_string="${19}" # friendly old value (with units), previously named "old_value_string"
calc_expression="${21}" # contains the expression that was evaluated to trigger the alarm calc_expression="${20}" # contains the expression that was evaluated to trigger the alarm
calc_param_values="${22}" # the values of the parameters in the expression, at the time of the evaluation calc_param_values="${21}" # the values of the parameters in the expression, at the time of the evaluation
total_warnings="${23}" # Total number of alarms in WARNING state total_warnings="${22}" # Total number of alarms in WARNING state
total_critical="${24}" # Total number of alarms in CRITICAL state total_critical="${23}" # Total number of alarms in CRITICAL state
total_warn_alarms="${25}" # List of alarms in warning state total_warn_alarms="${24}" # List of alarms in warning state
total_crit_alarms="${26}" # List of alarms in critical state total_crit_alarms="${25}" # List of alarms in critical state
classification="${27}" # The class field from .conf files classification="${26}" # The class field from .conf files
edit_command_line="${28}" # The command to edit the alarm, with the line number edit_command_line="${27}" # The command to edit the alarm, with the line number
child_machine_guid="${29}" # the machine_guid of the child child_machine_guid="${28}" # the machine_guid of the child
transition_id="${30}" # the transition_id of the alert transition_id="${29}" # the transition_id of the alert
summary="${31}" # the summary text field of the alert summary="${30}" # the summary text field of the alert
fi fi
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
@ -1133,7 +1132,7 @@ send_kafka() {
local httpcode sent=0 local httpcode sent=0
if [ "${SEND_KAFKA}" = "YES" ]; then if [ "${SEND_KAFKA}" = "YES" ]; then
httpcode=$(docurl -X POST \ httpcode=$(docurl -X POST \
--data "{host_ip:\"${KAFKA_SENDER_IP}\",when:${when},name:\"${name}\",chart:\"${chart}\",family:\"${family}\",status:\"${status}\",old_status:\"${old_status}\",value:${value},old_value:${old_value},duration:${duration},non_clear_duration:${non_clear_duration},units:\"${units}\",info:\"${info}\"}" \ --data "{host_ip:\"${KAFKA_SENDER_IP}\",when:${when},name:\"${name}\",chart:\"${chart}\",status:\"${status}\",old_status:\"${old_status}\",value:${value},old_value:${old_value},duration:${duration},non_clear_duration:${non_clear_duration},units:\"${units}\",info:\"${info}\"}" \
"${KAFKA_URL}") "${KAFKA_URL}")
if [ "${httpcode}" = "204" ]; then if [ "${httpcode}" = "204" ]; then
@ -1168,7 +1167,7 @@ send_pd() {
current_time=$(date -r ${when} +'%Y-%m-%dT%H:%M:%S.000') current_time=$(date -r ${when} +'%Y-%m-%dT%H:%M:%S.000')
fi fi
for PD_SERVICE_KEY in ${recipients}; do for PD_SERVICE_KEY in ${recipients}; do
d="${status} ${name} = ${value_string} - ${host}, ${family}" d="${status} ${name} = ${value_string} - ${host}"
if [ ${USE_PD_VERSION} = "2" ]; then if [ ${USE_PD_VERSION} = "2" ]; then
payload="$( payload="$(
cat <<EOF cat <<EOF
@ -1178,7 +1177,6 @@ send_pd() {
"source" : "${args_host}", "source" : "${args_host}",
"severity" : "${severity}", "severity" : "${severity}",
"timestamp" : "${current_time}", "timestamp" : "${current_time}",
"group" : "${family}",
"class" : "${chart}", "class" : "${chart}",
"custom_details": { "custom_details": {
"value_w_units": "${value_string}", "value_w_units": "${value_string}",
@ -1188,7 +1186,6 @@ send_pd() {
"alarm_id" : "${alarm_id}", "alarm_id" : "${alarm_id}",
"name" : "${name}", "name" : "${name}",
"chart" : "${chart}", "chart" : "${chart}",
"family" : "${family}",
"status" : "${status}", "status" : "${status}",
"old_status" : "${old_status}", "old_status" : "${old_status}",
"value" : "${value}", "value" : "${value}",
@ -1223,7 +1220,6 @@ EOF
"alarm_id" : "${alarm_id}", "alarm_id" : "${alarm_id}",
"name" : "${name}", "name" : "${name}",
"chart" : "${chart}", "chart" : "${chart}",
"family" : "${family}",
"status" : "${status}", "status" : "${status}",
"old_status" : "${old_status}", "old_status" : "${old_status}",
"value" : "${value}", "value" : "${value}",
@ -1471,7 +1467,7 @@ send_msteams() {
"@type": "MessageCard", "@type": "MessageCard",
"themeColor": "${color}", "themeColor": "${color}",
"title": "$icon Alert ${status} from netdata for ${host}", "title": "$icon Alert ${status} from netdata for ${host}",
"text": "${host} ${status_message}, ${chart} (_${family}_), *${alarm}*", "text": "${host} ${status_message}, ${chart}, *${alarm}*",
"potentialAction": [ "potentialAction": [
{ {
"@type": "OpenUri", "@type": "OpenUri",
@ -1536,10 +1532,10 @@ send_slack() {
$ch $ch
"username": "netdata on ${host}", "username": "netdata on ${host}",
"icon_url": "${images_base_url}/images/banner-icon-144x144.png", "icon_url": "${images_base_url}/images/banner-icon-144x144.png",
"text": "${host} ${status_message}, \`${chart}\` (_${family}_), *${alarm}*", "text": "${host} ${status_message}, \`${chart}\`, *${alarm}*",
"attachments": [ "attachments": [
{ {
"fallback": "${alarm} - ${chart} (${family}) - ${info}", "fallback": "${alarm} - ${chart} - ${info}",
"color": "${color}", "color": "${color}",
"title": "${alarm}", "title": "${alarm}",
"title_link": "${goto_url}", "title_link": "${goto_url}",
@ -1549,11 +1545,6 @@ send_slack() {
"title": "${chart}", "title": "${chart}",
"value": "chart", "value": "chart",
"short": true "short": true
},
{
"title": "${family}",
"value": "family",
"short": true
} }
], ],
"thumb_url": "${image}", "thumb_url": "${image}",
@ -1601,7 +1592,7 @@ send_rocketchat() {
"channel": "#${channel}", "channel": "#${channel}",
"alias": "netdata on ${host}", "alias": "netdata on ${host}",
"avatar": "${images_base_url}/images/banner-icon-144x144.png", "avatar": "${images_base_url}/images/banner-icon-144x144.png",
"text": "${host} ${status_message}, \`${chart}\` (_${family}_), *${alarm}*", "text": "${host} ${status_message}, \`${chart}\`, *${alarm}*",
"attachments": [ "attachments": [
{ {
"color": "${color}", "color": "${color}",
@ -1613,11 +1604,6 @@ send_rocketchat() {
"title": "${chart}", "title": "${chart}",
"short": true, "short": true,
"value": "chart" "value": "chart"
},
{
"title": "${family}",
"short": true,
"value": "family"
} }
], ],
"thumb_url": "${image}", "thumb_url": "${image}",
@ -1661,7 +1647,7 @@ send_alerta() {
resource=$chart resource=$chart
event=$name event=$name
else else
resource="${host}:${family}" resource="${host}"
event="${chart}.${name}" event="${chart}.${name}"
fi fi
@ -1682,7 +1668,6 @@ send_alerta() {
"roles": "${roles}", "roles": "${roles}",
"name": "${name}", "name": "${name}",
"chart": "${chart}", "chart": "${chart}",
"family": "${family}",
"source": "${src}", "source": "${src}",
"moreInfo": "<a href=\"${goto_url}\">View Netdata</a>" "moreInfo": "<a href=\"${goto_url}\">View Netdata</a>"
}, },
@ -1739,7 +1724,7 @@ send_flock() {
\"timestamp\": \"${when}\", \"timestamp\": \"${when}\",
\"attachments\": [ \"attachments\": [
{ {
\"description\": \"${chart} (${family}) - ${info}\", \"description\": \"${chart} - ${info}\",
\"color\": \"${color}\", \"color\": \"${color}\",
\"title\": \"${alarm}\", \"title\": \"${alarm}\",
\"url\": \"${goto_url}\", \"url\": \"${goto_url}\",
@ -1791,7 +1776,7 @@ send_discord() {
{ {
"channel": "#${channel}", "channel": "#${channel}",
"username": "${username}", "username": "${username}",
"text": "${host} ${status_message}, \`${chart}\` (_${family}_), *${alarm}*", "text": "${host} ${status_message}, \`${chart}\`, *${alarm}*",
"icon_url": "${images_base_url}/images/banner-icon-144x144.png", "icon_url": "${images_base_url}/images/banner-icon-144x144.png",
"attachments": [ "attachments": [
{ {
@ -1802,7 +1787,6 @@ send_discord() {
"fields": [ "fields": [
{ {
"title": "${chart}", "title": "${chart}",
"value": "${family}"
} }
], ],
"thumb_url": "${image}", "thumb_url": "${image}",
@ -1835,7 +1819,7 @@ EOF
send_fleep() { send_fleep() {
local httpcode sent=0 webhooks="${1}" data message local httpcode sent=0 webhooks="${1}" data message
if [ "${SEND_FLEEP}" = "YES" ]; then if [ "${SEND_FLEEP}" = "YES" ]; then
message="${host} ${status_message}, \`${chart}\` (${family}), *${alarm}*\\n${info}" message="${host} ${status_message}, \`${chart}\`, *${alarm}*\\n${info}"
for hook in ${webhooks}; do for hook in ${webhooks}; do
data="{ " data="{ "
@ -1865,7 +1849,7 @@ send_fleep() {
send_prowl() { send_prowl() {
local httpcode sent=0 data message keys prio=0 alarm_url event local httpcode sent=0 data message keys prio=0 alarm_url event
if [ "${SEND_PROWL}" = "YES" ]; then if [ "${SEND_PROWL}" = "YES" ]; then
message="$(urlencode "${host} ${status_message}, \`${chart}\` (${family}), *${alarm}*\\n${info}")" message="$(urlencode "${host} ${status_message}, \`${chart}\`, *${alarm}*\\n${info}")"
message="description=${message}" message="description=${message}"
keys="$(urlencode "$(echo "${1}" | tr ' ' ,)")" keys="$(urlencode "$(echo "${1}" | tr ' ' ,)")"
keys="apikey=${keys}" keys="apikey=${keys}"
@ -1995,8 +1979,8 @@ send_matrix() {
{ {
"msgtype": "m.notice", "msgtype": "m.notice",
"format": "org.matrix.custom.html", "format": "org.matrix.custom.html",
"formatted_body": "${emoji} ${host} ${status_message} - <b>${name//_/ }</b><br>${chart} (${family})<br><a href=\"${goto_url}\">${alarm}</a><br><i>${info}</i>", "formatted_body": "${emoji} ${host} ${status_message} - <b>${name//_/ }</b><br>${chart}<br><a href=\"${goto_url}\">${alarm}</a><br><i>${info}</i>",
"body": "${emoji} ${host} ${status_message} - ${name//_/ } ${chart} (${family}) ${goto_url} ${alarm} ${info}" "body": "${emoji} ${host} ${status_message} - ${name//_/ } ${chart} ${goto_url} ${alarm} ${info}"
} }
EOF EOF
)" )"
@ -2094,7 +2078,7 @@ send_sms() {
local recipients="${1}" errcode errmessage sent=0 local recipients="${1}" errcode errmessage sent=0
# Human readable SMS # Human readable SMS
local msg="${host} ${status_message}: ${chart} (${family}), ${alarm}" local msg="${host} ${status_message}: ${chart}, ${alarm}"
# limit it to 160 characters # limit it to 160 characters
msg="${msg:0:160}" msg="${msg:0:160}"
@ -2118,7 +2102,6 @@ send_sms() {
return 1 return 1
} }
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Dynatrace sender # Dynatrace sender
@ -2201,7 +2184,6 @@ send_opsgenie() {
"chart" : "${chart}", "chart" : "${chart}",
"when": ${when}, "when": ${when},
"name" : "${name}", "name" : "${name}",
"family" : "${family}",
"priority" : "${priority}", "priority" : "${priority}",
"status" : "${status}", "status" : "${status}",
"old_status" : "${old_status}", "old_status" : "${old_status}",
@ -2336,14 +2318,12 @@ urlencode "${args_host}" >/dev/null
url_host="${REPLY}" url_host="${REPLY}"
urlencode "${chart}" >/dev/null urlencode "${chart}" >/dev/null
url_chart="${REPLY}" url_chart="${REPLY}"
urlencode "${family}" >/dev/null
url_family="${REPLY}"
urlencode "${name}" >/dev/null urlencode "${name}" >/dev/null
url_name="${REPLY}" url_name="${REPLY}"
urlencode "${value_string}" >/dev/null urlencode "${value_string}" >/dev/null
url_value_string="${REPLY}" url_value_string="${REPLY}"
redirect_params="host=${url_host}&chart=${url_chart}&family=${url_family}&alarm=${url_name}&alarm_unique_id=${unique_id}&alarm_id=${alarm_id}&alarm_event_id=${event_id}&alarm_when=${when}&alarm_status=${status}&alarm_chart=${chart}&alarm_value=${url_value_string}" redirect_params="host=${url_host}&chart=${url_chart}&alarm=${url_name}&alarm_unique_id=${unique_id}&alarm_id=${alarm_id}&alarm_event_id=${event_id}&alarm_when=${when}&alarm_status=${status}&alarm_chart=${chart}&alarm_value=${url_value_string}"
if [ -z "${NETDATA_REGISTRY_UNIQUE_ID}" ]; then if [ -z "${NETDATA_REGISTRY_UNIQUE_ID}" ]; then
if [ -f "@registrydir_POST@/netdata.public.unique.id" ]; then if [ -f "@registrydir_POST@/netdata.public.unique.id" ]; then
@ -2522,7 +2502,6 @@ SENT_DISCORD=$?
send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${when}" "${goto_url}" "${status}" "${host} ${status_message} - ${name//_/ } - ${chart}" " send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${when}" "${goto_url}" "${status}" "${host} ${status_message} - ${name//_/ } - ${chart}" "
<font color=\"${color}\"><b>${alarm}</b></font>${info_html}<br/>&nbsp; <font color=\"${color}\"><b>${alarm}</b></font>${info_html}<br/>&nbsp;
<small><b>${chart}</b><br/>Chart<br/>&nbsp;</small> <small><b>${chart}</b><br/>Chart<br/>&nbsp;</small>
<small><b>${family}</b><br/>Family<br/>&nbsp;</small>
<small><b>${severity}</b><br/>Severity<br/>&nbsp;</small> <small><b>${severity}</b><br/>Severity<br/>&nbsp;</small>
<small><b>${date}${raised_for_html}</b><br/>Time<br/>&nbsp;</small> <small><b>${date}${raised_for_html}</b><br/>Time<br/>&nbsp;</small>
<a href=\"${goto_url}\">View Netdata</a><br/>&nbsp; <a href=\"${goto_url}\">View Netdata</a><br/>&nbsp;
@ -2537,7 +2516,6 @@ SENT_PUSHOVER=$?
send_pushbullet "${PUSHBULLET_ACCESS_TOKEN}" "${PUSHBULLET_SOURCE_DEVICE}" "${to_pushbullet}" "${goto_url}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}\\n send_pushbullet "${PUSHBULLET_ACCESS_TOKEN}" "${PUSHBULLET_SOURCE_DEVICE}" "${to_pushbullet}" "${goto_url}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}\\n
Severity: ${severity}\\n Severity: ${severity}\\n
Chart: ${chart}\\n Chart: ${chart}\\n
Family: ${family}\\n
${date}\\n ${date}\\n
The source of this alarm is line ${src}" The source of this alarm is line ${src}"
@ -2549,7 +2527,6 @@ SENT_PUSHBULLET=$?
send_twilio "${TWILIO_ACCOUNT_SID}" "${TWILIO_ACCOUNT_TOKEN}" "${TWILIO_NUMBER}" "${to_twilio}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm} send_twilio "${TWILIO_ACCOUNT_SID}" "${TWILIO_ACCOUNT_TOKEN}" "${TWILIO_NUMBER}" "${to_twilio}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}
Severity: ${severity} Severity: ${severity}
Chart: ${chart} Chart: ${chart}
Family: ${family}
${info}" ${info}"
SENT_TWILIO=$? SENT_TWILIO=$?
@ -2560,7 +2537,6 @@ SENT_TWILIO=$?
send_messagebird "${MESSAGEBIRD_ACCESS_KEY}" "${MESSAGEBIRD_NUMBER}" "${to_messagebird}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm} send_messagebird "${MESSAGEBIRD_ACCESS_KEY}" "${MESSAGEBIRD_NUMBER}" "${to_messagebird}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}
Severity: ${severity} Severity: ${severity}
Chart: ${chart} Chart: ${chart}
Family: ${family}
${info}" ${info}"
SENT_MESSAGEBIRD=$? SENT_MESSAGEBIRD=$?
@ -2571,7 +2547,6 @@ SENT_MESSAGEBIRD=$?
send_kavenegar "${KAVENEGAR_API_KEY}" "${KAVENEGAR_SENDER}" "${to_kavenegar}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm} send_kavenegar "${KAVENEGAR_API_KEY}" "${KAVENEGAR_SENDER}" "${to_kavenegar}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}
Severity: ${severity} Severity: ${severity}
Chart: ${chart} Chart: ${chart}
Family: ${family}
${info}" ${info}"
SENT_KAVENEGAR=$? SENT_KAVENEGAR=$?
@ -2581,7 +2556,7 @@ SENT_KAVENEGAR=$?
# https://core.telegram.org/bots/api#formatting-options # https://core.telegram.org/bots/api#formatting-options
send_telegram "${TELEGRAM_BOT_TOKEN}" "${to_telegram}" "${host} ${status_message} - <b>${name//_/ }</b> send_telegram "${TELEGRAM_BOT_TOKEN}" "${to_telegram}" "${host} ${status_message} - <b>${name//_/ }</b>
${chart} (${family}) ${chart}
<a href=\"${goto_url}\">${alarm}</a> <a href=\"${goto_url}\">${alarm}</a>
<i>${info}</i>" <i>${info}</i>"
@ -2617,7 +2592,6 @@ SENT_PROWL=$?
send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${IRC_NETWORK}" "${IRC_PORT}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm} send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${IRC_NETWORK}" "${IRC_PORT}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
Severity: ${severity} Severity: ${severity}
Chart: ${chart} Chart: ${chart}
Family: ${family}
${info}" ${info}"
SENT_IRC=$? SENT_IRC=$?
@ -2652,7 +2626,7 @@ SENT_CUSTOM=$?
send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \ send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
${host} ${status_message}<br/> \ ${host} ${status_message}<br/> \
<b>${alarm}</b> ${info_html}<br/> \ <b>${alarm}</b> ${info_html}<br/> \
<b>${chart}</b> (family <b>${family}</b>)<br/> \ <b>${chart}</b><br/> \
<b>${date}${raised_for_html}</b><br/> \ <b>${date}${raised_for_html}</b><br/> \
<a href=\\\"${goto_url}\\\">View netdata dashboard</a> \ <a href=\\\"${goto_url}\\\">View netdata dashboard</a> \
(source of alarm ${src}) \ (source of alarm ${src}) \
@ -2695,7 +2669,6 @@ ${alarm} ${info}
${raised_for} ${raised_for}
Chart : ${chart} Chart : ${chart}
Family : ${family}
Severity: ${severity} Severity: ${severity}
URL : ${goto_url} URL : ${goto_url}
Source : ${src} Source : ${src}
@ -2719,7 +2692,6 @@ ${email_thread_headers}
X-Netdata-Severity: ${status,,} X-Netdata-Severity: ${status,,}
X-Netdata-Alert-Name: $name X-Netdata-Alert-Name: $name
X-Netdata-Chart: $chart X-Netdata-Chart: $chart
X-Netdata-Family: $family
X-Netdata-Classification: $classification X-Netdata-Classification: $classification
X-Netdata-Host: $host X-Netdata-Host: $host
X-Netdata-Role: $roles X-Netdata-Role: $roles
@ -3473,7 +3445,6 @@ ${email_thread_headers}
X-Netdata-Severity: ${status,,} X-Netdata-Severity: ${status,,}
X-Netdata-Alert-Name: $name X-Netdata-Alert-Name: $name
X-Netdata-Chart: $chart X-Netdata-Chart: $chart
X-Netdata-Family: $family
X-Netdata-Classification: $classification X-Netdata-Classification: $classification
X-Netdata-Host: $host X-Netdata-Host: $host
X-Netdata-Role: $roles X-Netdata-Role: $roles

View file

@ -75,8 +75,6 @@
| `${url_name}` | Same as ${name} but URL encoded | | `${url_name}` | Same as ${name} but URL encoded |
| `${chart}` | The name of the chart (type.id) | | `${chart}` | The name of the chart (type.id) |
| `${url_chart}` | Same as ${chart} but URL encoded | | `${url_chart}` | Same as ${chart} but URL encoded |
| `${family}` | The family of the chart |
| `${url_family}` | Same as ${family} but URL encoded |
| `${status}` | The current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL | | `${status}` | The current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
| `${old_status}` | The previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL | | `${old_status}` | The previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
| `${value}` | The current value of the alarm | | `${value}` | The current value of the alarm |

View file

@ -99,8 +99,6 @@
| `${url_name}` | Same as ${name} but URL encoded | | `${url_name}` | Same as ${name} but URL encoded |
| `${chart}` | The name of the chart (type.id) | | `${chart}` | The name of the chart (type.id) |
| `${url_chart}` | Same as ${chart} but URL encoded | | `${url_chart}` | Same as ${chart} but URL encoded |
| `${family}` | The family of the chart |
| `${url_family}` | Same as ${family} but URL encoded |
| `${status}` | The current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL | | `${status}` | The current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
| `${old_status}` | The previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL | | `${old_status}` | The previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
| `${value}` | The current value of the alarm | | `${value}` | The current value of the alarm |

View file

@ -867,8 +867,6 @@ custom_sender() {
# ${url_name} same as ${name} but URL encoded # ${url_name} same as ${name} but URL encoded
# ${chart} the name of the chart (type.id) # ${chart} the name of the chart (type.id)
# ${url_chart} same as ${chart} but URL encoded # ${url_chart} same as ${chart} but URL encoded
# ${family} the family of the chart
# ${url_family} same as ${family} but URL encoded
# ${status} the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL # ${status} the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
# ${old_status} the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL # ${old_status} the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
# ${value} the current value of the alarm # ${value} the current value of the alarm

View file

@ -29,8 +29,8 @@ void health_silencers_add(SILENCER *silencer) {
// Add the created instance to the linked list in silencers // Add the created instance to the linked list in silencers
silencer->next = silencers->silencers; silencer->next = silencers->silencers;
silencers->silencers = silencer; silencers->silencers = silencer;
netdata_log_debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s:%s", silencer->alarms, netdata_log_debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s", silencer->alarms,
silencer->charts, silencer->contexts, silencer->hosts, silencer->families silencer->charts, silencer->contexts, silencer->hosts
); );
} }
@ -51,8 +51,7 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
hash_template = 0, hash_template = 0,
hash_chart = 0, hash_chart = 0,
hash_context = 0, hash_context = 0,
hash_host = 0, hash_host = 0;
hash_families = 0;
if (unlikely(!hash_alarm)) { if (unlikely(!hash_alarm)) {
hash_alarm = simple_uhash(HEALTH_ALARM_KEY); hash_alarm = simple_uhash(HEALTH_ALARM_KEY);
@ -60,7 +59,6 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
hash_chart = simple_uhash(HEALTH_CHART_KEY); hash_chart = simple_uhash(HEALTH_CHART_KEY);
hash_context = simple_uhash(HEALTH_CONTEXT_KEY); hash_context = simple_uhash(HEALTH_CONTEXT_KEY);
hash_host = simple_uhash(HEALTH_HOST_KEY); hash_host = simple_uhash(HEALTH_HOST_KEY);
hash_families = simple_uhash(HEALTH_FAMILIES_KEY);
} }
uint32_t hash = simple_uhash(key); uint32_t hash = simple_uhash(key);
@ -70,8 +68,7 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
(hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) || (hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) ||
(hash == hash_chart && !strcasecmp(key, HEALTH_CHART_KEY)) || (hash == hash_chart && !strcasecmp(key, HEALTH_CHART_KEY)) ||
(hash == hash_context && !strcasecmp(key, HEALTH_CONTEXT_KEY)) || (hash == hash_context && !strcasecmp(key, HEALTH_CONTEXT_KEY)) ||
(hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) || (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY))
(hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY))
) { ) {
silencer = create_silencer(); silencer = create_silencer();
if(!silencer) { if(!silencer) {
@ -93,9 +90,6 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
} else if (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) { } else if (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) {
silencer->hosts = strdupz(value); silencer->hosts = strdupz(value);
silencer->hosts_pattern = simple_pattern_create(silencer->hosts, NULL, SIMPLE_PATTERN_EXACT, true); silencer->hosts_pattern = simple_pattern_create(silencer->hosts, NULL, SIMPLE_PATTERN_EXACT, true);
} else if (hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY)) {
silencer->families = strdupz(value);
silencer->families_pattern = simple_pattern_create(silencer->families, NULL, SIMPLE_PATTERN_EXACT, true);
} }
return silencer; return silencer;
@ -172,4 +166,4 @@ int health_initialize_global_silencers() {
silencers->silencers=NULL; silencers->silencers=NULL;
return 0; return 0;
} }

View file

@ -11,7 +11,6 @@
#define HEALTH_CHART_KEY "chart" #define HEALTH_CHART_KEY "chart"
#define HEALTH_HOST_KEY "hosts" #define HEALTH_HOST_KEY "hosts"
#define HEALTH_OS_KEY "os" #define HEALTH_OS_KEY "os"
#define HEALTH_FAMILIES_KEY "families"
#define HEALTH_LOOKUP_KEY "lookup" #define HEALTH_LOOKUP_KEY "lookup"
#define HEALTH_CALC_KEY "calc" #define HEALTH_CALC_KEY "calc"
@ -28,9 +27,6 @@ typedef struct silencer {
char *charts; char *charts;
SIMPLE_PATTERN *charts_pattern; SIMPLE_PATTERN *charts_pattern;
char *families;
SIMPLE_PATTERN *families_pattern;
struct silencer *next; struct silencer *next;
} SILENCER; } SILENCER;

View file

@ -190,12 +190,6 @@ err=0
cmd "cmd=RESET" "$HEALTH_CMDAPI_MSG_RESET" cmd "cmd=RESET" "$HEALTH_CMDAPI_MSG_RESET"
check_list "RESET" check_list "RESET"
# Add silencer without a command to disable or silence alarms
printf -v resp "$HEALTH_CMDAPI_MSG_ADDED\n$HEALTH_CMDAPI_MSG_STYPEWARNING"
cmd "families=load" "${resp}"
check "Family selector with no command" "False False False False False False"
check_list "FAMILIES_LOAD"
# Add silence command # Add silence command
cmd "cmd=SILENCE" "$HEALTH_CMDAPI_MSG_SILENCE" cmd "cmd=SILENCE" "$HEALTH_CMDAPI_MSG_SILENCE"
check "Silence family load" "False False False False False True" check "Silence family load" "False False False False False True"

View file

@ -61,7 +61,7 @@ Specifically, the API allows you to:
- Disable health checks completely. Alert conditions will not be evaluated at all and no entries will be added to the alert log. - Disable health checks completely. Alert conditions will not be evaluated at all and no entries will be added to the alert log.
- Silence alert notifications. Alert conditions will be evaluated, the alerts will appear in the log and the Netdata UI will show the alerts as active, but no notifications will be sent. - Silence alert notifications. Alert conditions will be evaluated, the alerts will appear in the log and the Netdata UI will show the alerts as active, but no notifications will be sent.
- Disable or Silence specific alerts that match selectors on alert/template name, chart, context, host and family. - Disable or Silence specific alerts that match selectors on alert/template name, chart, context, and host.
The API is available by default, but it is protected by an `api authorization token` that is stored in the file you will see in the following entry of `http://NODE:19999/netdata.conf`: The API is available by default, but it is protected by an `api authorization token` that is stored in the file you will see in the following entry of `http://NODE:19999/netdata.conf`:
@ -138,7 +138,6 @@ The accepted keys for the `selection criteria` are the following:
- `chart` : Chart ids/names, as shown on the dashboard. These will match the `on` entry of a configured `alarm`. - `chart` : Chart ids/names, as shown on the dashboard. These will match the `on` entry of a configured `alarm`.
- `context` : Chart context, as shown on the dashboard. These will match the `on` entry of a configured `template`. - `context` : Chart context, as shown on the dashboard. These will match the `on` entry of a configured `template`.
- `hosts` : The hostnames that will need to match. - `hosts` : The hostnames that will need to match.
- `families` : The alert families.
You can add any of the selection criteria you need on the request, to ensure that only the alerts you are interested in are matched and disabled/silenced. e.g. there is no reason to add `hosts: *`, if you want the criteria to be applied to alerts for all hosts. You can add any of the selection criteria you need on the request, to ensure that only the alerts you are interested in are matched and disabled/silenced. e.g. there is no reason to add `hosts: *`, if you want the criteria to be applied to alerts for all hosts.
@ -154,12 +153,6 @@ Example 2: Silence all alerts and templates with name starting with `out_of` on
http://NODE:19999/api/v1/manage/health?cmd=SILENCE&alarm=out_of*&hosts=myhost http://NODE:19999/api/v1/manage/health?cmd=SILENCE&alarm=out_of*&hosts=myhost
``` ```
Example 2.2: Add one more selector, to also silence alerts for cpu1 and cpu2
```
http://NODE:19999/api/v1/manage/health?families=cpu1 cpu2
```
### List silencers ### List silencers
The command `LIST` was added in Netdata v1.16.0 and returns a JSON with the current status of the silencers. The command `LIST` was added in Netdata v1.16.0 and returns a JSON with the current status of the silencers.

View file

@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// //
// Created by Christopher on 11/12/18. // Created by Christopher on 11/12/18.
// //
@ -14,18 +15,16 @@
void free_silencers(SILENCER *t) { void free_silencers(SILENCER *t) {
if (!t) return; if (!t) return;
if (t->next) free_silencers(t->next); if (t->next) free_silencers(t->next);
netdata_log_debug(D_HEALTH, "HEALTH command API: Freeing silencer %s:%s:%s:%s:%s", t->alarms, netdata_log_debug(D_HEALTH, "HEALTH command API: Freeing silencer %s:%s:%s:%s", t->alarms,
t->charts, t->contexts, t->hosts, t->families); t->charts, t->contexts, t->hosts);
simple_pattern_free(t->alarms_pattern); simple_pattern_free(t->alarms_pattern);
simple_pattern_free(t->charts_pattern); simple_pattern_free(t->charts_pattern);
simple_pattern_free(t->contexts_pattern); simple_pattern_free(t->contexts_pattern);
simple_pattern_free(t->hosts_pattern); simple_pattern_free(t->hosts_pattern);
simple_pattern_free(t->families_pattern);
freez(t->alarms); freez(t->alarms);
freez(t->charts); freez(t->charts);
freez(t->contexts); freez(t->contexts);
freez(t->hosts); freez(t->hosts);
freez(t->families);
freez(t); freez(t);
return; return;
} }
@ -74,7 +73,6 @@ void health_silencers2json(BUFFER *wb) {
j=health_silencers2json_entry(wb, HEALTH_CHART_KEY, silencer->charts, j); j=health_silencers2json_entry(wb, HEALTH_CHART_KEY, silencer->charts, j);
j=health_silencers2json_entry(wb, HEALTH_CONTEXT_KEY, silencer->contexts, j); j=health_silencers2json_entry(wb, HEALTH_CONTEXT_KEY, silencer->contexts, j);
j=health_silencers2json_entry(wb, HEALTH_HOST_KEY, silencer->hosts, j); j=health_silencers2json_entry(wb, HEALTH_HOST_KEY, silencer->hosts, j);
health_silencers2json_entry(wb, HEALTH_FAMILIES_KEY, silencer->families, j);
j=0; j=0;
buffer_strcat(wb, "\n\t\t}"); buffer_strcat(wb, "\n\t\t}");
i++; i++;

View file

@ -1645,14 +1645,6 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "families",
"in": "query",
"description": "The alarm families.",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@ -4426,4 +4418,4 @@
} }
} }
} }
} }

View file

@ -1059,11 +1059,6 @@ paths:
description: The hostnames that will need to match. description: The hostnames that will need to match.
schema: schema:
type: string type: string
- name: families
in: query
description: The alarm families.
schema:
type: string
responses: responses:
"200": "200":
description: A plain text response based on the result of the command. description: A plain text response based on the result of the command.