[rrd-users] Re: rrd_graph and once more calling

Frank Swasey Frank.Swasey at uvm.edu
Sat Nov 10 15:52:39 MET 2001


Yes, your program does work the following one doesn't...  The only thing
I changed was I'm varying the start time instead of the comment.  The
file0.png and file1.png files are IDENTICAL, they shouldn't be!

---------8<------------8<-----------8<---------8<-----------8<-------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <rrdtool/rrd.h>

int
main(int argc, char** argv) {
    char **calcpr;
    int xsize, ysize;
    int i, j;
    int num_graphs = 2;
    char tfilename[24];
    char tstart[24];
    char tcom[24];
    char *filename = "file";
    char *com = "COMMENT:Number ";
    char *ga[6];

    ga[0] = "graph";
    ga[1] = tfilename;
    ga[2] = "-s";
    ga[3] = tstart;
    ga[4] = "DEF:temp=testg.rrd:temp:AVERAGE";
    ga[5] = "COMMENT:Yup, this is one";

    for (i = 0; i < num_graphs ; i++) {
	sprintf(tfilename, "%s%i.png", filename, i);
	sprintf(tstart,"%d", (i+1) * (-86400) );

	printf("Before: ");
        for (j=0; j<6; j++) {
	    printf("%s ", ga[j]);
	}
	printf("\n");

	printf("making %s \t", tfilename);

	if ( rrd_graph(6, ga, &calcpr, &xsize, &ysize) != -1 ) {
	    printf("%dx%d\n", xsize, ysize);
	}

	if ( rrd_test_error() ) {
	    printf("ERROR: %s\n", rrd_get_error() );
	    rrd_clear_error();
	}

	printf("After: ");
        for (j=0; j<6; j++) {
	    printf("%s ", ga[j]);
	}
	printf("\n\n");

    }

    return 0;
}
---------8<------------8<-----------8<---------8<-----------8<-------

Here's what it prints out....  Why did the values in ga[1], [2], and [3]
moved during the first call to rrd_graph?

---------8<------------8<-----------8<---------8<-----------8<-------
$ ./testg
Before: graph file0.png -s -86400 DEF:temp=testg.rrd:temp:AVERAGE COMMENT:Yup, this is one
making file0.png 	495x155
After: graph -s -86400 file0.png DEF:temp=testg.rrd:temp:AVERAGE COMMENT:Yup, this is one

Before: graph -s -172800 file1.png DEF:temp=testg.rrd:temp:AVERAGE COMMENT:Yup, this is one
making file1.png 	495x155
After: graph -s -172800 file1.png DEF:temp=testg.rrd:temp:AVERAGE COMMENT:Yup, this is one

---------8<------------8<-----------8<---------8<-----------8<-------

cmp file0.png file1.png shows NO DIFFERENCES.  There are two days worth
of sample data in the rrd file but both png files only have 24 hours of
graph.

I'd like to be able to generate the daily, weekly, monthly, yearly type
graphs I'm familiar with from MRTG using a C program that has a loop
around rrd_graph modifying the start time and step intervals.

It would appear that there is some other step that must be done to clear
rrd_graph's recollection of what the arguments were.  What is that step?

Thanks,
-- 
Frank Swasey                    | http://www.uvm.edu/~fcs
Systems Programmer              | Always remember: You are UNIQUE,
University of Vermont           |    just like everyone else.
                    === God Bless Us All ===



--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list