Closed geoffgarside closed 11 years ago
This happens because we check for the int returned by the C function rrd_graph in rrd_graph(args.size+1, argv, calcpr_ptr, xsize_ptr, ysize_ptr, nil, ymin_ptr, ymax_ptr) == 0
I suggest investigating from which C function or parameter you could get this printable outputs and maybe propose a pull request. I honestly never used the print command, that's why I never researched its implementation.
The output comes from the char ***prdata
argument to the rrd_graph
function. So the data will be in the calcpr_ptr
variable in your code.
The rrd_tool.c
code relevant to this is
if (rrd_graph
(argc - 1, &argv[1], &calcpr, &xsize, &ysize, NULL, &ymin,
&ymax) == 0) {
if (!tostdout && !imginfo)
printf("%dx%d\n", xsize, ysize);
if (calcpr) {
for (i = 0; calcpr[i]; i++) {
if (!tostdout)
printf("%s\n", calcpr[i]);
free(calcpr[i]);
}
free(calcpr);
}
}
the relevant part being printf("%s\n", calcpr[i]);
so the RRD::Wrapper.graph
method needs to capture this and return it appropriately. I'll see if I can work out enough of FFI to get these strings out, for now though it looks like I can require both rrd-ffi and the 'RRD' ruby bindings and get the bindings version of the RRD.graph
method.
Would you be adverse to the RRD::Wrapper.graph
method returning an array of strings instead of true
if theres PRINT output to return?
Nice job. I'm ok with that, since the rrd graph does output the PRINT output to the cli.
Does the RRD::Wrapper.graph method eat up all of the PRINT output from the graph call? Using PRINT in graph is only way to get calculated data out of an RRD, but it looks like the wrapper method just returns true and I never get any of the stats I need.