summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2d897a7)
raw | patch | inline | side by side (parent: 2d897a7)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 28 Feb 2007 10:43:37 +0000 (11:43 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 28 Feb 2007 10:43:37 +0000 (11:43 +0100) |
The documentation has been updated, too.
src/collectd.conf.pod | patch | blob | history | |
src/rrdtool.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 3d387079b4134c5e115636b6b6fa6e0edf04e9b2..3c34905f726195e313ce5a471a3100fc36f85087 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=head2 Plugin C<rrdtool>
+You can use the settings B<StepSize>, B<HeartBeat>, B<RRARows>, and B<XFF> to
+finetune your RRD-files. Please read L<rrdcreate(1)> if you encounter problems
+using these settings. If you don't want to dive into the depths of RRDTool, you
+can savely ignore these settings.
+
=over 4
+=item B<DataDir> I<Directory>
+
+Set the directory to store RRD-files under. Per default RRD-files are generated
+beneath the daemon's working directory, i.E<nbsp>e. the B<BaseDir>.
+
+=item B<StepSize> I<Seconds>
+
+Sets the stepsize of newly created RRD-files. Ideally (and per default) this
+setting is identical to the global B<Interval>-option and should not be
+smaller. If unsure, don't set this option.
+
+=item B<HeartBeat> I<Seconds>
+
+Sets the heartbeat of newly created RRD-files. Ideally (and per default) this
+setting is bigger than the B<Interval>-setting. If unsure, don't set this
+option.
+
+=item B<RRARows> I<NumRows>
+
+The C<rrdtool plugin> calculates the number of PDPs per CDP based on the
+B<StepSize>, this setting and a timespan. This plugin creates RRD-files with
+three times five RRAs, i. e. five RRAs with the CFs B<MIN>, B<AVERAGE>, and
+B<MAX>. The five RRAs are optimized for graphs covering one hour, one day, one
+week, one month, and one year.
+
+So for each timespan, it calculates how many PDPs need to be consolidated into
+one CDP by calculating:
+ number of PDPs = timespan / (stepsize * rrarows)
+
+Bottom line is, set this no smaller than the width of you graphs in pixels.
+
+=item B<XFF> I<Factor>
+
+Set the "XFiles Factor". This is mostly interesting if you set B<StepSize>
+bigger than B<Interval>. If unsure, don't set this option.
+
=item B<CacheFlush> I<Seconds>
When the C<rrdtool plugin> uses a cache (by setting B<CacheTimeout>, see below)
@@ -360,11 +401,6 @@ reduces IO-operations and thus lessens the load produced by updating the files.
The tradeoff is that the graphs kind of "drag behind" and that more memory is
used.
-=item B<DataDir> I<Directory>
-
-Set the directory to store RRD-files under. Per default RRD-files are generated
-beneath the daemon's working directory, i.E<nbsp>e. the B<BaseDir>.
-
=back
=head2 Plugin C<sensors>
diff --git a/src/rrdtool.c b/src/rrdtool.c
index 8154df9d8d53d5d6d4c2620b68f72d431781dd1e..80fc7671c32939d19ace90e93e3ab15538b3992d 100644 (file)
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
86400,
604800,
2678400,
- 31622400,
- 0
+ 31622400
};
-static int rra_timespans_num = 5;
+static int rra_timespans_num = STATIC_ARRAY_SIZE (rra_timespans);
static char *rra_types[] =
{
"AVERAGE",
"MIN",
- "MAX",
- NULL
+ "MAX"
};
-static int rra_types_num = 3;
+static int rra_types_num = STATIC_ARRAY_SIZE (rra_types);
static const char *config_keys[] =
{
"CacheTimeout",
"CacheFlush",
"DataDir",
- NULL
+ "StepSize",
+ "HeartBeat",
+ "RRARows",
+ "XFF"
};
-static int config_keys_num = 3;
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
-static char *datadir = NULL;
+static char *datadir = NULL;
+static int stepsize = 0;
+static int heartbeat = 0;
+static int rrarows = 1200;
+static double xff = 0.1;
static int cache_timeout = 0;
static int cache_flush_timeout = 0;
int rra_max = rra_timespans_num * rra_types_num;
- int step;
- int rows;
int span;
int cdp_num;
return (-1);
memset (rra_def, '\0', (rra_max + 1) * sizeof (char *));
- step = interval_g;
- /* FIXME: Use config here */
- rows = atoi (COLLECTD_ROWS);
-
- if ((step <= 0) || (rows <= 0))
+ if ((stepsize <= 0) || (rrarows <= 0))
{
*ret = NULL;
return (-1);
{
span = rra_timespans[i];
- if ((span / step) < rows)
+ if ((span / stepsize) < rrarows)
continue;
if (cdp_len == 0)
cdp_len = 1;
else
- cdp_len = (int) floor (((double) span) / ((double) (rows * step)));
+ cdp_len = (int) floor (((double) span)
+ / ((double) (rrarows * stepsize)));
- cdp_num = (int) ceil (((double) span) / ((double) (cdp_len * step)));
+ cdp_num = (int) ceil (((double) span)
+ / ((double) (cdp_len * stepsize)));
for (j = 0; j < rra_types_num; j++)
{
if (rra_num >= rra_max)
break;
- if (snprintf (buffer, sizeof(buffer), "RRA:%s:%3.1f:%u:%u",
- rra_types[j], COLLECTD_XFF,
+ if (snprintf (buffer, sizeof (buffer), "RRA:%s:%3.1f:%u:%u",
+ rra_types[j], xff,
cdp_len, cdp_num) >= sizeof (buffer))
{
syslog (LOG_ERR, "rra_get: Buffer would have been truncated.");
}
status = snprintf (buffer, sizeof (buffer),
- "DS:%s:%s:%s:%s:%s",
- d->name, type, COLLECTD_HEARTBEAT,
+ "DS:%s:%s:%i:%s:%s",
+ d->name, type, heartbeat,
min, max);
if ((status < 1) || (status >= sizeof (buffer)))
break;
char **ds_def;
int ds_num;
int i, j;
- char step[16];
+ char stepsize_str[16];
int status = 0;
if (check_create_dir (filename))
return (-1);
}
- status = snprintf (step, sizeof (step), "%i", interval_g);
- if ((status < 1) || (status >= sizeof (step)))
+ status = snprintf (stepsize_str, sizeof (stepsize_str),
+ "%i", stepsize);
+ if ((status < 1) || (status >= sizeof (stepsize_str)))
{
syslog (LOG_ERR, "rrdtool plugin: snprintf failed.");
return (-1);
argv[0] = "create";
argv[1] = filename;
argv[2] = "-s";
- argv[3] = step;
+ argv[3] = stepsize_str;
j = 4;
for (i = 0; i < ds_num; i++)
return (0);
} /* int rrd_write */
-static int rrd_config (const char *key, const char *val)
+static int rrd_config (const char *key, const char *value)
{
if (strcasecmp ("CacheTimeout", key) == 0)
{
- int tmp = atoi (val);
+ int tmp = atoi (value);
if (tmp < 0)
{
fprintf (stderr, "rrdtool: `CacheTimeout' must "
}
else if (strcasecmp ("CacheFlush", key) == 0)
{
- int tmp = atoi (val);
+ int tmp = atoi (value);
if (tmp < 0)
{
fprintf (stderr, "rrdtool: `CacheFlush' must "
{
if (datadir != NULL)
free (datadir);
- datadir = strdup (val);
+ datadir = strdup (value);
if (datadir != NULL)
{
int len = strlen (datadir);
}
}
}
+ else if (strcasecmp ("StepSize", key) == 0)
+ {
+ int tmp = atoi (value);
+ if (tmp <= 0)
+ {
+ fprintf (stderr, "rrdtool: `StepSize' must "
+ "be greater than 0.\n");
+ return (1);
+ }
+ stepsize = tmp;
+ }
+ else if (strcasecmp ("HeartBeat", key) == 0)
+ {
+ int tmp = atoi (value);
+ if (tmp <= 0)
+ {
+ fprintf (stderr, "rrdtool: `HeartBeat' must "
+ "be greater than 0.\n");
+ return (1);
+ }
+ heartbeat = tmp;
+ }
+ else if (strcasecmp ("RRARows", key) == 0)
+ {
+ int tmp = atoi (value);
+ if (tmp <= 0)
+ {
+ fprintf (stderr, "rrdtool: `RRARows' must "
+ "be greater than 0.\n");
+ return (1);
+ }
+ rrarows = tmp;
+ }
+ else if (strcasecmp ("XFF", key) == 0)
+ {
+ double tmp = atof (value);
+ if ((tmp < 0.0) || (tmp >= 1.0))
+ {
+ fprintf (stderr, "rrdtool: `XFF' must "
+ "be in the range 0 to 1 (exclusive).");
+ return (1);
+ }
+ xff = tmp;
+ }
else
{
return (-1);
static int rrd_init (void)
{
+ if (stepsize <= 0)
+ stepsize = interval_g;
+ if (heartbeat <= 0)
+ heartbeat = 2 * interval_g;
+
+ if (heartbeat < interval_g)
+ syslog (LOG_WARNING, "rrdtool plugin: Your `heartbeat' is "
+ "smaller than your `interval'. This will "
+ "likely cause problems.");
+ else if (stepsize < interval_g)
+ syslog (LOG_WARNING, "rrdtool plugin: Your `stepsize' is "
+ "smaller than your `interval'. This will "
+ "create needlessly big RRD-files.");
+
if (cache_timeout < 2)
{
cache_timeout = 0;
cache_flush_last = time (NULL);
plugin_register_shutdown ("rrdtool", rrd_shutdown);
}
+
+ DBG ("datadir = %s; stepsize = %i; heartbeat = %i; rrarows = %i; xff = %lf;",
+ (datadir == NULL) ? "(null)" : datadir,
+ stepsize, heartbeat, rrarows, xff);
+
return (0);
} /* int rrd_init */