[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rrd-developers
Subject:    [rrd-developers] [patch] report header length in rrdinfo
From:       <Daniel.Pocock () barclayscapital ! com>
Date:       2009-04-17 10:41:29
Message-ID: B9AEC8265E202D4BA6540EA32F49579007DAFA80 () LDNPCMEU301VEUA ! INTRANET ! BARCAPINT ! COM
[Download RAW message or body]



This patch does two things:
- the code for calculating header length is moved to a function in
rrd_format.c
- the header length is reported by `rrdtool info', useful for studying
file size and memory usage

Regards,

Daniel



Index: src/rrd_info.c
===================================================================
--- src/rrd_info.c      (revision 1793)
+++ src/rrd_info.c      (working copy)
@@ -164,6 +164,9 @@
     info.u_cnt = rrd.live_head->last_up;
     cd = rrd_info_push(cd, sprintf_alloc("last_update"), RD_I_CNT,
info);
 
+    info.u_cnt = rrd_get_header_size(&rrd);
+    cd = rrd_info_push(cd, sprintf_alloc("header_size"), RD_I_CNT,
info);
+
     for (i = 0; i < rrd.stat_head->ds_cnt; i++) {
 
         info.u_str = rrd.ds_def[i].dst;
Index: src/rrd_tool.h
===================================================================
--- src/rrd_tool.h      (revision 1793)
+++ src/rrd_tool.h      (working copy)
@@ -115,6 +115,8 @@
     long      ds_match(
     rrd_t *rrd,
     char *ds_nam);
+    off_t rrd_get_header_size(
+    rrd_t *rrd);
     double    rrd_diff(
     char *a,
     char *b);
Index: src/rrd_format.c
===================================================================
--- src/rrd_format.c    (revision 1793)
+++ src/rrd_format.c    (working copy)
@@ -98,3 +98,16 @@
     rrd_set_error("unknown data source name '%s'", ds_nam);
     return -1;
 }
+
+off_t rrd_get_header_size(
+    rrd_t *rrd)
+{
+    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) + \
+        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;
+}
Index: src/rrd_open.c
===================================================================
--- src/rrd_open.c      (revision 1793)
+++ src/rrd_open.c      (working copy)
@@ -107,15 +107,7 @@
     /* Are we creating a new file? */
     if((rdwr & RRD_CREAT) && (rrd->stat_head != NULL))
     {
-        header_len = \
-          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) + \
-          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;
+        header_len = rrd_get_header_size(rrd);
 
         value_cnt = 0;
         for (ui = 0; ui < rrd->stat_head->rra_cnt; ui++)
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise \
protected from disclosure. If you are not an intended recipient of this e-mail, do \
not duplicate or redistribute it by any means. Please delete it and any attachments \
and notify the sender that you have received it in error. Unless specifically \
indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or \
sell any securities, investment products or other financial product or service, an \
official confirmation of any transaction, or an official statement of Barclays. Any \
views or opinions presented are solely those of the author and do not necessarily \
represent those of Barclays. This e-mail is subject to terms available at the \
following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you \
consent to the foregoing.  Barclays Capital is the investment banking division of \
Barclays Bank PLC, a company registered in England (number 1026167) with its \
registered offic  e at 1 Churchill Place, London, E14 5HP.  This email may relate to \
or be sent from other members of the Barclays Group. \
_______________________________________________

_______________________________________________
rrd-developers mailing list
rrd-developers@lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic