From aabd76e0f7d18ef1eae639d2589834ac052b3679 Mon Sep 17 00:00:00 2001 From: oetiker Date: Mon, 20 Apr 2009 06:46:47 +0000 Subject: [PATCH] introduced header_property in info output -- Daniel.Pocock barclayscapital.com git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1795 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/doc/rrdinfo.pod | 1 + program/src/rrd_format.c | 13 +++++++++++++ program/src/rrd_info.c | 3 +++ program/src/rrd_open.c | 10 +--------- program/src/rrd_tool.h | 2 ++ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/program/doc/rrdinfo.pod b/program/doc/rrdinfo.pod index 00e5d165..d147756c 100644 --- a/program/doc/rrdinfo.pod +++ b/program/doc/rrdinfo.pod @@ -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 diff --git a/program/src/rrd_format.c b/program/src/rrd_format.c index 4e53e196..b7e3eff8 100644 --- a/program/src/rrd_format.c +++ b/program/src/rrd_format.c @@ -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; +} diff --git a/program/src/rrd_info.c b/program/src/rrd_info.c index 174bf1ab..9b2363f8 100644 --- a/program/src/rrd_info.c +++ b/program/src/rrd_info.c @@ -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; diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index f74c6d8a..42426c6e 100644 --- a/program/src/rrd_open.c +++ b/program/src/rrd_open.c @@ -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++) diff --git a/program/src/rrd_tool.h b/program/src/rrd_tool.h index f58cd784..c1c97284 100644 --- a/program/src/rrd_tool.h +++ b/program/src/rrd_tool.h @@ -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); -- 2.30.2