[rrd-users] why does/should rrd_create() alter argv?
Rick Jones
rick.jones2 at hp.com
Wed Apr 27 23:14:01 CEST 2011
I have code that is creating a new RRD via rrd_update() (1.4.3 via
Ubuntu) and I'm at a loss as to why rrd_update is mucking with the argv
I pass it. Here is the code snippet:
optind = 0;
opterr = 0;
rrd_clear_error();
tell_them(LOG_INFO,
"%s creating new RRD %s\n",
__FUNCTION__,
argv[1]);
rc = rrd_create(position,argv);
if (rrd_test_error()) {
char *err = rrd_get_error();
tell_them(LOG_WARNING,
"%s() rrd_create() returned '%s'\n",
__FUNCTION__,
err);
context->rrd_errors++;
line = __LINE__;
goto fail;
}
tell_them(LOG_INFO,
"%s added new rrd %s\n",
__FUNCTION__,
argv[1]);
and here is the resulting output:
2011-04-27-13:19:27.447202: stat_and_create_generic_counter_db creating
new RRD /tmp/counters/192.168.1.7/0/32/generic.rrd
2011-04-27-13:19:27.627944: stat_and_create_generic_counter_db added new
rrd --start
before the call, argv[1] was the filename. after the call it is
"--start" that was in argv[2]. As I am filling argv with dynamically
allocated strings I wish to later free() I'm concerned there is a memory
leak since rrd_create() is shuffling things around.
It seems all the more strange given that rrd_update() does not seem to
do the same thing - at least not to the filename argument. Here is
output of a similar code snippet bracketing rrd_update():
2011-04-27-13:28:16.785560: update_generic_counter_db updating
RRD /tmp/counters/192.168.1.7/0/19/generic.rrd using arrival time
1303936096.785111 truncated to millseconds
2011-04-27-13:28:16.785646: update_generic_counter_db updated
RRD /tmp/counters/192.168.1.7/0/19/generic.rrd using arrival time
1303936096.785111 truncated to millseconds
rick jones
More information about the rrd-users
mailing list