On 4/16/07, Mark Easton <[EMAIL PROTECTED]> wrote:
//Create Graph - but this returns a segmentation fault (core dumped)
sprintf(argstr, "temp.png --start %lu --end %lu
DEF:mytemp=temperature.rrd:temp:AVERAGE", (long)start_time, (long)end_time);
ret = wrap_rrd_graph( argstr);
rrd_wrapper from the contrib section of the rrdtool website is dated
17-Dec-2001. It has not been kept up and isn't compatible with
rrdtool 1.2.x. Actually, I'm not sure how you got it to compile; I
receive the following error:
$ gcc -o test -lrrd main.c rrdwrap.c
rrdwrap.c: In function 'wrap_rrd_graph':
rrdwrap.c:165: error: too few arguments to function 'rrd_graph'
I would guess you have an old version of rrd.h and rrd_tool.h, but
somehow linking to the 1.2.x version of the library (librrd.so). I've
attached a patch against rrdwrap.c that at least makes it compile (and
fixes a memory leak).
As you can see, rrd_wrapper is out-of-date and unmaintained. I urge
you to consider using the librrd API directly. Look at main() in
src/rrd_tool.c you'll see how the command-line rrdtool does this.
-Sam
--- rrdwrap.c.orig 2007-04-16 19:35:26.000000000 -0400
+++ rrdwrap.c 2007-04-16 19:39:39.000000000 -0400
@@ -156,15 +156,24 @@
i, argc,
xsize, // must be passed to the rrd_graph function but does not need to be initialised
ysize; // must be passed to the rrd_graph function but does not need to be initialised
+ double
+ ymin, // must be passed to the rrd_graph function but does not need to be initialised
+ ymax; // must be passed to the rrd_graph function but does not need to be initialised
if((argv = string_to_argv(argstr, &argc)) != NULL)
{
optind=0; /* reset gnu getopt */
opterr=0; /* no error messages */
- i = rrd_graph(argc, argv, prdata, &xsize, &ysize);
+ i = rrd_graph(argc, argv, prdata, &xsize, &ysize, NULL, &ymin, &ymax);
// free up the memory
+ if (prdata) {
+ for(i=0;prdata[i];i++) {
+ free(prdata[i]);
+ }
+ free(prdata);
+ }
Free_argv(argv);
return i;
_______________________________________________
rrd-users mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users