summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2020-02-03 00:30:45 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2020-02-03 00:30:45 -0500
commit023eae6eda47df078615b46266b01dad056a91ac (patch)
treea5c4ef13f1115e07b1774eb089c8e397cefbf1e1
parentdff188a6157c10ab6745b1a389c925794d6ca1ba (diff)
more
-rw-r--r--rrdformat/format.go8
-rw-r--r--rrdformat/marshal_xml.go23
2 files changed, 28 insertions, 3 deletions
diff --git a/rrdformat/format.go b/rrdformat/format.go
index ca0c459..2dbcb30 100644
--- a/rrdformat/format.go
+++ b/rrdformat/format.go
@@ -75,6 +75,14 @@ type DSDef struct {
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:"-"`
diff --git a/rrdformat/marshal_xml.go b/rrdformat/marshal_xml.go
index cb2db93..8e98d10 100644
--- a/rrdformat/marshal_xml.go
+++ b/rrdformat/marshal_xml.go
@@ -93,13 +93,14 @@ func (ds DSDef) marshalXML(rrd RRD, e *xml.Encoder, start xml.StartElement) erro
if err := e.EncodeToken(start); err != nil {
return err
}
+ // 1. DS Common
if err := e.EncodeElement(" "+ds.DSName+" ", xmlStart("name")); err != nil {
return err
}
if err := e.EncodeElement(" "+ds.DSType+" ", xmlStart("type")); err != nil {
return err
}
-
+ // 2. Parameters
switch ds.DSType {
case DST_CDEF:
var rpnps []rrdbinary.RPNToken
@@ -114,9 +115,25 @@ func (ds DSDef) marshalXML(rrd RRD, e *xml.Encoder, start xml.StartElement) erro
return err
}
default:
-
+ if err := e.EncodeElement(ds.Parameters[DSParam_MRHBCnt].AsULong(), xmlStart("minimal_heartbeat")); err != nil {
+ return err
+ }
+ if err := e.EncodeElement(ds.Parameters[DSParam_MinVal].AsDouble(), xmlStart("min")); err != nil {
+ return err
+ }
+ if err := e.EncodeElement(ds.Parameters[DSParam_MaxVal].AsDouble(), xmlStart("max")); err != nil {
+ return err
+ }
}
-
+ // 3. Comment
+ if err := e.EncodeToken(xml.CharData("\n\n")); err != nil {
+ return err
+ }
+ if err := e.EncodeToken(xml.Comment(" PDP Status ")); err != nil {
+ return err
+ }
+ // 4. TODO
+ // End
if err := e.EncodeToken(start.End()); err != nil {
return err
}