1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
package rrdformat
import (
"time"
"git.lukeshu.com/go/librrd/rrdformat/rrdbinary"
)
// File format versions:
//
// For the most part, the layout of the file format hasn't
// changed--the version number just indicates which enum members you
// need to support. The only parser-breaking change is that the
// 0002->0003 transition added a few bytes to the timestamp, in order
// to go from second-precision to microsecond-precision.
//
// - "0005" (added in rrdtool 1.5.0, 2015-04-16)
// * added DST_DCOUNTER
// * added DST_DDERIVE
// * otherwise identical to "0004"
//
// - "0004" (added in rrdtool 1.3.0, 2008-06-10)
// * added MHWPREDICT function
// * otherwise identical to "0003"
//
// - "0003" (added in the unreleased rrdtool 1.1.x in 2003,
// present in rrdtool 1.2.0, 2005-04-25)
// * last-updated timestamp gained a `long` microsecond component
// * otherwise identical to "0002"
//
// - "0002" (never used by a stable release of rrdtool, but was used
// by development versions of 1.1.x 2001-2003)
// * added DST_CDEF
// * added CF_HWPREDICT
// * added CF_SEASONAL
// * added CF_DEVPREDICT
// * added CF_DEVSEASONAL
// * 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
type Header struct {
Cookie rrdbinary.String `rrdbinary:"size=4" xml:"-"`
Version rrdbinary.String `rrdbinary:"size=5" xml:"version"`
FloatCookie rrdbinary.Double `xml:"-"`
DSCnt rrdbinary.ULong `xml:"-"`
RRACnt rrdbinary.ULong `xml:"-"`
PDPStep rrdbinary.ULong `xml:"step"`
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"`
Parameters [10]rrdbinary.Unival `xml:"params>item"`
}
const (
DSParam_MRHBCnt = iota // Minimum Required HeatBeat Count
DSParam_MinVal
DSParam_MaxVal
// When DSType==DST_CDEF, none of the above are used, and the
// parameters are instead interpretted with .AsRPNTokens().
)
type RRADef struct {
CFName rrdbinary.String `rrdbinary:"size=20" xml:"cf"`
RowCnt rrdbinary.ULong `xml:"-"`
PDPCnt rrdbinary.ULong `xml:"pdp_per_row"`
Parameters [10]rrdbinary.Unival `xml:"params>item"`
CDPPrep *CDPPrep `rrdbinary:"-" xml:"cdp_prep"`
Database [][]Value `rrdbinary:"-" xml:"database>row>v"`
}
type TimeWithUsec struct {
Sec rrdbinary.Time
Usec rrdbinary.Long // signed, but always >= 0 (version >= RRD_VERSION3)
}
func (ts TimeWithUsec) Time() time.Time {
return time.Unix(int64(ts.Sec), int64(ts.Usec)*1000)
}
type PDPPrep struct {
LastDS rrdbinary.String `rrdbinary:"size=30"`
Scratch [10]rrdbinary.Unival
}
const (
PDPScratch_UnknownSecCnt = iota
PDPScratch_Value
)
type CDPPrep struct {
Scratch [10]rrdbinary.Unival
}
type RRAPtr struct {
CurRow rrdbinary.ULong
}
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
}
|