index 47d34cb403ad45e72129859a52fd440cc181bd9d..f948f3aa5fef6337a88b9d31128d49d18c5ef50c 100644 (file)
--- a/program/src/rrd_create.c
+++ b/program/src/rrd_create.c
/* initialize some parameters */
rrd.rra_def[rrd.stat_head->rra_cnt].
par[RRA_seasonal_gamma].u_val = 0.1;
+ rrd.rra_def[rrd.stat_head->rra_cnt].
+ par[RRA_seasonal_smoothing_window].u_val = 0.05;
/* fall through */
case CF_DEVPREDICT:
rrd.rra_def[rrd.stat_head->rra_cnt].
par[RRA_dependent_rra_idx].u_cnt =
atoi(token) - 1;
break;
+ case CF_DEVSEASONAL:
+ case CF_SEASONAL:
+ /* optional smoothing window */
+ if (sscanf(token, "smoothing-window=%lf",
+ &(rrd.rra_def[rrd.stat_head->rra_cnt].
+ par[RRA_seasonal_smoothing_window].
+ u_val))) {
+ strcpy(rrd.stat_head->version, RRD_VERSION); /* smoothing-window causes Version 4 */
+ if (rrd.rra_def[rrd.stat_head->rra_cnt].
+ par[RRA_seasonal_smoothing_window].u_val < 0.0
+ || rrd.rra_def[rrd.stat_head->rra_cnt].
+ par[RRA_seasonal_smoothing_window].u_val >
+ 1.0) {
+ rrd_set_error
+ ("Invalid smoothing-window %f: must be between 0 and 1",
+ rrd.rra_def[rrd.stat_head->rra_cnt].
+ par[RRA_seasonal_smoothing_window].
+ u_val);
+ }
+ } else {
+ rrd_set_error("Invalid option %s", token);
+ }
+ break;
case CF_HWPREDICT:
case CF_MHWPREDICT:
/* length of the associated CF_SEASONAL and CF_DEVSEASONAL arrays. */
rrd_t rrd_dn;
if ((rrd_file =
- open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == NULL) {
+ open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
rrd_set_error("creating '%s': %s", file_name, rrd_strerror(errno));
rrd_free(rrd);
return (-1);