[rrd-developers] Can not loop create rrd archives by using rrd_create API

benny uid at 21cn.com
Mon Nov 17 07:05:53 MET 2003


the following is my test code, it can only create 1 rrd file.


##############################################
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <rrd.h>


int main()
{

int interval=300;
int i;
char *r_create[9] ;
char archivename[255]={0};
char steparg[64]={0};
char beginarg[64]={0};
char dsmaxarg[255]={0};
char dsusedarg[255]={0};
char rraarg1[255]={0};
char rraarg2[255]={0};
char rraarg3[255]={0};



for(i=0;i<5;i++)
{
sprintf(archivename,"/root/rrd/test%d.rrd",i);
sprintf(steparg,"%d",interval);
sprintf(dsmaxarg,"DS:max:GAUGE:%d:0:100",interval*2);
sprintf(dsusedarg,"DS:used:GAUGE:%d:0:100",interval*2);
sprintf(rraarg1,"RRA:AVERAGE:0:1:288");
sprintf(rraarg2,"RRA:AVERAGE:0:30:%d");
sprintf(rraarg3,"RRA:AVERAGE:0:365:288");
 
 
r_create[0]="create" ;
r_create[1]= archivename ;
r_create[2]="--step";
r_create[3]=steparg ;
r_create[4]=dsmaxarg ; 
r_create[5]=dsusedarg ;
r_create[6]=rraarg1;
r_create[7]=rraarg2;
r_create[8]=rraarg3;
 
rrd_create(9,r_create);

printf("count=%d\n",i);
printf("%s %s %s %s %s %s %s %s 
%s\n",r_create[0],r_create[1],r_create[2],r_create[3],r_create[4],r_create[5],r_create[6],r_create[7],r_create[8]);
	if (rrd_test_error()) {
         fprintf(stderr, "rrd_create: %s\n", rrd_get_error()); 
          rrd_clear_error();
                }
}       
exit(0);

}

###########################
gcc create.c -o create -lrrd
[root at localhost rrd]# ./create
count=0
create --step 300 /root/rrd/test0.rrd DS:max:GAUGE:600:0:100 
DS:used:GAUGE:600:0:100 RRA:AVERAGE:0:1:288 RRA:AVERAGE:0:30:600 
RRA:AVERAGE:0:365:288
count=1
create /root/rrd/test1.rrd --step 300 DS:max:GAUGE:600:0:100 
DS:used:GAUGE:600:0:100 RRA:AVERAGE:0:1:288 RRA:AVERAGE:0:30:600 
RRA:AVERAGE:0:365:288
count=2
create /root/rrd/test2.rrd --step 300 DS:max:GAUGE:600:0:100 
DS:used:GAUGE:600:0:100 RRA:AVERAGE:0:1:288 RRA:AVERAGE:0:30:600 
RRA:AVERAGE:0:365:288
count=3
create /root/rrd/test3.rrd --step 300 DS:max:GAUGE:600:0:100 
DS:used:GAUGE:600:0:100 RRA:AVERAGE:0:1:288 RRA:AVERAGE:0:30:600 
RRA:AVERAGE:0:365:288
count=4
create /root/rrd/test4.rrd --step 300 DS:max:GAUGE:600:0:100 
DS:used:GAUGE:600:0:100 RRA:AVERAGE:0:1:288 RRA:AVERAGE:0:30:600 
RRA:AVERAGE:0:365:288



[root at Benny rrd]# ls -l /root/rrd
-rwxr-xr-x    1 root     root       103924 11月 17 13:46 create
-rw-r--r--    1 root     root         1245 11月 17 13:46 create.c
-rw-r--r--    1 root     root        20212 11月 17 13:46 test0.rrd


there is only test0.rrd create.

can anyone finger out what's wrong with the program? thanks







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



More information about the rrd-developers mailing list