X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=sysdb%2Fstore.go;h=ffe55d586ba01736e45d0265871184fef8c99832;hb=8aa0c769b5124f4a0f59fa0b05ecdd096fbab16e;hp=9d90497266cd33b6fe9b7c94496d64a95b571b1a;hpb=72a60afdded7d2751bfdc392931e96ec70dfa852;p=sysdb%2Fgo.git diff --git a/sysdb/store.go b/sysdb/store.go index 9d90497..ffe55d5 100644 --- a/sysdb/store.go +++ b/sysdb/store.go @@ -40,6 +40,9 @@ const jsonTime = `"2006-01-02 15:04:05 -0700"` // sequence of decimal numbers with a unit suffix). type Duration time.Duration +// Common durations. All values greater than or equal to a day are not exact +// values but subject to daylight savings time changes, leap years, etc. They +// are available mostly for providing human readable display formats. const ( Second = Duration(1000000000) Minute = 60 * Second @@ -49,8 +52,8 @@ const ( Year = Duration(3652425 * 24 * 60 * 60 * 100000) ) -// MarshalJSON implements the json.Marshaler interface. The time is a quoted -// string in the SysDB JSON format. +// MarshalJSON implements the json.Marshaler interface. The duration is a +// quoted string in the SysDB JSON format. func (d Duration) MarshalJSON() ([]byte, error) { if d == 0 { return []byte(`"0s"`), nil @@ -177,6 +180,8 @@ func (d Duration) String() string { return time.Duration(d).String() } // (YYYY-MM-DD hh:mm:ss +-zzzz). type Time time.Time +// MarshalJSON implements the json.Marshaler interface. The time is a quoted +// string in the SysDB JSON format. func (t Time) MarshalJSON() ([]byte, error) { return []byte(time.Time(t).Format(jsonTime)), nil } @@ -205,6 +210,7 @@ type Attribute struct { Value string `json:"value"` LastUpdate Time `json:"last_update"` UpdateInterval Duration `json:"update_interval"` + Backends []string `json:"backends"` } // A Metric describes a metric known to SysDB. @@ -212,6 +218,7 @@ type Metric struct { Name string `json:"name"` LastUpdate Time `json:"last_update"` UpdateInterval Duration `json:"update_interval"` + Backends []string `json:"backends"` Attributes []Attribute `json:"attributes"` } @@ -220,6 +227,7 @@ type Service struct { Name string `json:"name"` LastUpdate Time `json:"last_update"` UpdateInterval Duration `json:"update_interval"` + Backends []string `json:"backends"` Attributes []Attribute `json:"attributes"` } @@ -228,6 +236,7 @@ type Host struct { Name string `json:"name"` LastUpdate Time `json:"last_update"` UpdateInterval Duration `json:"update_interval"` + Backends []string `json:"backends"` Attributes []Attribute `json:"attributes"` Metrics []Metric `json:"metrics"` Services []Service `json:"services"` @@ -236,14 +245,14 @@ type Host struct { // A DataPoint describes a datum at a certain point of time. type DataPoint struct { Timestamp Time `json:"timestamp"` - Value float64 `json:"value"` + Value float64 `json:"value,string"` } // A Timeseries describes a sequence of data-points. type Timeseries struct { - Start Time `json:"start"` - End Time `json:"end"` - Data map[string][]DataPoint + Start Time `json:"start"` + End Time `json:"end"` + Data map[string][]DataPoint `json:"data"` } // vim: set tw=78 sw=4 sw=4 noexpandtab :