X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_dump.c;h=aa2488277aa6bbc51b095613dc1d25bc5d70b8e4;hb=6c6bd6077fbc7dd9caa23e73e41b62af346e1fbf;hp=7b972e9dc360689ffe95e872aaaaa10eee713c2d;hpb=6bed7fb478dc5f4004c869630ba0ce8d8abfec98;p=rrdtool.git diff --git a/src/rrd_dump.c b/src/rrd_dump.c index 7b972e9..aa24882 100644 --- a/src/rrd_dump.c +++ b/src/rrd_dump.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.3rc4 Copyright by Tobi Oetiker, 1997-2008 + * RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2008 ***************************************************************************** * rrd_dump Display a RRD ***************************************************************************** @@ -43,13 +43,13 @@ *****************************************************************************/ #include "rrd_tool.h" #include "rrd_rpncalc.h" +#include "rrd_client.h" #if !(defined(NETWARE) || defined(WIN32)) extern char *tzname[2]; #endif - -int rrd_dump_opt_r( +static int rrd_dump_opt_r( const char *filename, char *outname, int opt_noheader) @@ -65,6 +65,7 @@ int rrd_dump_opt_r( rrd_value_t value; struct tm tm; + rrd_init(&rrd); rrd_file = rrd_open(filename, &rrd, RRD_READONLY | RRD_READAHEAD); if (rrd_file == NULL) { rrd_free(&rrd); @@ -441,6 +442,7 @@ int rrd_dump( { int rc; int opt_noheader = 0; + char *opt_daemon = NULL; /* init rrd clean */ @@ -451,16 +453,28 @@ int rrd_dump( int opt; int option_index = 0; static struct option long_options[] = { + {"daemon", required_argument, 0, 'd'}, {"no-header", no_argument, 0, 'n'}, {0, 0, 0, 0} }; - opt = getopt_long(argc, argv, "n", long_options, &option_index); + opt = getopt_long(argc, argv, "d:n", long_options, &option_index); if (opt == EOF) break; switch (opt) { + case 'd': + if (opt_daemon != NULL) + free (opt_daemon); + opt_daemon = strdup (optarg); + if (opt_daemon == NULL) + { + rrd_set_error ("strdup failed."); + return (-1); + } + break; + case 'n': opt_noheader = 1; break; @@ -479,6 +493,10 @@ int rrd_dump( return (-1); } + rc = rrdc_flush_if_daemon(opt_daemon, argv[optind]); + if (opt_daemon) free(opt_daemon); + if (rc) return (rc); + if ((argc - optind) == 2) { rc = rrd_dump_opt_r(argv[optind], argv[optind + 1], opt_noheader); } else {