Both commands not accept the `--daemon' option. When specified, a `flush'
command is send to the daemon just before reading the RRD file, so that
the output will contain the newest data available - even with (very) long
cache timeouts.
TIME SPECIFICATION section for a detailed explanation of how to
specify the end time.
TIME SPECIFICATION section for a detailed explanation of how to
specify the end time.
+=item B<--daemon> I<address>
+
+Address of the L<rrdcached(1)> daemon. If specified, a C<flush> command is sent
+to the server before reading the RRD files. This allows B<rrdtool> to return
+fresh data even if the daemon is configured to cache values for a long time. To
+specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
+addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
+addresses in most cases.
+
+ rrdtool fetch --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd AVERAGE
+
=back
=head2 RESOLUTION INTERVAL
=back
=head2 RESOLUTION INTERVAL
How many digits should rrdtool assume the y-axis labels to be? You
may have to use this option to make enough space once you start
How many digits should rrdtool assume the y-axis labels to be? You
may have to use this option to make enough space once you start
-fideling with the y-axis labeling.
+fiddling with the y-axis labeling.
Only generate the graph if the current graph is out of date or not
existent.
Only generate the graph if the current graph is out of date or not
existent.
+[B<--daemon> I<address>]
+
+Address of the L<rrdcached(1)> daemon. If specified, a C<flush> command is sent
+to the server before reading the RRD files. This allows the graph to contain
+fresh data even if the daemon is configured to cache values for a long time. To
+specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
+addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
+addresses in most cases.
+
+ rrdtool fetch --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd AVERAGE
+
[B<-f>|B<--imginfo> I<printfstr>]
After the image has been created, the graph function uses printf
[B<-f>|B<--imginfo> I<printfstr>]
After the image has been created, the graph function uses printf
const char *_template,
int argc,
const char **argv);
const char *_template,
int argc,
const char **argv);
- int rrd_fetch_r(
- const char *filename,
- const char *cf,
- time_t *start,
- time_t *end,
- unsigned long *step,
- unsigned long *ds_cnt,
- char ***ds_namv,
- rrd_value_t **data);
+ int rrd_fetch_r (
+ const char *filename,
+ const char *cf,
+ time_t *start,
+ time_t *end,
+ unsigned long *step,
+ const char *daemon,
+ unsigned long *ds_cnt,
+ char ***ds_namv,
+ rrd_value_t **data);
int rrd_dump_r(
const char *filename,
char *outname);
int rrd_dump_r(
const char *filename,
char *outname);
*****************************************************************************/
#include "rrd_tool.h"
*****************************************************************************/
#include "rrd_tool.h"
#include "rrd_is_thread_safe.h"
/*#define DEBUG*/
#include "rrd_is_thread_safe.h"
/*#define DEBUG*/
long step_tmp = 1;
time_t start_tmp = 0, end_tmp = 0;
const char *cf;
long step_tmp = 1;
time_t start_tmp = 0, end_tmp = 0;
const char *cf;
rrd_time_value_t start_tv, end_tv;
char *parsetime_error = NULL;
rrd_time_value_t start_tv, end_tv;
char *parsetime_error = NULL;
{"resolution", required_argument, 0, 'r'},
{"start", required_argument, 0, 's'},
{"end", required_argument, 0, 'e'},
{"resolution", required_argument, 0, 'r'},
{"start", required_argument, 0, 's'},
{"end", required_argument, 0, 'e'},
+ {"daemon", required_argument, 0, 'd'},
int option_index = 0;
int opt;
int option_index = 0;
int opt;
- opt = getopt_long(argc, argv, "r:s:e:", long_options, &option_index);
+ opt = getopt_long(argc, argv, "r:s:e:d:", long_options, &option_index);
case 'r':
step_tmp = atol(optarg);
break;
case 'r':
step_tmp = atol(optarg);
break;
+
+ case 'd':
+ if (daemon != NULL)
+ free (daemon);
+ daemon = strdup (optarg);
+ if (daemon == NULL)
+ {
+ rrd_set_error ("strdup failed.");
+ return (-1);
+ }
+ break;
+
case '?':
rrd_set_error("unknown option '-%c'", optopt);
return (-1);
case '?':
rrd_set_error("unknown option '-%c'", optopt);
return (-1);
- if (rrd_fetch_r(argv[optind], cf, start, end, step, ds_cnt, ds_namv, data)
- != 0)
+ if (rrd_fetch_r(argv[optind], cf, start, end, step, daemon, ds_cnt,
+ ds_namv, data) != 0)
return (-1);
return (0);
}
return (-1);
return (0);
}
* will be changed to represent reality */
unsigned long *step, /* which stepsize do you want?
* will be changed to represent reality */
* will be changed to represent reality */
unsigned long *step, /* which stepsize do you want?
* will be changed to represent reality */
unsigned long *ds_cnt, /* number of data sources in file */
char ***ds_namv, /* names of data_sources */
rrd_value_t **data)
{ /* two dimensional array containing the data */
enum cf_en cf_idx;
unsigned long *ds_cnt, /* number of data sources in file */
char ***ds_namv, /* names of data_sources */
rrd_value_t **data)
{ /* two dimensional array containing the data */
enum cf_en cf_idx;
if ((int) (cf_idx = cf_conv(cf)) == -1) {
return -1;
}
if ((int) (cf_idx = cf_conv(cf)) == -1) {
return -1;
}
- return (rrd_fetch_fn
- (filename, cf_idx, start, end, step, ds_cnt, ds_namv, data));
-}
+ if (daemon != NULL)
+ {
+ status = rrdc_connect (daemon);
+ if (status != 0)
+ {
+ rrd_set_error ("rrdc_connect failed with status %i.", status);
+ return (-1);
+ }
+ }
+
+ status = rrd_fetch_fn (filename, cf_idx, start, end, step,
+ (daemon == NULL) ? 0 : 1,
+ ds_cnt, ds_namv, data);
+
+ rrdc_disconnect ();
+
+ return (status);
+} /* int rrd_fetch_r */
int rrd_fetch_fn(
const char *filename, /* name of the rrd */
int rrd_fetch_fn(
const char *filename, /* name of the rrd */
* will be changed to represent reality */
unsigned long *step, /* which stepsize do you want?
* will be changed to represent reality */
* will be changed to represent reality */
unsigned long *step, /* which stepsize do you want?
* will be changed to represent reality */
unsigned long *ds_cnt, /* number of data sources in file */
char ***ds_namv, /* names of data_sources */
rrd_value_t **data)
unsigned long *ds_cnt, /* number of data sources in file */
char ***ds_namv, /* names of data_sources */
rrd_value_t **data)
rrd_value_t *data_ptr;
unsigned long rows;
rrd_value_t *data_ptr;
unsigned long rows;
+ if (use_rrdcached)
+ {
+ int status;
+
+ status = rrdc_flush (filename);
+ if (status != 0)
+ {
+ rrd_set_error ("rrdc_flush failed with status %i.", status);
+ return (-1);
+ }
+ }
+
#ifdef DEBUG
fprintf(stderr, "Entered rrd_fetch_fn() searching for the best match\n");
fprintf(stderr, "Looking for: start %10lu end %10lu step %5lu\n",
#ifdef DEBUG
fprintf(stderr, "Entered rrd_fetch_fn() searching for the best match\n");
fprintf(stderr, "Looking for: start %10lu end %10lu step %5lu\n",
#endif
#include "rrd_graph.h"
#endif
#include "rrd_graph.h"
/* some constant definitions */
/* some constant definitions */
if (im == NULL)
return 0;
if (im == NULL)
return 0;
+
+ if (im->use_rrdcached)
+ {
+ rrdc_disconnect ();
+ im->use_rrdcached = 0;
+ }
+
for (i = 0; i < (unsigned) im->gdes_c; i++) {
if (im->gdes[i].data_first) {
/* careful here, because a single pointer can occur several times */
for (i = 0; i < (unsigned) im->gdes_c; i++) {
if (im->gdes[i].data_first) {
/* careful here, because a single pointer can occur several times */
&im->gdes[i].start,
&im->gdes[i].end,
&ft_step,
&im->gdes[i].start,
&im->gdes[i].end,
&ft_step,
+ im->use_rrdcached ? 1 : 0,
&im->gdes[i].ds_cnt,
&im->gdes[i].ds_namv,
&im->gdes[i].data)) == -1) {
&im->gdes[i].ds_cnt,
&im->gdes[i].ds_namv,
&im->gdes[i].data)) == -1) {
im->grinfo_current = (rrd_info_t *) NULL;
im->imgformat = IF_PNG;
im->imginfo = NULL;
im->grinfo_current = (rrd_info_t *) NULL;
im->imgformat = IF_PNG;
im->imginfo = NULL;
im->lazy = 0;
im->logarithmic = 0;
im->maxval = DNAN;
im->lazy = 0;
im->logarithmic = 0;
im->maxval = DNAN;
{ "watermark", required_argument, 0, 'W'},
{ "alt-y-mrtg", no_argument, 0, 1000}, /* this has no effect it is just here to save old apps from crashing when they use it */
{ "pango-markup", no_argument, 0, 'P'},
{ "watermark", required_argument, 0, 'W'},
{ "alt-y-mrtg", no_argument, 0, 1000}, /* this has no effect it is just here to save old apps from crashing when they use it */
{ "pango-markup", no_argument, 0, 'P'},
+ { "daemon", required_argument, 0, 'd'},
{ 0, 0, 0, 0}
};
/* *INDENT-ON* */
{ 0, 0, 0, 0}
};
/* *INDENT-ON* */
int col_start, col_end;
opt = getopt_long(argc, argv,
int col_start, col_end;
opt = getopt_long(argc, argv,
- "s:e:x:y:v:w:h:D:iu:l:rb:oc:n:m:t:f:a:I:zgjFYAMEX:L:S:T:NR:B:W:kP",
+ "s:e:x:y:v:w:h:D:iu:l:rb:oc:n:m:t:f:a:I:zgjFYAMEX:L:S:T:NR:B:W:kPd:",
long_options, &option_index);
if (opt == EOF)
break;
long_options, &option_index);
if (opt == EOF)
break;
strncpy(im->watermark, optarg, 100);
im->watermark[99] = '\0';
break;
strncpy(im->watermark, optarg, 100);
im->watermark[99] = '\0';
break;
+ case 'd':
+ {
+ int status;
+ if (im->use_rrdcached)
+ {
+ rrd_set_error ("You cannot specify --daemon "
+ "more than once.");
+ return;
+ }
+ status = rrdc_connect (optarg);
+ if (status != 0)
+ {
+ rrd_set_error ("rrdc_connect(%s) failed with status %i.",
+ optarg, status);
+ return;
+ }
+ im->use_rrdcached = 1;
+ break;
+ }
case '?':
if (optopt != 0)
rrd_set_error("unknown option '%c'", optopt);
case '?':
if (optopt != 0)
rrd_set_error("unknown option '%c'", optopt);
char *imginfo; /* construct an <IMG ... tag and return
as first retval */
enum gfx_if_en imgformat; /* image format */
char *imginfo; /* construct an <IMG ... tag and return
as first retval */
enum gfx_if_en imgformat; /* image format */
int lazy; /* only update the image if there is
reasonable probablility that the
existing one is out of date */
int lazy; /* only update the image if there is
reasonable probablility that the
existing one is out of date */
N_("* fetch - fetch data out of an RRD\n\n"
"\trrdtool fetch filename.rrd CF\n"
"\t\t[-r|--resolution resolution]\n"
N_("* fetch - fetch data out of an RRD\n\n"
"\trrdtool fetch filename.rrd CF\n"
"\t\t[-r|--resolution resolution]\n"
- "\t\t[-s|--start start] [-e|--end end]\n\n");
+ "\t\t[-s|--start start] [-e|--end end]\n"
+ "\t\t[--daemon <address>]\n\n");
/* break up very large strings (help_graph, help_tune) for ISO C89 compliance*/
/* break up very large strings (help_graph, help_tune) for ISO C89 compliance*/
"\t\t[-h|--height pixels] [-o|--logarithmic]\n"
"\t\t[-u|--upper-limit value] [-z|--lazy]\n"
"\t\t[-l|--lower-limit value] [-r|--rigid]\n"
"\t\t[-h|--height pixels] [-o|--logarithmic]\n"
"\t\t[-u|--upper-limit value] [-z|--lazy]\n"
"\t\t[-l|--lower-limit value] [-r|--rigid]\n"
- "\t\t[-g|--no-legend]\n"
+ "\t\t[-g|--no-legend] [--daemon <address>]\n"
"\t\t[-F|--force-rules-legend]\n" "\t\t[-j|--only-graph]\n");
const char *help_graph2 =
N_("\t\t[-n|--font FONTTAG:size:font]\n"
"\t\t[-F|--force-rules-legend]\n" "\t\t[-j|--only-graph]\n");
const char *help_graph2 =
N_("\t\t[-n|--font FONTTAG:size:font]\n"
int rrd_create_fn(
const char *file_name,
rrd_t *rrd);
int rrd_create_fn(
const char *file_name,
rrd_t *rrd);
- int rrd_fetch_fn(
- const char *filename,
- enum cf_en cf_idx,
- time_t *start,
- time_t *end,
- unsigned long *step,
- unsigned long *ds_cnt,
- char ***ds_namv,
- rrd_value_t **data);
+ int rrd_fetch_fn (const char *filename,
+ enum cf_en cf_idx,
+ time_t *start,
+ time_t *end,
+ unsigned long *step,
+ int use_rrdcached,
+ unsigned long *ds_cnt,
+ char ***ds_namv,
+ rrd_value_t **data);
#define RRD_READONLY (1<<0)
#define RRD_READWRITE (1<<1)
#define RRD_READONLY (1<<0)
#define RRD_READWRITE (1<<1)