[rrd-users] problems in rrd_create

Ranieri Romera rromera at terra.com.br
Tue Jun 29 17:53:42 MEST 2004


Hi,

I'm writing a C program and found a strange behavior in
function rrd_create.

The destination file isn't created with the correct name.

The functions CountArgs and CreateArgs are imported from
rrd_tool.c

See part of my code:
...
#define defhead "--start NOW-10 --step"
#define defgaug "DS:ds0:GAUGE:600:0:'U' DS:ds1:GAUGE:600:0:'U'"
#define defcoun "DS:ds0:COUNTER:600:0:'U' DS:ds1:COUNTER:600:0:'U'"
#define defrraa "RRA:AVERAGE:0.5:1:800 RRA:AVERAGE:0.5:6:800 
RRA:AVERAGE:0.5:24:800 RRA:AVERAGE:0.5:288:800"
#define defrram "RRA:MAX:0.5:1:800 RRA:MAX:0.5:6:800 RRA:MAX:0.5:24:800 
RRA:MAX:0.5:288:800"
...
char **defargv ;
int defargc ;
...
char cmdlin[2048] ;
char opt[1024] ;
int f ;
...
if ( strstr(opt, "gauge") ) {
    snprintf(cmdlin,sizeof(cmdlin),"%s %s %s %d %s %s 
%s","create",dstpth,defhead,configuracao.cycle,
       defgaug,defrraa,defrram) ;
} else {
    snprintf(cmdlin,sizeof(cmdlin),"%s %s %s %d %s %s 
%s","create",dstpth,defhead,configuracao.cycle,
       defcoun,defrraa,defrram) ;
}
#ifdef DEBUG
printf("%s[%s(%d)] --> cmdlin={%s}\n",__FILE__,__FUNCTION__,__LINE__,cmdlin) ;
fflush (NULL) ;
#endif
defargc = CountArgs(cmdlin) ;
#ifdef DEBUG
printf("%s[%s(%d)] --> 
defargc={%d}\n",__FILE__,__FUNCTION__,__LINE__,defargc) ;
fflush (NULL) ;
#endif
defargv = (char **) malloc((defargc+1) * sizeof(char *));
bzero(defargv, (defargc+1) * sizeof(char *));
defargc = CreateArgs("tdc", cmdlin, defargc, defargv);
#ifdef DEBUG
printf("%s[%s(%d)] --> 
defargc={%d}\n",__FILE__,__FUNCTION__,__LINE__,defargc) ;
fflush (NULL) ;
#endif
#ifdef DEBUG
for ( f = 0 ; f < defargc ; f ++ ) {
    printf("%s[%s(%d)] --> defargv[%d] = 
{%s}\n",__FILE__,__FUNCTION__,__LINE__,f,defargv[f]) ;
}
fflush (NULL) ;
#endif
if ( rrd_create((defargc-2), &defargv[2]) == -1 ) {
    rrd_set_error("nao conheco a funcao '%s'", defargv[1]);
} else {
    printf("%s[%s(%d)] --> ok para {%s}\n",__FILE__,__FUNCTION__,__LINE__, 
defargv[1]);
    fflush(NULL) ;
}
if (rrd_test_error()) {
    printf("%s[%s(%d)] --> ERROR RRD: 
%s\n",__FILE__,__FUNCTION__,__LINE__,rrd_get_error());
    rrd_clear_error();
    fflush (NULL) ;
}
if (defargv) {
    free(defargv) ;
}

-----------------
See my debug info:

coleta.c[mrtg1itemmnt(260)] --> cmdlin={create 
/zaz/htdocs/mrtg/srvx-poa/srvx-poa_openfiles.rrd --start NOW-10 --step 300 
DS:ds0:GAUGE:600:0:'U' DS:ds1:GAUGE:600:0:'U' RRA:AVERAGE:0.5:1:800 
RRA:AVERAGE:0.5:6:800 RRA:AVERAGE:0.5:24:800 RRA:AVERAGE:0.5:288:800 
RRA:MAX:0.5:1:800 RRA:MAX:0.5:6:800 RRA:MAX:0.5:24:800 RRA:MAX:0.5:288:800}
coleta.c[mrtg1itemmnt(266)] --> defargc={16}
coleta.c[mrtg1itemmnt(273)] --> defargc={17}
coleta.c[mrtg1itemmnt(278)] --> defargv[0] = {tdc}
coleta.c[mrtg1itemmnt(278)] --> defargv[1] = {create}
coleta.c[mrtg1itemmnt(278)] --> defargv[2] = 
{/zaz/htdocs/mrtg/srvx-poa/srvx-poa_openfiles.rrd}
coleta.c[mrtg1itemmnt(278)] --> defargv[3] = {--start}
coleta.c[mrtg1itemmnt(278)] --> defargv[4] = {NOW-10}
coleta.c[mrtg1itemmnt(278)] --> defargv[5] = {--step}
coleta.c[mrtg1itemmnt(278)] --> defargv[6] = {300}
coleta.c[mrtg1itemmnt(278)] --> defargv[7] = {DS:ds0:GAUGE:600:0:U}
coleta.c[mrtg1itemmnt(278)] --> defargv[8] = {DS:ds1:GAUGE:600:0:U}
coleta.c[mrtg1itemmnt(278)] --> defargv[9] = {RRA:AVERAGE:0.5:1:800}
coleta.c[mrtg1itemmnt(278)] --> defargv[10] = {RRA:AVERAGE:0.5:6:800}
coleta.c[mrtg1itemmnt(278)] --> defargv[11] = {RRA:AVERAGE:0.5:24:800}
coleta.c[mrtg1itemmnt(278)] --> defargv[12] = {RRA:AVERAGE:0.5:288:800}
coleta.c[mrtg1itemmnt(278)] --> defargv[13] = {RRA:MAX:0.5:1:800}
coleta.c[mrtg1itemmnt(278)] --> defargv[14] = {RRA:MAX:0.5:6:800}
coleta.c[mrtg1itemmnt(278)] --> defargv[15] = {RRA:MAX:0.5:24:800}
coleta.c[mrtg1itemmnt(278)] --> defargv[16] = {RRA:MAX:0.5:288:800}
coleta.c[mrtg1itemmnt(285)] --> ok para {create}

---------------

In this case the file "/zaz/htdocs/mrtg/srvx-poa/srvx-poa_openfiles.rrd" isn't
created, but in the current directory I have a new file called 
"DS:ds0:GAUGE:600:0:U"
and this file is a RRD file.
# file DS\:ds0\:GAUGE\:600\:0\:U
DS:ds0:GAUGE:600:0:U: RRDTool DB version 0001


If I call the rrdtool, in command line, the file created is the correct.

I'm making anything wrong ? Any idea why this occurs ?

TIA,

Ranieri

--
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