From: oetiker Date: Mon, 20 Apr 2009 06:46:47 +0000 (+0000) Subject: introduced header_property in info output -- Daniel.Pocock barclayscapital.com X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=commitdiff_plain;h=1d0d1678df2083bc996d579e0c5d0cc46fff6745 introduced header_property in info output -- Daniel.Pocock barclayscapital.com git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1795 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/doc/rrdinfo.pod b/doc/rrdinfo.pod index 00e5d16..d147756 100644 --- a/doc/rrdinfo.pod +++ b/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/src/rrd_format.c b/src/rrd_format.c index 4e53e19..b7e3eff 100644 --- a/src/rrd_format.c +++ b/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/src/rrd_info.c b/src/rrd_info.c index 174bf1a..9b2363f 100644 --- a/src/rrd_info.c +++ b/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/src/rrd_open.c b/src/rrd_open.c index f74c6d8..42426c6 100644 --- a/src/rrd_open.c +++ b/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/src/rrd_tool.h b/src/rrd_tool.h index f58cd78..c1c9728 100644 --- a/src/rrd_tool.h +++ b/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);