From b3d7493f5e8b20378ec2e41a10459e4339d538e9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 1 Feb 2020 18:08:43 -0500 Subject: wip --- rrdformat/format.go | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'rrdformat/format.go') diff --git a/rrdformat/format.go b/rrdformat/format.go index d004e86..bb37761 100644 --- a/rrdformat/format.go +++ b/rrdformat/format.go @@ -38,6 +38,13 @@ import ( // * added CF_FAILURES // // - "0001" (the original in rrdtool 1.0.0, 1999-07-15) +const ( + RRD_VERSION1 = "0001" + RRD_VERSION2 = "0002" + RRD_VERSION3 = "0003" + RRD_VERSION4 = "0004" + RRD_VERSION5 = "0005" +) type Value = rrdbinary.Double @@ -51,6 +58,17 @@ type Header struct { Parameters [10]rrdbinary.Unival `xml:"-"` } +// Data Source Types +const ( + DST_COUNTER = "COUNTER" // version >= RRD_VERSION1 + DST_ABSOLUTE = "ABSOLUTE" // version >= RRD_VERSION1 + DST_GAUGE = "GAUGE" // version >= RRD_VERSION1 + DST_DERIVE = "DERIVE" // version >= RRD_VERSION1 + DST_CDEF = "CDEF" // version >= RRD_VERSION2 + DST_DCOUNTER = "DCOUNTER" // version >= RRD_VERSION5 + DST_DDERIV = "DDERIV" // version >= RRD_VERSION5 +) + type DSDef struct { DSName rrdbinary.String `rrdbinary:"size=20" xml:"name"` DSType rrdbinary.String `rrdbinary:"size=20" xml:"type"` @@ -68,7 +86,7 @@ type RRADef struct { type TimeWithUsec struct { Sec rrdbinary.Time - Usec rrdbinary.Long // signed, but always >= 0 + Usec rrdbinary.Long // signed, but always >= 0 (version >= RRD_VERSION3) } func (ts TimeWithUsec) Time() time.Time { @@ -96,29 +114,14 @@ type RRAPtr struct { CurRow rrdbinary.ULong } -type RRDv0005 = RRDv0004 -type RRDv0004 = RRDv0003 - -type RRDv0003 struct { - Header Header - DSDefs []DSDef // .Header.DSCnt - RRADefs []RRADef // .Header.RRACnt - LastUpdated TimeWithUsec - PDPPreps []PDPPrep // .Header.DSCnt - CDPPreps []CDPPrep // .Header.DSCnt * .Header.RRACnt - RRAPtrs []RRAPtr // .Header.RRACnt - Values []Value // Σ .RRADefs[i].RowCnt*.Header.DSCnt -} - -type RRDv0002 = RRDv0001 - -type RRDv0001 struct { - Header Header - DSDefs []DSDef // .Header.DSCnt - RRADefs []RRADef // .Header.RRACnt - LastUpdated TimeWithoutUsec - PDPPreps []PDPPrep // .Header.DSCnt - CDPPreps []CDPPrep // .Header.DSCnt * .Header.RRACnt - RRAPtrs []RRAPtr // .Header.RRACnt - Values []Value // Σ .RRADefs[i].RowCnt*.Header.DSCnt +type RRD struct { + Architecture rrdbinary.Architecture `rrdbinary:"-" xml:"-"` + Header Header + DSDefs []DSDef // .Header.DSCnt + RRADefs []RRADef // .Header.RRACnt + LastUpdated TimeWithUsec + PDPPreps []PDPPrep // .Header.DSCnt + CDPPreps []CDPPrep // .Header.DSCnt * .Header.RRACnt + RRAPtrs []RRAPtr // .Header.RRACnt + Values []Value // Σ .RRADefs[i].RowCnt*.Header.DSCnt } -- cgit v1.2.3