Hello all,

I've encountered another brick wall programming against librrd.

My program is supposed to create an rrd file for every interface ID it does not 
see an rrd file for.

When I run the program, the first call to createrrd() works like a charm, the 
second call attempts to make an rrd called DS:ifInOctets:COUNTER:600:U:U, which 
is args[3] (below), and this is obviously not the desired result.

Is there some sore of rrd_create/free function I need to be using that I'm 
missing, the arguments get passed correctly each time (note the debug 
statements).

Here is the function I use to create an RRD.

int createrrd(char *newrrd)
{
    int i, retval;
    char **args;
    char finalname[128];
    char finaltime[24];
    long now;
    struct stat     statbuf;
    int             statret;

    args = (char **)malloc(10240);
    bzero((char **)args, 10240);

    /* Make the RRD named accordingly */
    sprintf( finalname, "%s%s.rrd", RRD_FILES_PATH, newrrd );

    /* Unixtime funcs */
    now = (long)time(NULL);
    sprintf( finaltime, "--start=%li", now );

    args[0] = "create";
    args[1] = finalname;
    args[2] = finaltime;
    args[3] = "DS:ifInOctets:COUNTER:600:U:U";
    args[4] = "DS:ifOutOctets:COUNTER:600:U:U";
    args[5] = "DS:ifInUcastPkts:COUNTER:600:U:U";
    args[6] = "DS:ifOutUcastPkts:COUNTER:600:U:U";
    args[7] = "DS:ifInErrors:COUNTER:600:U:U";
    args[8] = "RRA:AVERAGE:0.5:1:600";
    args[9] = "RRA:AVERAGE:0.5:6:700";
    args[10] = "RRA:AVERAGE:0.5:24:775";
    args[11] = "RRA:AVERAGE:0.5:288:797";
    args[12] = "RRA:MAX:0.5:1:600";
    args[13] = "RRA:MAX:0.5:6:700";
    args[14] = "RRA:MAX:0.5:24:775";
    args[15] = "RRA:MAX:0.5:288:797";
    args[16] = "\0";

    for(i=0;i<16;i++)
    {
        printf("Args %d: %s\n",i,args[i]);
    }

    printf( "Creating RRD %s\n", args[1] );
    statret = stat( finalname, &statbuf );
    printf( "Checked %s, status: %d\n", finalname, statret );
    while( statret != 0 ) {
        retval = rrd_create(15,args);
        statret = stat( finalname, &statbuf );
    }

    free(args);
}


Best Regards, 

David Olsen
ISPrime, Inc.
866.502.4678 ext. 87
AIM: Dave ISPrime - ICQ: 136633378

--
Unsubscribe mailto:[EMAIL PROTECTED]
Help        mailto:[EMAIL PROTECTED]
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

Reply via email to