From: Florian Forster Date: Wed, 29 Sep 2010 16:02:01 +0000 (+0200) Subject: src/utils_{cache,threshold}.c: Don't replace %{data_source} and %{value} … X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=93ab34867bd3cee089135446f57b438a0a1035c2;p=collectd.git src/utils_{cache,threshold}.c: Don't replace %{data_source} and %{value} … … if the value is missing. --- diff --git a/src/utils_cache.c b/src/utils_cache.c index 0e9bdbef..f00cc9b1 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -216,7 +216,7 @@ static int uc_send_notification (const char *name) sstrncpy (msg, th.missing_message, sizeof (msg)); status = ut_build_message (msg, sizeof (msg), /* format = */ th.missing_message, - &ds, /* ds index = */ 0, + &ds, /* ds index = */ -1, &vl, ce->values_gauge, &n, &th); if (status != 0) diff --git a/src/utils_threshold.c b/src/utils_threshold.c index 6f28da2f..075af020 100644 --- a/src/utils_threshold.c +++ b/src/utils_threshold.c @@ -645,12 +645,18 @@ int ut_build_message(char *out, size_t bufsize, const char *fmt, REPLACE_FIELD ("%{plugin_instance}", n->plugin_instance); REPLACE_FIELD ("%{type}", n->type); REPLACE_FIELD ("%{type_instance}", n->type_instance); - REPLACE_FIELD ("%{data_source}", ds->ds[ds_index].name); - /* This is the offending value, its equivalent to %{ds:value}, if - * value is the data_source name. */ - FTOA(ftoa_temp,values[ds_index]) - REPLACE_FIELD ("%{value}", ftoa_temp); + /* ds_index is set to -1 if the value is missing (there is no data source / + * value we could reasonably use. */ + if (ds_index >= 0) + { + REPLACE_FIELD ("%{data_source}", ds->ds[ds_index].name); + + /* This is the offending value, its equivalent to %{ds:value}, if + * value is the data_source name. */ + FTOA(ftoa_temp,values[ds_index]) + REPLACE_FIELD ("%{value}", ftoa_temp); + } /* Now replace all %{ds: