summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b40ef91)
raw | patch | inline | side by side (parent: b40ef91)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 30 Jul 2009 07:56:31 +0000 (07:56 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 30 Jul 2009 07:56:31 +0000 (07:56 +0000) |
Allow to set the smoothing window (alpha, beta, gamma) to zero.
I'm using rrdtool 1.3.8 with abberant behavior detection from the Brutlag
method. I need to use a week seasonality and no smoothing for the SEASONAL
and DEVSEASONAL. So I use rrdtune in order to set the smoothing window to
0.0. This calls the set_hwarg(). But this method is also used to tune the
alpha, beta and gamma that can't be set to 0.0 So when I tune my smoothing
window size to 0.0, it returns -1 due to the if(window<=0.0) then do
nothing. I join here a small correction with a differnent method used to set
only the smoothing window size and allowing it to be zero.
-- sylvain.luiset gmail.com
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1875 a5681a0c-68f1-0310-ab6d-d61299d08faa
I'm using rrdtool 1.3.8 with abberant behavior detection from the Brutlag
method. I need to use a week seasonality and no smoothing for the SEASONAL
and DEVSEASONAL. So I use rrdtune in order to set the smoothing window to
0.0. This calls the set_hwarg(). But this method is also used to tune the
alpha, beta and gamma that can't be set to 0.0 So when I tune my smoothing
window size to 0.0, it returns -1 due to the if(window<=0.0) then do
nothing. I join here a small correction with a differnent method used to set
only the smoothing window size and allowing it to be zero.
-- sylvain.luiset gmail.com
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1875 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/src/rrd_tune.c | patch | blob | history |
diff --git a/program/src/rrd_tune.c b/program/src/rrd_tune.c
index 0df0476b5c7756dcc3a21de632fd8b0a95058fe7..fe2e4796cd5c0459ee1a15a7bb2bf6abf2bbfe9e 100644 (file)
--- a/program/src/rrd_tune.c
+++ b/program/src/rrd_tune.c
break;
case 's':
strcpy(rrd.stat_head->version, RRD_VERSION); /* smoothing_window causes Version 4 */
- if (set_hwarg
+ if (set_hwsmootharg
(&rrd, CF_SEASONAL, RRA_seasonal_smoothing_window, optarg)) {
rrd_free(&rrd);
return -1;
break;
case 'S':
strcpy(rrd.stat_head->version, RRD_VERSION); /* smoothing_window causes Version 4 */
- if (set_hwarg
+ if (set_hwsmootharg
(&rrd, CF_DEVSEASONAL, RRA_seasonal_smoothing_window,
optarg)) {
rrd_free(&rrd);
return 0;
}
+int set_hwsmootharg(
+ rrd_t *rrd,
+ enum cf_en cf,
+ enum rra_par_en rra_par,
+ char *arg)
+{
+ double param;
+ unsigned long i;
+ signed short rra_idx = -1;
+
+ /* read the value */
+ param = atof(arg);
+ /* in order to avoid smoothing of SEASONAL or DEVSEASONAL, we need to
+ * the 0.0 value*/
+ if (param < 0.0 || param > 1.0) {
+ rrd_set_error("Holt-Winters parameter must be between 0 and 1");
+ return -1;
+ }
+ /* does the appropriate RRA exist? */
+ for (i = 0; i < rrd->stat_head->rra_cnt; ++i) {
+ if (cf_conv(rrd->rra_def[i].cf_nam) == cf) {
+ rra_idx = i;
+ break;
+ }
+ }
+ if (rra_idx == -1) {
+ rrd_set_error("Holt-Winters RRA does not exist in this RRD");
+ return -1;
+ }
+
+ /* set the value */
+ rrd->rra_def[rra_idx].par[rra_par].u_val = param;
+ return 0;
+}
+
int set_deltaarg(
rrd_t *rrd,
enum rra_par_en rra_par,