From 34cfe3a3f2bdf13994a2a166e970e6b255368afb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 26 Jan 2020 17:33:43 -0500 Subject: add timestamp type --- rrdformat/format.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'rrdformat/format.go') diff --git a/rrdformat/format.go b/rrdformat/format.go index 7ea15b7..4e68b93 100644 --- a/rrdformat/format.go +++ b/rrdformat/format.go @@ -12,6 +12,8 @@ import ( const XMLNS = "https://oss.oetiker.ch/rrdtool/rrdtool-dump.xml" +type RRDValue = rrdbinary.Float + // rrdtool: // rrd_format.h: stat_head_t -- static header of the database // @@ -39,16 +41,30 @@ type RRADef struct { PDPCnt rrdBinary.Uint } -type LiveHead struct { - +type PDPPrep struct { + LastDS rrdbinary.String `rrdbinary:"size=30"` + Scratch [10]rrdbinary.Unival +} + +type CDPPrep struct { + Scratch [10]rrdbinary.Unival +} + +type RRAPtr struct { + CurRow rrdbinary.Uint } // rrdtool: // rrd_format.h: rrd_t One single struct to hold all the others. type RRD struct { - DSDefs []DSDef - RRADefs []RRADef - LiveHead LiveHead + Header Header + DSDefs []DSDef + RRADefs []RRADef + LastUpdated rrdbinary.Timesstamp + PDPPrep TODO + CPDPrep TODO + RRAPtr TODO + Values []RRDValue } type Header struct { @@ -102,7 +118,6 @@ func (h *Header) UnmarshalBinary(data []byte) error { // Assume IEEE 754 doubles. C doesn't assume 754 doubles, but anything that doesn't use 754 doubles is exotic // enough that I'm OK saying "you're going to need to use `rrdtool dump`". This lets us assume that: // - a 'double' is 8 bytes wide - // - the value will be exactly equal, and we don't need to worry about weird rounding. h.FloatWidth = 8 magicFloat := float64(8.642135e130) -- cgit v1.2.3