summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 981a488)
raw | patch | inline | side by side (parent: 981a488)
author | Florian Forster <octo@collectd.org> | |
Wed, 3 Sep 2014 07:10:00 +0000 (09:10 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 3 Sep 2014 07:10:00 +0000 (09:10 +0200) |
This is called from the curl and memcachec plugins. Previously, gauge
average, minimum and maximum values were calculated since the start of
the daemon, rather than per-interval. This is not the documented
functionality.
Fixes: #663
average, minimum and maximum values were calculated since the start of
the daemon, rather than per-interval. This is not the documented
functionality.
Fixes: #663
src/curl.c | patch | blob | history | |
src/memcachec.c | patch | blob | history | |
src/utils_match.c | patch | blob | history | |
src/utils_match.h | patch | blob | history |
diff --git a/src/curl.c b/src/curl.c
index e2c4a132514f797b6abb195729719ebe5ddafc8a..0d4677fdc5b06f82062527cc7d859d6b7e100e8f 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
}
cc_submit (wp, wm, mv);
+ match_value_reset (mv);
} /* for (wm = wp->matches; wm != NULL; wm = wm->next) */
return (0);
diff --git a/src/memcachec.c b/src/memcachec.c
index c57a831226d4da64691922a7a43983c5b37eeee1..7c8528d500492751cd035f580000a487f42d3cb6 100644 (file)
--- a/src/memcachec.c
+++ b/src/memcachec.c
}
cmc_submit (wp, wm, mv);
+ match_value_reset (mv);
} /* for (wm = wp->matches; wm != NULL; wm = wm->next) */
sfree (wp->buffer);
diff --git a/src/utils_match.c b/src/utils_match.c
index 062bcfe37fd152851eb11eb03464daabe0b53ae2..bb53a9a317bd79b718e26f7262c49ea2268ccd93 100644 (file)
--- a/src/utils_match.c
+++ b/src/utils_match.c
/**
* collectd - src/utils_match.c
- * Copyright (C) 2008 Florian octo Forster
+ * Copyright (C) 2008-2014 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
return (obj);
} /* cu_match_t *match_create_simple */
+void match_value_reset (cu_match_value_t *mv)
+{
+ if (mv == NULL)
+ return;
+
+ if (mv->ds_type & UTILS_MATCH_DS_TYPE_GAUGE)
+ {
+ mv->value.gauge = NAN;
+ mv->values_num = 0;
+ }
+} /* }}} void match_value_reset */
+
void match_destroy (cu_match_t *obj)
{
if (obj == NULL)
diff --git a/src/utils_match.h b/src/utils_match.h
index 36abe30ca427ee48861a792e0563cd327fa953b1..24517b3ad42ef4d558acda75d76bc971933162e0 100644 (file)
--- a/src/utils_match.h
+++ b/src/utils_match.h
/**
* collectd - src/utils_match.h
- * Copyright (C) 2008 Florian octo Forster
+ * Copyright (C) 2008-2014 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -117,6 +117,17 @@ cu_match_t *match_create_callback (const char *regex, const char *excluderegex,
cu_match_t *match_create_simple (const char *regex,
const char *excluderegex, int ds_type);
+/*
+ * NAME
+ * match_value_reset
+ *
+ * DESCRIPTION
+ * Resets the internal state, if applicable. This function must be called
+ * after each iteration for "simple" matches, usually after dispatching the
+ * metrics.
+ */
+void match_value_reset (cu_match_value_t *mv);
+
/*
* NAME
* match_destroy