summaryrefslogtreecommitdiff
path: root/rrdformat
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2020-02-01 09:50:23 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2020-02-01 09:50:23 -0500
commita14b9983db45f7b20a654d85ca580bc729e20874 (patch)
treee92b7f76d879965c25f01b34b9b23c5a8fd5c872 /rrdformat
parent65a401ccf7dd37474868e122393db8bee7ce3c4d (diff)
wip xml
Diffstat (limited to 'rrdformat')
-rw-r--r--rrdformat/format.go17
-rw-r--r--rrdformat/marshal_xml.go7
-rw-r--r--rrdformat/unmarshal_binary.go12
3 files changed, 25 insertions, 11 deletions
diff --git a/rrdformat/format.go b/rrdformat/format.go
index a2d95af..8277089 100644
--- a/rrdformat/format.go
+++ b/rrdformat/format.go
@@ -52,17 +52,18 @@ type Header struct {
}
type DSDef struct {
- DSName rrdbinary.String `rrdbinary:"size=20"`
- DSType rrdbinary.String `rrdbinary:"size=20"`
- Parameters [10]rrdbinary.Unival
+ DSName rrdbinary.String `rrdbinary:"size=20" xml:"name"`
+ DSType rrdbinary.String `rrdbinary:"size=20" xml:"type"`
+ Parameters [10]rrdbinary.Unival `xml:"params>item"`
}
type RRADef struct {
- CFName rrdbinary.String `rrdbinary:"size=20"`
- RowCnt rrdbinary.Uint
- PDPCnt rrdbinary.Uint
- Parameters [10]rrdbinary.Unival
- Values []Value `rrdbinary:"-"`
+ CFName rrdbinary.String `rrdbinary:"size=20" xml:"cf"`
+ RowCnt rrdbinary.Uint `xml:"-"`
+ PDPCnt rrdbinary.Uint `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 {
diff --git a/rrdformat/marshal_xml.go b/rrdformat/marshal_xml.go
index d81c6cc..fb6c9e1 100644
--- a/rrdformat/marshal_xml.go
+++ b/rrdformat/marshal_xml.go
@@ -50,6 +50,13 @@ func (rrd RRDv0005) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
}
}
+ // 4. Round Robin Archives
+ for _, rra := range rrd.RRADefs {
+ if err := e.EncodeElement(rra, xmlStart("rra")); err != nil {
+ return err
+ }
+ }
+
if err := e.EncodeToken(start.End()); err != nil {
return err
}
diff --git a/rrdformat/unmarshal_binary.go b/rrdformat/unmarshal_binary.go
index bd4c005..67dc4ff 100644
--- a/rrdformat/unmarshal_binary.go
+++ b/rrdformat/unmarshal_binary.go
@@ -44,10 +44,16 @@ func (rrd *RRD) UnmarshalBinary(data []byte) error {
}
vals := make([]Value, val_cnt)
parsed.Values = vals
- for i := range parsed.RRADefs {
- parsed.RRADefs[i].Values = vals[:parsed.RRADefs[i].RowCnt*parsed.Header.DSCnt]
- vals = vals[parsed.RRADefs[i].RowCnt*parsed.Header.DSCnt:]
+ // set up some of pointers
+ for rra_i := range parsed.RRADefs {
+ parsed.RRADefs[rra_i].CDPPrep = &parsed.CDPPreps[rra_i]
+ parsed.RRADefs[rra_i].Database = make([][]Value, parsed.RRADefs[rra_i].RowCnt)
+ for row_i := 0; row_i < int(parsed.RRADefs[rra_i].RowCnt); row_i++ {
+ parsed.RRADefs[rra_i].Database[row_i] = vals[:parsed.Header.DSCnt]
+ vals = vals[parsed.Header.DSCnt:]
+ }
}
+
// resume decoding
var lastUpdatedPtr interface{}
switch parsed.Header.Version {