diff --git a/unifi.go b/unifi.go index f00a385..3739b0e 100644 --- a/unifi.go +++ b/unifi.go @@ -133,39 +133,41 @@ func processUnifiAPI(s int) ([]node, []link, error) { // INFLUX STOP //log.Println(currentDevice.Mac) - nodes = append(nodes, node{ - Firstseen: "0", - Lastseen: time.Unix(int64(currentDevice.LastSeen), 0).Format(iso8601), - IsOnline: itob(currentDevice.State), - IsGateway: false, - Clients: clients, - ClientsWifi24: 0, - ClientsWifi5: 0, - ClientsOther: clients, - RootFSUsage: 0, - LoadAVG: load / 100, - MemoryUsage: mem / 100, - Uptime: time.Now().Add(-1 * time.Second * time.Duration(currentDevice.Uptime)).Format(iso8601), - GatewayNexthop: currentJSONDevice.GatewayNexthop, - Gateway: currentJSONDevice.Gateway, - Location: ¤tJSONDevice.Location, - NodeID: strings.ReplaceAll(currentDevice.Mac, ":", ""), - MAC: currentDevice.Mac, - Adresses: []string{currentDevice.IP}, - Domain: currentJSONDevice.Domain, - Hostname: "[Unifi] " + currentDevice.Name, - Owner: "Freifunk Rhein-Sieg", - Firmware: firmware{ - Base: "Ubiquiti - Stock", - Release: currentDevice.Version, - }, - Autoupdater: autoupdater{ - Enabled: false, - Branch: "stable", - }, - NProc: 1, - Model: model, - }) + if currentDevice.Mac != "" { + nodes = append(nodes, node{ + Firstseen: "0", + Lastseen: time.Unix(int64(currentDevice.LastSeen), 0).Format(iso8601), + IsOnline: itob(currentDevice.State), + IsGateway: false, + Clients: clients, + ClientsWifi24: 0, + ClientsWifi5: 0, + ClientsOther: clients, + RootFSUsage: 0, + LoadAVG: load / 100, + MemoryUsage: mem / 100, + Uptime: time.Now().Add(-1 * time.Second * time.Duration(currentDevice.Uptime)).Format(iso8601), + GatewayNexthop: currentJSONDevice.GatewayNexthop, + Gateway: currentJSONDevice.Gateway, + Location: ¤tJSONDevice.Location, + NodeID: strings.ReplaceAll(currentDevice.Mac, ":", ""), + MAC: currentDevice.Mac, + Adresses: []string{currentDevice.IP}, + Domain: currentJSONDevice.Domain, + Hostname: "[Unifi] " + currentDevice.Name, + Owner: "Freifunk Rhein-Sieg", + Firmware: firmware{ + Base: "Ubiquiti - Stock", + Release: currentDevice.Version, + }, + Autoupdater: autoupdater{ + Enabled: false, + Branch: "stable", + }, + NProc: 1, + Model: model, + }) + } } return nodes, links, err }