X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_hw.c;h=1eba57e88fa9ec71ec7f36123033e2e1353998cf;hb=26d23e7abaeb6dc428374626debf6b271ad7e0d7;hp=24cfb1709a6869a72913537228cf447759570fc2;hpb=51fcea2cbf9721f012f2f0d43c604a3aaf684ee8;p=rrdtool.git diff --git a/src/rrd_hw.c b/src/rrd_hw.c index 24cfb17..1eba57e 100644 --- a/src/rrd_hw.c +++ b/src/rrd_hw.c @@ -1,11 +1,13 @@ /***************************************************************************** - * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007 + * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 ***************************************************************************** * rrd_hw.c : Support for Holt-Winters Smoothing/ Aberrant Behavior Detection ***************************************************************************** * Initial version by Jake Brutlag, WebTV Networks, 5/1/00 *****************************************************************************/ +#include + #include "rrd_tool.h" #include "rrd_hw.h" #include "rrd_hw_math.h" @@ -139,7 +141,14 @@ int apply_smoother( rrd_value_t *working_average; rrd_value_t *baseline; - offset = floor(0.025 * row_count); + if (atoi(rrd->stat_head->version) >= 4) { + offset = floor(rrd->rra_def[rra_idx]. + par[RRA_seasonal_smoothing_window]. + u_val / 2 * row_count); + } else { + offset = floor(0.05 / 2 * row_count); + } + if (offset == 0) return 0; /* no smoothing */ @@ -157,7 +166,7 @@ int apply_smoother( free(rrd_values); return -1; } - rrd_flush(rrd_file); + /* could read all data in a single block, but we need to * check for NA values */ for (i = 0; i < row_count; ++i) { @@ -261,7 +270,6 @@ int apply_smoother( baseline[j]; } /* flush cdp to disk */ - rrd_flush(rrd_file); if (rrd_seek(rrd_file, sizeof(stat_head_t) + rrd->stat_head->ds_cnt * sizeof(ds_def_t) + rrd->stat_head->rra_cnt * sizeof(rra_def_t) + @@ -284,7 +292,6 @@ int apply_smoother( /* endif CF_SEASONAL */ /* flush updated values to disk */ - rrd_flush(rrd_file); if (rrd_seek(rrd_file, rra_start, SEEK_SET)) { rrd_set_error("apply_smoother: seek to pos %d failed", rra_start); free(rrd_values); @@ -299,7 +306,6 @@ int apply_smoother( return -1; } - rrd_flush(rrd_file); free(rrd_values); free(baseline); return 0; @@ -415,7 +421,7 @@ int update_aberrant_CF( hw_multiplicative_init_seasonality, hw_calculate_seasonal_deviation, hw_init_seasonal_deviation, - 1.0 // identity value + 1.0 /* identity value */ }; static hw_functions_t hw_additive_functions = { @@ -426,7 +432,7 @@ int update_aberrant_CF( hw_additive_init_seasonality, hw_calculate_seasonal_deviation, hw_init_seasonal_deviation, - 0.0 // identity value + 0.0 /* identity value */ }; rrd->cdp_prep[cdp_idx].scratch[CDP_scratch_idx].u_val = pdp_val;