Fix pointer mismatch.
This commit is contained in:
parent
3b3bbeb9d2
commit
9d619f3ff5
|
|
@ -8,7 +8,8 @@ import (
|
|||
)
|
||||
|
||||
// Points generates a client's datapoints for InfluxDB.
|
||||
func (u UCL) Points() (points []*influx.Point, err error) {
|
||||
func (u UCL) Points() ([]*influx.Point, error) {
|
||||
var points []*influx.Point
|
||||
if u.Name == "" && u.Hostname != "" {
|
||||
u.Name = u.Hostname
|
||||
} else if u.Hostname == "" && u.Name != "" {
|
||||
|
|
@ -95,6 +96,9 @@ func (u UCL) Points() (points []*influx.Point, err error) {
|
|||
"wired-tx_bytes-r": u.WiredTxBytesR,
|
||||
"wired-tx_packets": u.WiredTxPackets,
|
||||
}
|
||||
points[0], err = influx.NewPoint("clients", tags, fields, time.Now())
|
||||
return
|
||||
pt, err := influx.NewPoint("clients", tags, fields, time.Now())
|
||||
if err == nil {
|
||||
points = append(points, pt)
|
||||
}
|
||||
return points, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (c *AuthedReq) GetUnifiClients() ([]UCL, error) {
|
|||
return nil, err
|
||||
} else if body, err := ioutil.ReadAll(resp.Body); err != nil {
|
||||
return nil, err
|
||||
} else if err = json.Unmarshal(body, response); err != nil {
|
||||
} else if err = json.Unmarshal(body, &response); err != nil {
|
||||
return nil, err
|
||||
} else if err = resp.Body.Close(); err != nil {
|
||||
log.Println("resp.Body.Close():", err) // Not fatal? Just log it.
|
||||
|
|
@ -95,17 +95,17 @@ func (c *AuthedReq) GetUnifiDevices() ([]USG, []USW, []UAP, error) {
|
|||
// Unmarshal again into the correct type..
|
||||
switch assetType {
|
||||
case "uap":
|
||||
if err := json.Unmarshal(r, uap); err != nil {
|
||||
if err := json.Unmarshal(r, &uap); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
uaps = append(uaps, uap)
|
||||
case "ugw", "usg": // in case they ever fix the name in the api.
|
||||
if err := json.Unmarshal(r, usg); err != nil {
|
||||
if err := json.Unmarshal(r, &usg); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
usgs = append(usgs, usg)
|
||||
case "usw":
|
||||
if err := json.Unmarshal(r, usw); err != nil {
|
||||
if err := json.Unmarshal(r, &usw); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
usws = append(usws, usw)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import (
|
|||
)
|
||||
|
||||
// Points generates a device's datapoints for InfluxDB.
|
||||
func (u USG) Points() (points []*influx.Point, err error) {
|
||||
func (u USG) Points() ([]*influx.Point, error) {
|
||||
var points []*influx.Point
|
||||
tags := map[string]string{
|
||||
"id": u.ID,
|
||||
"mac": u.Mac,
|
||||
|
|
@ -117,6 +118,9 @@ func (u USG) Points() (points []*influx.Point, err error) {
|
|||
"wan-tx_bytes": u.Stat.WanTxBytes,
|
||||
"wan-tx_packets": u.Stat.WanTxPackets,
|
||||
}
|
||||
points[0], err = influx.NewPoint("usg", tags, fields, time.Now())
|
||||
return
|
||||
pt, err := influx.NewPoint("usg", tags, fields, time.Now())
|
||||
if err == nil {
|
||||
points = append(points, pt)
|
||||
}
|
||||
return points, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import (
|
|||
)
|
||||
|
||||
// Points generates a device's datapoints for InfluxDB.
|
||||
func (u USW) Points() (points []*influx.Point, err error) {
|
||||
func (u USW) Points() ([]*influx.Point, error) {
|
||||
var points []*influx.Point
|
||||
tags := map[string]string{
|
||||
"id": u.ID,
|
||||
"mac": u.Mac,
|
||||
|
|
@ -109,6 +110,9 @@ func (u USW) Points() (points []*influx.Point, err error) {
|
|||
"stat_tx_retries": u.Stat.TxRetries,
|
||||
// Add the port stats too.
|
||||
}
|
||||
points[0], err = influx.NewPoint("usw", tags, fields, time.Now())
|
||||
return
|
||||
pt, err := influx.NewPoint("usw", tags, fields, time.Now())
|
||||
if err == nil {
|
||||
points = append(points, pt)
|
||||
}
|
||||
return points, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue