X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftarget_notification.c;h=f83a904ac07f6f73d9d7530e2d01e3dfa3c07178;hb=8fd8f76dc11064e75e44448d16d35e09e46191a2;hp=ffd76dc552e406a9b91f22e73bd0599e7e4e7798;hpb=be126043c2be20399d7670fe194645292018bde0;p=collectd.git diff --git a/src/target_notification.c b/src/target_notification.c index ffd76dc5..f83a904a 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -221,7 +221,9 @@ static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */ char template[DATA_MAX_NAME_LEN]; char value_str[DATA_MAX_NAME_LEN]; - snprintf(template, sizeof(template), "%%{ds:%s}", ds->ds[i].name); + const char *format = "%%{ds:%.*s}"; + snprintf(template, sizeof(template), format, + DATA_MAX_NAME_LEN - strlen(format), ds->ds[i].name); if (ds->ds[i].type != DS_TYPE_GAUGE) { if ((rates == NULL) && (rates_failed == 0)) { @@ -234,7 +236,7 @@ static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */ /* If this is a gauge value, use the current value. */ if (ds->ds[i].type == DS_TYPE_GAUGE) snprintf(value_str, sizeof(value_str), GAUGE_FORMAT, - (double)vl->values[i].gauge); + (double)vl->values[i].gauge); /* If it's a counter, try to use the current rate. This may fail, if the * value has been renamed. */ else if (rates != NULL)