From 93ab34867bd3cee089135446f57b438a0a1035c2 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 29 Sep 2010 18:02:01 +0200 Subject: [PATCH] =?utf8?q?src/utils=5F{cache,threshold}.c:=20Don't=20repla?= =?utf8?q?ce=20%{data=5Fsource}=20and=20%{value}=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … if the value is missing. --- src/utils_cache.c | 2 +- src/utils_threshold.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) 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: