From: netniV Date: Sun, 5 Jul 2020 11:59:21 +0000 (+0000) Subject: Allow JSONTIME to be added to graphv output X-Git-Tag: v1.8.0~34^2~9 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f1889ead675e8f390d7cbabc9fa059855c6f17dd;p=thirdparty%2Frrdtool-1.x.git Allow JSONTIME to be added to graphv output --- diff --git a/src/rrd_graph.c b/src/rrd_graph.c index bf774292..4c574656 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -4755,6 +4755,16 @@ rrd_info_t *rrd_graph_v( img.u_blo.ptr = im.rendered_image; grinfo_push(&im, sprintf_alloc("image"), RD_I_BLO, img); } + if (im.extra_flags & FORCE_JSONTIME) { + im.imgformat = IF_JSONTIME; + if (rrd_graph_xport(&im)) { + rrd_infoval_t img; + + img.u_blo.size = im.rendered_image_size; + img.u_blo.ptr = im.rendered_image; + grinfo_push(&im, sprintf_alloc("datapoints"), RD_I_BLO, img); + } + } grinfo = im.grinfo; im_free(&im); return grinfo; @@ -4948,6 +4958,7 @@ void rrd_graph_options( /* defines for long options without a short equivalent. should be bytes, and may not collide with (the ASCII value of) short options */ #define LONGOPT_UNITS_SI 255 +#define LONGOPT_ADD_JSONTIME 254 /* *INDENT-OFF* */ struct optparse_long longopts[] = { @@ -4994,6 +5005,7 @@ void rrd_graph_options( {"lazy", 'z', OPTPARSE_NONE}, {"use-nan-for-all-missing-data", 'Z', OPTPARSE_NONE}, {"units", LONGOPT_UNITS_SI, OPTPARSE_REQUIRED}, + {"add-jsontime", LONGOPT_ADD_JSONTIME, OPTPARSE_NONE}, {"alt-y-mrtg", 1000, OPTPARSE_NONE}, /* this has no effect it is just here to save old apps from crashing when they use it */ {"disable-rrdtool-tag",1001, OPTPARSE_NONE}, {"right-axis", 1002, OPTPARSE_REQUIRED}, @@ -5094,6 +5106,13 @@ void rrd_graph_options( return; } break; + case LONGOPT_ADD_JSONTIME: + if (im->extra_flags & FORCE_JSONTIME) { + rrd_set_error("--units can only be used once!"); + return; + } + im->extra_flags |= FORCE_JSONTIME; + break; case 'X': im->unitsexponent = atoi(poptions->optarg); break; diff --git a/src/rrd_graph.h b/src/rrd_graph.h index a2f4faa4..958d0874 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -45,6 +45,7 @@ #define FULL_SIZE_MODE 0x200 /* -width and -height indicate the total size of the image */ #define NO_RRDTOOL_TAG 0x400 /* disable the rrdtool tag */ #define ALLOW_MISSING_DS 0x800 /* missing DS is not fatal */ +#define FORCE_JSONTIME 0x1000 /* add jsontime to graphv output */ #define gdes_fetch_key(x) sprintf_alloc("%s:%s:%d:%d:%d:%d:%d:%d",x.rrd,x.daemon,x.cf,x.cf_reduce,x.start_orig,x.end_orig,x.step_orig,x.step)