+int set_hwarg(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);
+ 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,char *arg)
+{
+ rrd_value_t param;
+ unsigned long i;
+ signed short rra_idx = -1;
+
+ param = atof(arg);
+ if (param < 0.1)
+ {
+ rrd_set_error("Parameter specified is too small");
+ 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_FAILURES)
+ {
+ rra_idx = i;
+ break;
+ }
+ }
+ if (rra_idx == -1)
+ {
+ rrd_set_error("Failures 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_windowarg(rrd_t *rrd,enum rra_par_en rra_par,char *arg)
+{
+ unsigned long param;
+ unsigned long i, cdp_idx;
+ signed short rra_idx = -1;
+ /* read the value */
+ param = atoi(arg);
+ if (param < 1 || param > MAX_FAILURES_WINDOW_LEN)
+ {
+ rrd_set_error("Parameter must be between %d and %d",
+ 1, MAX_FAILURES_WINDOW_LEN);
+ 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_FAILURES)
+ {
+ rra_idx = i;
+ break;
+ }
+ }
+ if (rra_idx == -1)
+ {
+ rrd_set_error("Failures RRA does not exist in this RRD");
+ return -1;
+ }
+
+ /* set the value */
+ rrd -> rra_def[rra_idx].par[rra_par].u_cnt = param;
+
+ /* erase existing violations */
+ for (i = 0; i < rrd -> stat_head -> ds_cnt; i++)
+ {
+ cdp_idx = rra_idx * (rrd -> stat_head -> ds_cnt) + i;
+ erase_violations(rrd,cdp_idx,rra_idx);
+ }
+ return 0;
+}