projects
/
rrdtool.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
usr rrd_free for freeing the rrd structs ... vito caputo
[rrdtool.git]
/
src
/
rrd_create.c
diff --git
a/src/rrd_create.c
b/src/rrd_create.c
index
d36cf3c
..
a5c304f
100644
(file)
--- a/
src/rrd_create.c
+++ b/
src/rrd_create.c
@@
-25,6
+25,13
@@
int rrd_create(
int argc,
char **argv)
{
int argc,
char **argv)
{
+ struct option long_options[] = {
+ {"start", required_argument, 0, 'b'},
+ {"step", required_argument, 0, 's'},
+ {0, 0, 0, 0}
+ };
+ int option_index = 0;
+ int opt;
time_t last_up = time(NULL) - 10;
unsigned long pdp_step = 300;
struct rrd_time_value last_up_tv;
time_t last_up = time(NULL) - 10;
unsigned long pdp_step = 300;
struct rrd_time_value last_up_tv;
@@
-36,14
+43,6
@@
int rrd_create(
opterr = 0; /* initialize getopt */
while (1) {
opterr = 0; /* initialize getopt */
while (1) {
- static struct option long_options[] = {
- {"start", required_argument, 0, 'b'},
- {"step", required_argument, 0, 's'},
- {0, 0, 0, 0}
- };
- int option_index = 0;
- int opt;
-
opt = getopt_long(argc, argv, "b:s:", long_options, &option_index);
if (opt == EOF)
opt = getopt_long(argc, argv, "b:s:", long_options, &option_index);
if (opt == EOF)
@@
-89,7
+88,7
@@
int rrd_create(
}
}
if (optind == argc) {
}
}
if (optind == argc) {
- rrd_set_error("
what is the name of the rrd file you want to create?
");
+ rrd_set_error("
need name of an rrd file to create
");
return -1;
}
rc = rrd_create_r(argv[optind],
return -1;
}
rc = rrd_create_r(argv[optind],
@@
-247,6
+246,7
@@
int rrd_create_r(
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
+ case CF_MHWPREDICT:
/* initialize some parameters */
rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_alpha].
u_val = 0.1;
/* initialize some parameters */
rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_alpha].
u_val = 0.1;
@@
-293,6
+293,7
@@
int rrd_create_r(
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
+ case CF_MHWPREDICT:
case CF_DEVSEASONAL:
case CF_SEASONAL:
case CF_DEVPREDICT:
case CF_DEVSEASONAL:
case CF_SEASONAL:
case CF_DEVPREDICT:
@@
-316,6
+317,7
@@
int rrd_create_r(
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
+ case CF_MHWPREDICT:
rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_alpha].
u_val = atof(token);
if (atof(token) <= 0.0 || atof(token) >= 1.0)
rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_alpha].
u_val = atof(token);
if (atof(token) <= 0.0 || atof(token) >= 1.0)
@@
-361,6
+363,7
@@
int rrd_create_r(
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
switch (cf_conv
(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
case CF_HWPREDICT:
+ case CF_MHWPREDICT:
rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_beta].
u_val = atof(token);
if (atof(token) < 0.0 || atof(token) > 1.0)
rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_beta].
u_val = atof(token);
if (atof(token) < 0.0 || atof(token) > 1.0)
@@
-415,6
+418,7
@@
int rrd_create_r(
atoi(token) - 1;
break;
case CF_HWPREDICT:
atoi(token) - 1;
break;
case CF_HWPREDICT:
+ case CF_MHWPREDICT:
/* length of the associated CF_SEASONAL and CF_DEVSEASONAL arrays. */
period = atoi(token);
if (period >
/* length of the associated CF_SEASONAL and CF_DEVSEASONAL arrays. */
period = atoi(token);
if (period >
@@
-463,8
+467,10
@@
int rrd_create_r(
par[RRA_dependent_rra_idx].u_cnt, rrd.stat_head->rra_cnt);
#endif
/* should we create CF_SEASONAL, CF_DEVSEASONAL, and CF_DEVPREDICT? */
par[RRA_dependent_rra_idx].u_cnt, rrd.stat_head->rra_cnt);
#endif
/* should we create CF_SEASONAL, CF_DEVSEASONAL, and CF_DEVPREDICT? */
- if (cf_conv(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam) ==
- CF_HWPREDICT
+ if ((cf_conv(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam) ==
+ CF_HWPREDICT
+ || cf_conv(rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam) ==
+ CF_MHWPREDICT)
&& rrd.rra_def[rrd.stat_head->rra_cnt].
par[RRA_dependent_rra_idx].u_cnt == rrd.stat_head->rra_cnt) {
#ifdef DEBUG
&& rrd.rra_def[rrd.stat_head->rra_cnt].
par[RRA_dependent_rra_idx].u_cnt == rrd.stat_head->rra_cnt) {
#ifdef DEBUG
@@
-626,12
+632,7
@@
int rrd_create_fn(
if ((rrd_file = fopen(file_name, "wb")) == NULL) {
rrd_set_error("creating '%s': %s", file_name, rrd_strerror(errno));
if ((rrd_file = fopen(file_name, "wb")) == NULL) {
rrd_set_error("creating '%s': %s", file_name, rrd_strerror(errno));
- free(rrd->stat_head);
- rrd->stat_head = NULL;
- free(rrd->ds_def);
- rrd->ds_def = NULL;
- free(rrd->rra_def);
- rrd->rra_def = NULL;
+ rrd_free(rrd);
return (-1);
}
return (-1);
}
@@
-671,6
+672,7
@@
int rrd_create_fn(
for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
switch (cf_conv(rrd->rra_def[i].cf_nam)) {
case CF_HWPREDICT:
for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
switch (cf_conv(rrd->rra_def[i].cf_nam)) {
case CF_HWPREDICT:
+ case CF_MHWPREDICT:
init_hwpredict_cdp(rrd->cdp_prep);
break;
case CF_SEASONAL:
init_hwpredict_cdp(rrd->cdp_prep);
break;
case CF_SEASONAL: