Compare commits

..

2 Commits

Author SHA1 Message Date
Stefan Hoffmann
631a5e398f Merge branch 'master' of ssh://git.freifunk-rhein-sieg.net:2222/Freifunk-Troisdorf/ubnt-freifunk-map-api
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-09-25 18:34:32 +02:00
Stefan Hoffmann
e6583918c1 Fixing ghost devices in Unifi 2024-09-25 18:33:41 +02:00

View File

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