Fixing ghost devices in Unifi
This commit is contained in:
parent
ff5cf755aa
commit
e6583918c1
68
unifi.go
68
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user