[rrd-users] rrd resize error

Tobias Oetiker tobi at oetiker.ch
Wed Jun 29 00:39:15 CEST 2011


Yesterday Daniel De Marco wrote:

> * Daniel De Marco <ddm at bartol.udel.edu> [06/27/2011 23:09]:
> > creates it with a header size of 548, that is not divisible by
> > sizeof(rrd_value_t)=8. I don't know whether this is normal or not.
>
> this seems to be normal. However the problem might be in the definition
> of rrd_get_header_size in rrd_format.c . To calculate header size the
> function includes the sizeof(time_t) that is no longer used in v3.
> When rrd_open creates a new file it uses rrd_get_header_size to
> determine its size. Then other functions fill it and the 4 extra bytes
> remain unused at the end of the file. rrd_resize stumbles on those 4
> extra bytes. On x86_64 the sizeof(time_t) is 8, so the extra space at
> the end of the file is a multiple of sizeof(rrd_value_t) and rrd_resize
> copies it without complaining. What do you think?

neat ... so I guess the following should fix this problem:

Index: rrd_format.c
===================================================================
--- rrd_format.c        (revision 2188)
+++ rrd_format.c        (working copy)
@@ -125,8 +125,7 @@
     return sizeof(stat_head_t) + \
         sizeof(ds_def_t) * rrd->stat_head->ds_cnt + \
         sizeof(rra_def_t) * rrd->stat_head->rra_cnt + \
-        sizeof(time_t) + \
-        sizeof(live_head_t) + \
+        atoi(rrd->stat_head->version) < 3 ? sizeof(time_t) : sizeof(live_head_t) + \
         sizeof(pdp_prep_t) * rrd->stat_head->ds_cnt + \
         sizeof(cdp_prep_t) * rrd->stat_head->ds_cnt * rrd->stat_head->rra_cnt + \
         sizeof(rra_ptr_t) * rrd->stat_head->rra_cnt;

can you try ?

cheers
tobi
>
> Daniel.
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900



More information about the rrd-users mailing list