summaryrefslogtreecommitdiffstats
path: root/health/health.c
diff options
context:
space:
mode:
Diffstat (limited to 'health/health.c')
-rw-r--r--health/health.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/health/health.c b/health/health.c
index 27ae673d8..d49021ed0 100644
--- a/health/health.c
+++ b/health/health.c
@@ -61,7 +61,6 @@ static bool prepare_command(BUFFER *wb,
uint32_t when,
const char *alert_name,
const char *alert_chart_name,
- const char *alert_family,
const char *new_status,
const char *old_status,
NETDATA_DOUBLE new_value,
@@ -82,7 +81,8 @@ static bool prepare_command(BUFFER *wb,
const char *classification,
const char *edit_command,
const char *machine_guid,
- uuid_t *transition_id
+ uuid_t *transition_id,
+ const char *summary
) {
char buf[8192];
size_t n = 8192 - 1;
@@ -117,10 +117,6 @@ static bool prepare_command(BUFFER *wb,
return false;
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))
return false;
buffer_sprintf(wb, " '%s'", buf);
@@ -195,6 +191,10 @@ static bool prepare_command(BUFFER *wb,
return false;
buffer_sprintf(wb, " '%s'", buf);
+ if (!sanitize_command_argument_string(buf, summary, n))
+ return false;
+ buffer_sprintf(wb, " '%s'", buf);
+
return true;
}
@@ -376,9 +376,6 @@ static void health_reload_host(RRDHOST *host) {
// link the loaded alarms to their charts
rrdset_foreach_write(st, host) {
- if (rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED))
- continue;
-
rrdcalc_link_matching_alerts_to_rrdset(st);
rrdcalctemplate_link_matching_templates_to_rrdset(st);
}
@@ -563,7 +560,6 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
(unsigned long)ae->when,
ae_name(ae),
ae->chart?ae_chart_id(ae):"NOCHART",
- ae->family?ae_family(ae):"NOFAMILY",
rrdcalc_status2string(ae->new_status),
rrdcalc_status2string(ae->old_status),
ae->new_value,
@@ -584,7 +580,8 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
ae->classification?ae_classification(ae):"Unknown",
edit_command,
host->machine_guid,
- &ae->transition_id);
+ &ae->transition_id,
+ host->health.use_summary_for_notifications && ae->summary?ae_summary(ae):ae_name(ae));
const char *command_to_run = buffer_tostring(wb);
if (ok) {
@@ -724,11 +721,6 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
return 0;
}
- if(unlikely(rrdset_flag_check(rc->rrdset, RRDSET_FLAG_ARCHIVED))) {
- netdata_log_debug(D_HEALTH, "Health not running alarm '%s.%s'. The chart has been marked as archived", rrdcalc_chart_name(rc), rrdcalc_name(rc));
- return 0;
- }
-
if(unlikely(!rc->rrdset->last_collected_time.tv_sec || rc->rrdset->counter_done < 2)) {
netdata_log_debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not fully collected yet.", rrdcalc_chart_name(rc), rrdcalc_name(rc));
return 0;
@@ -843,9 +835,7 @@ static void initialize_health(RRDHOST *host)
snprintfz(filename, FILENAME_MAX, "%s/alarm-notify.sh", netdata_configured_primary_plugins_dir);
host->health.health_default_exec = string_strdupz(config_get(CONFIG_SECTION_HEALTH, "script to execute on alarm", filename));
host->health.health_default_recipient = string_strdupz("root");
-
- //if (!is_chart_name_populated(&host->host_uuid))
- // chart_name_populate(&host->host_uuid);
+ host->health.use_summary_for_notifications = config_get_boolean(CONFIG_SECTION_HEALTH, "use summary for notifications", CONFIG_BOOLEAN_YES);
sql_health_alarm_log_load(host);
@@ -857,9 +847,6 @@ static void initialize_health(RRDHOST *host)
// link the loaded alarms to their charts
RRDSET *st;
rrdset_foreach_reentrant(st, host) {
- if (rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED))
- continue;
-
rrdcalc_link_matching_alerts_to_rrdset(st);
rrdcalctemplate_link_matching_templates_to_rrdset(st);
}
@@ -886,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) {
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",
- rrdcalc_name(rc), (rc->rrdset)?rrdset_context(rc->rrdset):"", rrdcalc_chart_name(rc), host, (rc->rrdset)?rrdset_family(rc->rrdset):"");
+ 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);
for (s = silencers->silencers; s!=NULL; s=s->next){
if (
(!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->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->families_pattern || (rc->rrdset && rc->rrdset->family && s->families_pattern && simple_pattern_matches_string(s->families_pattern, rc->rrdset->family)))
+ (!s->charts_pattern || (rc->chart && s->charts_pattern && simple_pattern_matches_string(s->charts_pattern, rc->chart)))
) {
- 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)) {
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 {
- 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"
, rrdcalc_name(rc)
, (rc->rrdset)?rrdset_context(rc->rrdset):""
, rrdcalc_chart_name(rc)
, host
- , (rc->rrdset)?rrdset_family(rc->rrdset):""
);
}
return silencers->stype;
@@ -1158,7 +1143,6 @@ void *health_main(void *ptr) {
rc->rrdset->id,
rc->rrdset->context,
rc->rrdset->name,
- rc->rrdset->family,
rc->classification,
rc->component,
rc->type,
@@ -1171,6 +1155,7 @@ void *health_main(void *ptr) {
RRDCALC_STATUS_REMOVED,
rc->source,
rc->units,
+ rc->summary,
rc->info,
0,
rrdcalc_isrepeating(rc)?HEALTH_ENTRY_FLAG_IS_REPEATING:0);
@@ -1187,7 +1172,7 @@ void *health_main(void *ptr) {
#ifdef ENABLE_ACLK
if (netdata_cloud_enabled)
- sql_queue_alarm_to_aclk(host, ae, 1);
+ sql_queue_alarm_to_aclk(host, ae, true);
#endif
}
}
@@ -1214,7 +1199,7 @@ void *health_main(void *ptr) {
int ret = rrdset2value_api_v1(rc->rrdset, NULL, &rc->value, rrdcalc_dimensions(rc), 1,
rc->after, rc->before, rc->group, NULL,
- 0, rc->options,
+ 0, rc->options | RRDR_OPTION_SELECTED_TIER,
&rc->db_after,&rc->db_before,
NULL, NULL, NULL,
&value_is_null, NULL, 0, 0,
@@ -1425,7 +1410,6 @@ void *health_main(void *ptr) {
rc->rrdset->id,
rc->rrdset->context,
rc->rrdset->name,
- rc->rrdset->family,
rc->classification,
rc->component,
rc->type,
@@ -1438,6 +1422,7 @@ void *health_main(void *ptr) {
status,
rc->source,
rc->units,
+ rc->summary,
rc->info,
rc->delay_last,
(
@@ -1512,7 +1497,6 @@ void *health_main(void *ptr) {
rc->rrdset->id,
rc->rrdset->context,
rc->rrdset->name,
- rc->rrdset->family,
rc->classification,
rc->component,
rc->type,
@@ -1525,6 +1509,7 @@ void *health_main(void *ptr) {
rc->status,
rc->source,
rc->units,
+ rc->summary,
rc->info,
rc->delay_last,
(
@@ -1611,7 +1596,7 @@ void *health_main(void *ptr) {
}
void health_add_host_labels(void) {
- DICTIONARY *labels = localhost->rrdlabels;
+ RRDLABELS *labels = localhost->rrdlabels;
// The source should be CONF, but when it is set, these labels are exported by default ('send configured labels' in exporting.conf).
// Their export seems to break exporting to Graphite, see https://github.com/netdata/netdata/issues/14084.