[rrd-users] rrd_graph() producing a 0 bytes image

folkert folkert at vanheusden.com
Thu Aug 21 22:30:09 CEST 2014


Hi,

I'm trying to generate a graph from an rrd-file using rrd_graph() in
c++:

const char *rrd_file_name = "myrrdfile.rrd";

        char *data_line = NULL;
        asprintf(&data_line, "DEF:ds0=%s:ds0:AVERAGE", rrd_file_name);

        const char *const args[] = {
                "--width",
                "640",
                "--height",
                "480",
                "--end",
                "now",
                "--start",
                "-1d",
                data_line,
                "LINE1:ds0#00ff00:ds0",
                NULL };

        FILE *fh = open_memstream(data, data_len);
        if (!fh)
                error_exit(true, "open_memstream failed");

        char **prdata = NULL;
        int xsize = 640, ysize = 480;
        double ymin = 0, ymax = 0;
        int rc = rrd_graph(10, (char **)args, &prdata, &xsize, &ysize, fh, &ymin, &ymax);

        fclose(fh);

        free(data_line);

	printf("%d,%d %p,%d\n", xsize, ysize, *data, (int)(*data_len));

What this produces:
481,535 0x7f2760000e00,0

So: rrd_graph does something; it figures out it should create an image
of 481x535 pixels. But then something goes wrong because it retuns 0
bytes.

For completeness sake, myrrdfile.rrd:
                            ds0

1408573800: -nan
...
1408658100: -nan
1408658400: 5.7286432161e-03
1408658700: -nan
1408659000: -nan
1408659300: -nan
1408659600: -nan
1408659900: 0.0000000000e+00
1408660200: -nan

So there's data in it.

Any ideas what I might be doing wrong?

The return value is 0 by the way and also rrd_get_error() does not
return anything.


Folkert van Heusden

-- 
Wintips voor de staatsloterij? http://www.vanheusden.com/sl.php
     Meer weten over Bitcoins? http://www.vanheusden.com/bitcoins/
          Meer weten over TOR? http://www.vanheusden.com/tor/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



More information about the rrd-users mailing list