introduced header_property in info output -- Daniel.Pocock barclayscapital.com
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Mon, 20 Apr 2009 06:46:47 +0000 (06:46 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Mon, 20 Apr 2009 06:46:47 +0000 (06:46 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1795 a5681a0c-68f1-0310-ab6d-d61299d08faa

doc/rrdinfo.pod
src/rrd_format.c
src/rrd_info.c
src/rrd_open.c
src/rrd_tool.h

index 00e5d16..d147756 100644 (file)
@@ -45,6 +45,7 @@ data sources.
  rrd_version = "0001"
  step = 300
  last_update = 955892996
+ header_size = 2872
  ds[a].type = "GAUGE"
  ds[a].minimal_heartbeat = 600
  ds[a].min = NaN
index 4e53e19..b7e3eff 100644 (file)
@@ -98,3 +98,16 @@ long ds_match(
     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 174bf1a..9b2363f 100644 (file)
@@ -164,6 +164,9 @@ rrd_info_t *rrd_info_r(
     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 f74c6d8..42426c6 100644 (file)
@@ -107,15 +107,7 @@ rrd_file_t *rrd_open(
     /* 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++)
index f58cd78..c1c9728 100644 (file)
@@ -115,6 +115,8 @@ int rrd_fetch_fn_libdbi(char *filename, enum cf_en cf_idx,
     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);