From: oetiker Date: Tue, 28 Oct 2008 08:57:13 +0000 (+0000) Subject: - remove the spaccing between the elements X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=907f9b68f3714bc0432d2ace43a2c93d81b4bffc;p=rrdtool.git - remove the spaccing between the elements - add xsd support to dump output - change the argument "[--no-header|-n]" to [--header|-h {xsd,dtd}] -- tobias.lindenmann 1und1.de git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1637 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/NEWS b/NEWS index 5497a67..8741b7b 100644 --- a/NEWS +++ b/NEWS @@ -1,164 +1,15 @@ RRDTOOL NEWS ============ -##################################### -Major Changes between 1.2.x and 1.3.x -------------------------------------- +########################################## +Functional Changes between 1.3.x and 1.4.x +------------------------------------------ -NEW Fast file access methods (Bernhard Fischer / Tobi Oetiker) ----------------------------- -* introduced file-accessor functions rrd_read/rrd_seek/rrd_write +RRDcached Accelerator +--------------------- +tbd -* implemented full mmap-based file access with madvise hints for - improved scalability, much reduced memory-footprint and much less - blocking while accessing the disk - -* implemented optional full file-descriptor access instead of FILE* - access - -NEW Graphing (Tobi Oetiker) ------------- -* libart has been replaced by cairo/pango - -* pango markup is supported (--pango-markup) - -* full grid fitting - -* --graph-render-mode=mono for non anti aliased graphing - -* --font-render-mode=mono for non anti aliased fonts - -* fonts come through fontconfig, use the Pango font nameing scheme - -> 'Times 20' ... it is not possible to use truetype fonts - directly anymore. - -* Tabs are position independent. - -* TRENDNAN filter that ignores NAN values while calculating the - TREND data. (Timo Stripf) - -* --full-size-mode to specify the outer border of the image and not - just of the graphing canvas (Matthew Chambers) - -* TEXTALIGN command to alter default text alignment behavior - -* C API in-memory graphing with rrd_graph_v (Evan Miller) - -* draw dashed lines in graphs (Thomas Gutzler) - -* new interface graphv which returns information using the rrd_info - interface (Tobi Oetiker and Mark Plaksin) - -* improved horizontal grid. Have a bit more grid lines and y-axis - labels while keeping them far enough apart to not run into each - other. - -NEW Forecasting (Evan Miller) ---------------- -* the new MHWPREDICT consolidation function uses a variation of the - Holt-Winters method. It is a drop-in replacement for HWPREDICT, - and is better suited for data whose seasonal variations grow or - shrink in proportion to the average. - -* If you create an RRD with the new MHWPREDICT function, the - resulting rrd file will be version 0004 and can only be used in - rrdtool 1.3. - -Rewrites --------- -* rrd_restore now uses libxml for parsing which makes things much - more tolerant towards xml variations. The old code could mostly - just parse the XML as it was output by rrdtool dump. See also: - the note at the bottom of this document. (by Florian octo - Forster) - -* rrd_update rewritten to make it more modular. Fixed two - longstanding HW bugs in the process (Evan Miller) - -Internationalization (Takao Fujiwara and Tobi Oetiker) --------------------- -* The help output by rrdtool has been internationalized. There are - no real translations included with rrdtool yet, contributions are - welcome. - -* The internationalization will only be compiled if libintl and - friends are available on your system. Use the configure option - --disable-libintl if you want to disable this feature - -Language Bindings ------------------ -* ruby rrd_fetch will return step as a last property -- Mike Perham - -RRDtool dump / restore incompatibility --------------------------------------- -* rrdtool dump 1.3 does emit completely legal XML. Basically this - means that it contains an XML header and a DOCTYPE definition. - Unfortunately this causes older versions of rrdtool restore to be - unhappy. - -* To restore a new dump with an old rrdtool restore version, either - remove the XML header and the doctype by hand (both on the first - line of the dump) or use rrdtool dump --no-header. - - -###################################################################################### -Major Changes between 1.0.x and 1.2.x -====================================================================================== -Graphing --------- - -* rewritten graphics generation based on libart. - - anti-aliased output - - alpha transparency support - - truetype fonts - -* additional graphics formats: EPS, PDF, SVG - -* extended multi-part documentation - -* VDEF support; define and use variables. Find, and use, the - maximum rate seen by rrdtool; compute and show the average - -* Sliding window (trend) analysis - Compute a smoother average, for instance over the last 6 CDPs - -* percentile (95th or other) - Remove peaks, 95 percent of all rates are at or below the - returned value - -Logging +RRDdump ------- -* a second logging interface: rrdtool updatev - Verbose updating of the database; show CPDs being created - -* Aberrant Behavior Detection with Holt-Winters Forecasting - Compare current data with expected data, detect and log when - the rates are outside expected levels - -* COMPUTE data type for artificial data-sources calculating their - input using RPN math and data from the other data-sources. - -Incompatibilities ------------------ -* Colons in COMMENT arguments to rrdtool graph must be escaped with a backslash - -* the --alt-y-mrtg option is gone or rather since 1.2.7 it is back but - without functionality. - -* In pipe mode, rrdtool answers with OK only if it was successful with the - command. Otherwhise the answer will be ERROR... - - -Behind the Scenes ------------------ -* In order to support Holt-Winters and Calculated Datasources, - the rrdtool data format has changed. While the new version of rrdtool can - read files created with rrdtool 1.0.x. It is not possible to read files - created by rrdtool-1.2.x with rrdtool-1.0.x - -* External libraries are not included with rrdtool anymore. This is in line - with todays trend of using shared libraries everywhere. With the exception - of the cgi library most things required by rrdtool will be found on every recent - system. - -* Memory Mapped IO support for faster logging. +* no more spaces in output +* --no-header replaced with --header {xsd,dtd} diff --git a/doc/rrddump.pod b/doc/rrddump.pod index c26d31b..52c68b6 100644 --- a/doc/rrddump.pod +++ b/doc/rrddump.pod @@ -5,14 +5,14 @@ rrddump - dump the contents of an RRD to XML format =head1 SYNOPSIS B B I -S<[B<--no-header>|B<-n>]> +S<[B<--header>|B<-h> {xsd,dtd}]> S<[B<--daemon> I
]> S I> or B B I I -S<[B<--no-header>|B<-n>]> +S<[B<--header>|B<-h> {xsd,dtd}]> S<[B<--daemon> I
]> =head1 DESCRIPTION @@ -36,12 +36,9 @@ The name of the B you want to dump. The (optional) filename that you want to write the XML output to. If not specified, the XML will be printed to stdout. -=item B<--no-header>|B<-n> +=item B<--header>|B<-h> {xsd,dtd} -In rrdtool 1.3, the dump function started producing correct xml-headers. -Unfortunately the rrdtool restore function from the 1.2 series can not -handle these headers. With this option you can supress the creatinon of -the xml headers. +Optionally rrdtool can add a xsd or dtd header to the dump output. =item B<--daemon> I
diff --git a/doc/rrdtool-dump.xsd b/doc/rrdtool-dump.xsd new file mode 100644 index 0000000..22cd7ca --- /dev/null +++ b/doc/rrdtool-dump.xsd @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rrd_dump.c b/src/rrd_dump.c index aa24882..9da8fd7 100644 --- a/src/rrd_dump.c +++ b/src/rrd_dump.c @@ -52,7 +52,7 @@ extern char *tzname[2]; static int rrd_dump_opt_r( const char *filename, char *outname, - int opt_noheader) + int opt_header) { unsigned int i, ii, ix, iii = 0; time_t now; @@ -81,20 +81,29 @@ static int rrd_dump_opt_r( out_file = stdout; } - if (!opt_noheader) { + if (opt_header == 1) { fputs("\n", out_file); fputs ("\n", out_file); + fputs("\n", out_file); + fputs("\n", out_file); + } else if (opt_header == 2) { + fputs("\n", out_file); + fputs("\n", out_file); + fputs("\n", out_file); + } else { + fputs("\n", out_file); + fputs("\n", out_file); } - fputs("", out_file); - fputs("", out_file); + if (atoi(rrd.stat_head->version) <= 3) { - fprintf(out_file, "\t %s \n", RRD_VERSION3); + fprintf(out_file, "\t%s\n", RRD_VERSION3); } else { - fprintf(out_file, "\t %s \n", RRD_VERSION); + fprintf(out_file, "\t%s\n", RRD_VERSION); } - fprintf(out_file, "\t %lu \n", + fprintf(out_file, "\t%lu \n", rrd.stat_head->pdp_step); #if HAVE_STRFTIME localtime_r(&rrd.live_head->last_up, &tm); @@ -102,26 +111,26 @@ static int rrd_dump_opt_r( #else # error "Need strftime" #endif - fprintf(out_file, "\t %lu \n\n", + fprintf(out_file, "\t%lu \n\n", (unsigned long) rrd.live_head->last_up, somestring); for (i = 0; i < rrd.stat_head->ds_cnt; i++) { fprintf(out_file, "\t\n"); - fprintf(out_file, "\t\t %s \n", rrd.ds_def[i].ds_nam); - fprintf(out_file, "\t\t %s \n", rrd.ds_def[i].dst); + fprintf(out_file, "\t\t%s\n", rrd.ds_def[i].ds_nam); + fprintf(out_file, "\t\t%s\n", rrd.ds_def[i].dst); if (dst_conv(rrd.ds_def[i].dst) != DST_CDEF) { fprintf(out_file, - "\t\t %lu \n", + "\t\t%lu\n", rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); if (isnan(rrd.ds_def[i].par[DS_min_val].u_val)) { - fprintf(out_file, "\t\t NaN \n"); + fprintf(out_file, "\t\tNaN\n"); } else { - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.ds_def[i].par[DS_min_val].u_val); } if (isnan(rrd.ds_def[i].par[DS_max_val].u_val)) { - fprintf(out_file, "\t\t NaN \n"); + fprintf(out_file, "\t\tNaN\n"); } else { - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.ds_def[i].par[DS_max_val].u_val); } } else { /* DST_CDEF */ @@ -129,25 +138,25 @@ static int rrd_dump_opt_r( rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]), rrd.ds_def, &str); - fprintf(out_file, "\t\t %s \n", str); + fprintf(out_file, "\t\t%s\n", str); free(str); } fprintf(out_file, "\n\t\t\n"); - fprintf(out_file, "\t\t %s \n", + fprintf(out_file, "\t\t%s\n", rrd.pdp_prep[i].last_ds); if (isnan(rrd.pdp_prep[i].scratch[PDP_val].u_val)) { - fprintf(out_file, "\t\t NaN \n"); + fprintf(out_file, "\t\tNaN\n"); } else { - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.pdp_prep[i].scratch[PDP_val].u_val); } - fprintf(out_file, "\t\t %lu \n", + fprintf(out_file, "\t\t%lu\n", rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt); fprintf(out_file, "\t\n\n"); } - fputs("", out_file); + fputs("\n", out_file); rra_base = rrd_file->header_len; rra_next = rra_base; @@ -160,9 +169,9 @@ static int rrd_dump_opt_r( rra_next += (rrd.stat_head->ds_cnt * rrd.rra_def[i].row_cnt * sizeof(rrd_value_t)); fprintf(out_file, "\t\n"); - fprintf(out_file, "\t\t %s \n", rrd.rra_def[i].cf_nam); + fprintf(out_file, "\t\t%s\n", rrd.rra_def[i].cf_nam); fprintf(out_file, - "\t\t %lu \n\n", + "\t\t%lu \n\n", rrd.rra_def[i].pdp_cnt, rrd.rra_def[i].pdp_cnt * rrd.stat_head->pdp_step); /* support for RRA parameters */ @@ -170,46 +179,46 @@ static int rrd_dump_opt_r( switch (cf_conv(rrd.rra_def[i].cf_nam)) { case CF_HWPREDICT: case CF_MHWPREDICT: - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.rra_def[i].par[RRA_hw_alpha].u_val); - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.rra_def[i].par[RRA_hw_beta].u_val); fprintf(out_file, - "\t\t %lu \n", + "\t\t%lu\n", rrd.rra_def[i].par[RRA_dependent_rra_idx].u_cnt); break; case CF_SEASONAL: case CF_DEVSEASONAL: fprintf(out_file, - "\t\t %0.10e \n", + "\t\t%0.10e\n", rrd.rra_def[i].par[RRA_seasonal_gamma].u_val); fprintf(out_file, - "\t\t %lu \n", + "\t\t%lu\n", rrd.rra_def[i].par[RRA_seasonal_smooth_idx].u_cnt); if (atoi(rrd.stat_head->version) >= 4) { fprintf(out_file, - "\t\t %0.10e \n", + "\t\t%0.10e\n", rrd.rra_def[i].par[RRA_seasonal_smoothing_window]. u_val); } fprintf(out_file, - "\t\t %lu \n", + "\t\t%lu\n", rrd.rra_def[i].par[RRA_dependent_rra_idx].u_cnt); break; case CF_FAILURES: - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.rra_def[i].par[RRA_delta_pos].u_val); - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.rra_def[i].par[RRA_delta_neg].u_val); - fprintf(out_file, "\t\t %lu \n", + fprintf(out_file, "\t\t%lu\n", rrd.rra_def[i].par[RRA_window_len].u_cnt); fprintf(out_file, - "\t\t %lu \n", + "\t\t%lu\n", rrd.rra_def[i].par[RRA_failure_threshold].u_cnt); /* fall thru */ case CF_DEVPREDICT: fprintf(out_file, - "\t\t %lu \n", + "\t\t%lu\n", rrd.rra_def[i].par[RRA_dependent_rra_idx].u_cnt); break; case CF_AVERAGE: @@ -217,7 +226,7 @@ static int rrd_dump_opt_r( case CF_MINIMUM: case CF_LAST: default: - fprintf(out_file, "\t\t %0.10e \n", + fprintf(out_file, "\t\t%0.10e\n", rrd.rra_def[i].par[RRA_cdp_xff_val].u_val); break; } @@ -236,10 +245,10 @@ static int rrd_dump_opt_r( + ii].scratch[CDP_primary_val].u_val; if (isnan(value)) { fprintf(out_file, - "\t\t\t NaN \n"); + "\t\t\tNaN\n"); } else { fprintf(out_file, - "\t\t\t %0.10e \n", + "\t\t\t%0.10e\n", value); } value = @@ -247,10 +256,10 @@ static int rrd_dump_opt_r( ii].scratch[CDP_secondary_val].u_val; if (isnan(value)) { fprintf(out_file, - "\t\t\t NaN \n"); + "\t\t\tNaN\n"); } else { fprintf(out_file, - "\t\t\t %0.10e \n", + "\t\t\t%0.10e\n", value); } switch (cf_conv(rrd.rra_def[i].cf_nam)) { @@ -260,29 +269,29 @@ static int rrd_dump_opt_r( rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_hw_intercept].u_val; if (isnan(value)) { - fprintf(out_file, "\t\t\t NaN \n"); + fprintf(out_file, "\t\t\tNaN\n"); } else { fprintf(out_file, - "\t\t\t %0.10e \n", value); + "\t\t\t%0.10e\n", value); } value = rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_hw_last_intercept].u_val; if (isnan(value)) { fprintf(out_file, - "\t\t\t NaN \n"); + "\t\t\tNaN\n"); } else { fprintf(out_file, - "\t\t\t %0.10e \n", + "\t\t\t%0.10e\n", value); } value = rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_hw_slope].u_val; if (isnan(value)) { - fprintf(out_file, "\t\t\t NaN \n"); + fprintf(out_file, "\t\t\tNaN\n"); } else { - fprintf(out_file, "\t\t\t %0.10e \n", + fprintf(out_file, "\t\t\t%0.10e\n", value); } value = @@ -290,22 +299,22 @@ static int rrd_dump_opt_r( ii].scratch[CDP_hw_last_slope].u_val; if (isnan(value)) { fprintf(out_file, - "\t\t\t NaN \n"); + "\t\t\tNaN\n"); } else { fprintf(out_file, - "\t\t\t %0.10e \n", + "\t\t\t%0.10e\n", value); } ivalue = rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_null_count].u_cnt; - fprintf(out_file, "\t\t\t %lu \n", + fprintf(out_file, "\t\t\t%lu\n", ivalue); ivalue = rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_last_null_count].u_cnt; fprintf(out_file, - "\t\t\t %lu \n", + "\t\t\t%lu\n", ivalue); break; case CF_SEASONAL: @@ -314,9 +323,9 @@ static int rrd_dump_opt_r( rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_hw_seasonal].u_val; if (isnan(value)) { - fprintf(out_file, "\t\t\t NaN \n"); + fprintf(out_file, "\t\t\tNaN\n"); } else { - fprintf(out_file, "\t\t\t %0.10e \n", + fprintf(out_file, "\t\t\t%0.10e\n", value); } value = @@ -324,16 +333,16 @@ static int rrd_dump_opt_r( ii].scratch[CDP_hw_last_seasonal].u_val; if (isnan(value)) { fprintf(out_file, - "\t\t\t NaN \n"); + "\t\t\tNaN\n"); } else { fprintf(out_file, - "\t\t\t %0.10e \n", + "\t\t\t%0.10e\n", value); } ivalue = rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_init_seasonal].u_cnt; - fprintf(out_file, "\t\t\t %lu \n", + fprintf(out_file, "\t\t\t%lu\n", ivalue); break; case CF_DEVPREDICT: @@ -366,13 +375,13 @@ static int rrd_dump_opt_r( rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_val].u_val; if (isnan(value)) { - fprintf(out_file, "\t\t\t NaN \n"); + fprintf(out_file, "\t\t\tNaN\n"); } else { - fprintf(out_file, "\t\t\t %0.10e \n", + fprintf(out_file, "\t\t\t%0.10e\n", value); } fprintf(out_file, - "\t\t\t %lu \n", + "\t\t\t%lu\n", rrd.cdp_prep[i * rrd.stat_head->ds_cnt + ii].scratch[CDP_unkn_pdp_cnt].u_cnt); break; @@ -410,9 +419,9 @@ static int rrd_dump_opt_r( for (iii = 0; iii < rrd.stat_head->ds_cnt; iii++) { rrd_read(rrd_file, &my_cdp, sizeof(rrd_value_t) * 1); if (isnan(my_cdp)) { - fprintf(out_file, " NaN "); + fprintf(out_file, "NaN"); } else { - fprintf(out_file, " %0.10e ", my_cdp); + fprintf(out_file, "%0.10e", my_cdp); }; } fprintf(out_file, "\n"); @@ -441,7 +450,12 @@ int rrd_dump( char **argv) { int rc; - int opt_noheader = 0; + /** + * 0 = no header + * 1 = dtd header + * 2 = xsd header + */ + int opt_header = 0; char *opt_daemon = NULL; /* init rrd clean */ @@ -454,11 +468,11 @@ int rrd_dump( int option_index = 0; static struct option long_options[] = { {"daemon", required_argument, 0, 'd'}, - {"no-header", no_argument, 0, 'n'}, + {"header", required_argument, 0, 'h'}, {0, 0, 0, 0} }; - opt = getopt_long(argc, argv, "d:n", long_options, &option_index); + opt = getopt_long(argc, argv, "d:h:", long_options, &option_index); if (opt == EOF) break; @@ -475,12 +489,16 @@ int rrd_dump( } break; - case 'n': - opt_noheader = 1; - break; + case 'h': + if (strcmp(optarg, "dtd") == 0) { + opt_header = 1; + } else if (strcmp(optarg, "xsd") == 0) { + opt_header = 2; + } + break; default: - rrd_set_error("usage rrdtool %s [--no-header|-n] " + rrd_set_error("usage rrdtool %s [--header|-h {xsd,dtd}] " "file.rrd [file.xml]", argv[0]); return (-1); break; @@ -488,7 +506,7 @@ int rrd_dump( } /* while (42) */ if ((argc - optind) < 1 || (argc - optind) > 2) { - rrd_set_error("usage rrdtool %s [--no-header|-n] " + rrd_set_error("usage rrdtool %s [--header|-h {xsd,dtd}] " "file.rrd [file.xml]", argv[0]); return (-1); } @@ -498,9 +516,9 @@ int rrd_dump( if (rc) return (rc); if ((argc - optind) == 2) { - rc = rrd_dump_opt_r(argv[optind], argv[optind + 1], opt_noheader); + rc = rrd_dump_opt_r(argv[optind], argv[optind + 1], opt_header); } else { - rc = rrd_dump_opt_r(argv[optind], NULL, opt_noheader); + rc = rrd_dump_opt_r(argv[optind], NULL, opt_header); } return rc; diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 4da8019..051631c 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -70,7 +70,8 @@ void PrintUsage( const char *help_dump = N_("* dump - dump an RRD to XML\n\n" - "\trrdtool dump filename.rrd >filename.xml\n\n"); + "\trrdtool dump filename.rrd >filename.xml\n" + "\t\t[--header|-h {xsd,dtd}]\n\n"); const char *help_info = N_("* info - returns the configuration and status of the RRD\n\n"