[rrd-users] Problems when using C library

Francisco Sant'Anna chico.santanna at uol.com.br
Wed Nov 28 13:40:10 MET 2001


I want to update an RRD database inside a C program.

For that I use rrd_last() to check if the database already exists.
If it does I just uptade it with rrd_update().
If it doesn't I create it with rrd_create() and then update it with

When I run the program the first time (the RRD database doesn't exists),
after the rrd_update() call, I get the error:
"ERROR: Not enough arguments"

The second time the problem doesn't accurs!
It just happens when I call rrd_create() followed by rrd_update().

Using pipes I don't get the problem.


Here is the output for the two consecutives runs:

[root at nas niacap]# ./a.out 
COMMAND: last test.rrd
ERROR: opening 'test.rrd': No such file or directory	<----- OK, IT
COMMAND: create --start 1000000000 test.rrd
COMMAND: update test.rrd 1000000001:1000:1000
ERROR: Not enough arguments				<----- THE ERROR

[root at nas niacap]# ./a.out 
COMMAND: last test.rrd					<----- IT EXISTS
COMMAND: update test.rrd 1000000001:1000:1000		<----- NO ERROR
[root at nas niacap]# 


Here is the code for this program that simulates the problem:

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

void r_erro (void)
	if (rrd_test_error())
		fprintf(stdout, "ERROR: %s\n", rrd_get_error());

unsigned int r_last (char *rrd_nome)
	char *argv[2] = { "last", rrd_nome };
	unsigned int t;

	printf("COMMAND: %s %s\n", argv[0], argv[1]);
	t = rrd_last(2, argv);

	return ((int)t == -1) ? 0 : t;

int main (void)
	int i;
	unsigned int last;

	char r_nome[50] = "test.rrd";
	char r_update_temp[50];
	char *r_update[3] = { "update", r_nome, r_update_temp };

	char *r_create[8] =
		"create", "--start", "1000000000", r_nome,

	if ( !(last = r_last(r_nome)) )
		printf("COMMAND: %s %s %s %s\n\t%s\n\t%s\n\t%s\n\t%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]);
		rrd_create(8, r_create);

	sprintf(r_update_temp, "%u:%u:%u", ++last, 1000, 1000);
	printf("COMMAND: %s %s %s\n", r_update[0], r_update[1], r_update[2]);

	rrd_update(3, r_update);


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