[rrd-users] Re: 64-bit maximum create question

Flemming Kjaer Jensen fkj at tomat.net
Tue Apr 20 16:24:35 MEST 2004


On Mon, 2004-04-19 at 21:05, golden wrote:
> Hello all,
> 
> I am creating a PERL program to create and update RRD.  I have found
> that when I create the graph using a 64 bit value (1.8e+19) for the
> maximum, the fetch data shows something smaller (1.8e+17).  It seems
> that if I do a tune command after the create to reset the maximum
> value to 1.8e+19, the database gets updated correctly.
> 
> Is this a known issue?

I verified your problem on the command-line and the problem persists.
See below for my explanation.

fkj at rocket% rrdtool create packet.rrd --start 0 --step 60
DS:pkts_in_total:COUNTER:120:0:18446744073709551616
RRA:AVERAGE:0.5:1:1200

fkj at rocket% rrdtool info packet.rrd
filename = "packet.rrd"
rrd_version = "0001"
step = 60
last_update = 1082412000
ds[pkts_in_total].type = "COUNTER"
ds[pkts_in_total].minimal_heartbeat = 120
ds[pkts_in_total].min = 0.0000000000e+00
ds[pkts_in_total].max = 1.8446744074e+17
ds[pkts_in_total].last_ds = "UNKN"
ds[pkts_in_total].value = 0.0000000000e+00
ds[pkts_in_total].unknown_sec = 0
rra[0].cf = "AVERAGE"
rra[0].rows = 1200
rra[0].pdp_per_row = 1
rra[0].xff = 5.0000000000e-01
rra[0].cdp_prep[0].value = NaN
rra[0].cdp_prep[0].unknown_datapoints = 0

> Any suggestions or help is greatly appreciated.

I would guess that using gdb and a rrdtool recompiled for debugging
would help to identify the source of the problem but browsing the source
of rrdtool/src/rrd_create.c reveals that the snip of the following
function

/* The magic number here is one less than DS_NAM_SIZE */
#define DS_NAM_FMT    "%19[a-zA-Z0-9_-]"
#define DS_NAM_SIZE   20
...
...
...
void parseGENERIC_DS(char *def,rrd_t *rrd, int ds_idx)
{
    char minstr[DS_NAM_SIZE], maxstr[DS_NAM_SIZE];	
    /*
      int temp;
      
      temp = sscanf(def,"%lu:%18[^:]:%18[^:]",	
      &(rrd -> ds_def[ds_idx].par[DS_mrhb_cnt].u_cnt),
      minstr,maxstr);
    */
    if (sscanf(def,"%lu:%18[^:]:%18[^:]",	
               &(rrd -> ds_def[ds_idx].par[DS_mrhb_cnt].u_cnt),
               minstr,maxstr) == 3)
    {
        if (minstr[0] == 'U' && minstr[1] == 0)
            rrd -> ds_def[ds_idx].par[DS_min_val].u_val = DNAN;
        else
            rrd -> ds_def[ds_idx].par[DS_min_val].u_val = atof(minstr);
        
        if (maxstr[0] == 'U' && maxstr[1] == 0)
            rrd -> ds_def[ds_idx].par[DS_max_val].u_val = DNAN;
        else
            rrd -> ds_def[ds_idx].par[DS_max_val].u_val  = atof(maxstr);

from that it seems that although the string "maxstr" of length
DS_NAM_SIZE (20) only 18 characters are parsed in the sscanf(...)
function call. It looks like the problem you are having with specifying
a 20 character long max value 1.8e19 can be explained by rrdtool create
only parsing 18 characters of the max value you specify.

A solution would probably change sscanf() to parse 20 characters but I
do not know the possible harm it could do to other parts of rrdtool...

The rrdtool/src/rrd_tune.c function implement the parsing using

case 'a':
    if ((matches = sscanf(optarg, DS_NAM_FMT,":%lf",ds_nam,&max)) <1){
	rrd_set_error("invalid arguments for maximum ds value");
	rrd_free(&rrd);
        fclose(rrd_file);
	return -1;

where sscanf format string does not impose any limits to max length of
the max value supplied through the command line. That is most likely why
you can specify 1.8e19 with rrdtune and only 1.8e17 with rrdcreate.

Fix the source code and recompile or wait for the official fix.


kind regards 

Flemming Kjaer Jensen
<fkj at tomat.net>





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