Add nil checks
This commit is contained in:
parent
8317e9d2ef
commit
406a1383b9
|
|
@ -10,6 +10,9 @@ import (
|
||||||
// UAPPoints generates Wireless-Access-Point datapoints for InfluxDB.
|
// UAPPoints generates Wireless-Access-Point datapoints for InfluxDB.
|
||||||
// These points can be passed directly to influx.
|
// These points can be passed directly to influx.
|
||||||
func UAPPoints(u *unifi.UAP, now time.Time) ([]*influx.Point, error) {
|
func UAPPoints(u *unifi.UAP, now time.Time) ([]*influx.Point, error) {
|
||||||
|
if u.Stat.Ap == nil {
|
||||||
|
u.Stat.Ap = &unifi.Ap{}
|
||||||
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,12 @@ import (
|
||||||
// UDMPoints generates Unifi Gateway datapoints for InfluxDB.
|
// UDMPoints generates Unifi Gateway datapoints for InfluxDB.
|
||||||
// These points can be passed directly to influx.
|
// These points can be passed directly to influx.
|
||||||
func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
|
if u.Stat.Sw == nil {
|
||||||
|
u.Stat.Sw = &unifi.Sw{}
|
||||||
|
}
|
||||||
|
if u.Stat.Gw == nil {
|
||||||
|
u.Stat.Gw = &unifi.Gw{}
|
||||||
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ import (
|
||||||
// USGPoints generates Unifi Gateway datapoints for InfluxDB.
|
// USGPoints generates Unifi Gateway datapoints for InfluxDB.
|
||||||
// These points can be passed directly to influx.
|
// These points can be passed directly to influx.
|
||||||
func USGPoints(u *unifi.USG, now time.Time) ([]*influx.Point, error) {
|
func USGPoints(u *unifi.USG, now time.Time) ([]*influx.Point, error) {
|
||||||
|
if u.Stat.Gw == nil {
|
||||||
|
u.Stat.Gw = &unifi.Gw{}
|
||||||
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ import (
|
||||||
// USWPoints generates Unifi Switch datapoints for InfluxDB.
|
// USWPoints generates Unifi Switch datapoints for InfluxDB.
|
||||||
// These points can be passed directly to influx.
|
// These points can be passed directly to influx.
|
||||||
func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
||||||
|
if u.Stat.Sw == nil {
|
||||||
|
u.Stat.Sw = &unifi.Sw{}
|
||||||
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": u.ID,
|
"id": u.ID,
|
||||||
"mac": u.Mac,
|
"mac": u.Mac,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue