Compare commits
2 Commits
2a28bb7498
...
efd3ba1520
Author | SHA1 | Date | |
---|---|---|---|
|
efd3ba1520 | ||
|
e9615b3637 |
109
main.go
109
main.go
@ -25,7 +25,7 @@ const (
|
|||||||
// flags
|
// flags
|
||||||
var configPath = flag.String("configPath", "config.json", "Path to config.json")
|
var configPath = flag.String("configPath", "config.json", "Path to config.json")
|
||||||
var version = "development"
|
var version = "development"
|
||||||
var delay time.Duration = 60 * time.Second
|
var delay time.Duration = 5 * time.Second
|
||||||
var conf = loadconfig(*configPath)
|
var conf = loadconfig(*configPath)
|
||||||
var ucDev = getDevices(conf.Unifi.UCDevicesURL)
|
var ucDev = getDevices(conf.Unifi.UCDevicesURL)
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ func processUcAPIs() ([]node, []link) {
|
|||||||
Uptime: time.Now().Add(-1 * time.Second * time.Duration(currentDevice.Uptime)).Format(iso8601),
|
Uptime: time.Now().Add(-1 * time.Second * time.Duration(currentDevice.Uptime)).Format(iso8601),
|
||||||
GatewayNexthop: currentJSONDevice.GatewayNexthop,
|
GatewayNexthop: currentJSONDevice.GatewayNexthop,
|
||||||
Gateway: currentJSONDevice.Gateway,
|
Gateway: currentJSONDevice.Gateway,
|
||||||
Location: currentJSONDevice.Location,
|
Location: ¤tJSONDevice.Location,
|
||||||
NodeID: strings.ReplaceAll(currentDevice.Mac, ":", ""),
|
NodeID: strings.ReplaceAll(currentDevice.Mac, ":", ""),
|
||||||
MAC: currentDevice.Mac,
|
MAC: currentDevice.Mac,
|
||||||
Adresses: []string{currentDevice.IP},
|
Adresses: []string{currentDevice.IP},
|
||||||
@ -212,7 +212,7 @@ func processUNMSAPI() ([]node, []link) {
|
|||||||
Uptime: dev.Identification.Started.Format(iso8601),
|
Uptime: dev.Identification.Started.Format(iso8601),
|
||||||
GatewayNexthop: currentDevice.GatewayNexthop,
|
GatewayNexthop: currentDevice.GatewayNexthop,
|
||||||
Gateway: currentDevice.Gateway,
|
Gateway: currentDevice.Gateway,
|
||||||
Location: currentDevice.Location,
|
Location: ¤tDevice.Location,
|
||||||
NodeID: strings.ReplaceAll(dev.Identification.MAC, ":", ""),
|
NodeID: strings.ReplaceAll(dev.Identification.MAC, ":", ""),
|
||||||
MAC: dev.Identification.MAC,
|
MAC: dev.Identification.MAC,
|
||||||
Adresses: getAddresses(details.IPAddress),
|
Adresses: getAddresses(details.IPAddress),
|
||||||
@ -513,39 +513,76 @@ func addmvDevices(d mvDevices) ([]node, []link) {
|
|||||||
mvNode.ClientsWifi5 = 0
|
mvNode.ClientsWifi5 = 0
|
||||||
mvNode.ClientsOther = 0
|
mvNode.ClientsOther = 0
|
||||||
}
|
}
|
||||||
nodes = append(nodes, node{
|
if mvNode.Location.Latitude == 0 {
|
||||||
Firstseen: mvNode.Firstseen,
|
nodes = append(nodes, node{
|
||||||
Lastseen: mvNode.Lastseen,
|
Firstseen: mvNode.Firstseen,
|
||||||
IsOnline: mvNode.IsOnline,
|
Lastseen: mvNode.Lastseen,
|
||||||
IsGateway: mvNode.IsGateway,
|
IsOnline: mvNode.IsOnline,
|
||||||
Clients: mvNode.Clients,
|
IsGateway: mvNode.IsGateway,
|
||||||
ClientsWifi24: mvNode.ClientsWifi24,
|
Clients: mvNode.Clients,
|
||||||
ClientsWifi5: mvNode.ClientsWifi5,
|
ClientsWifi24: mvNode.ClientsWifi24,
|
||||||
ClientsOther: mvNode.ClientsOther,
|
ClientsWifi5: mvNode.ClientsWifi5,
|
||||||
RootFSUsage: int(mvNode.RootfsUsage),
|
ClientsOther: mvNode.ClientsOther,
|
||||||
LoadAVG: mvNode.Loadavg,
|
RootFSUsage: int(mvNode.RootfsUsage),
|
||||||
MemoryUsage: mvNode.MemoryUsage,
|
LoadAVG: mvNode.Loadavg,
|
||||||
Uptime: mvNode.Uptime,
|
MemoryUsage: mvNode.MemoryUsage,
|
||||||
GatewayNexthop: mvNode.GatewayNexthop,
|
Uptime: mvNode.Uptime,
|
||||||
Gateway: mvNode.Gateway,
|
GatewayNexthop: mvNode.GatewayNexthop,
|
||||||
Location: mvNode.Location,
|
Gateway: mvNode.Gateway,
|
||||||
NodeID: mvNode.NodeID,
|
NodeID: mvNode.NodeID,
|
||||||
MAC: mvNode.Mac,
|
MAC: mvNode.Mac,
|
||||||
Adresses: mvNode.Addresses,
|
Adresses: mvNode.Addresses,
|
||||||
Domain: mvNode.Domain,
|
Domain: mvNode.Domain,
|
||||||
Hostname: mvNode.Hostname,
|
Hostname: mvNode.Hostname,
|
||||||
Owner: mvNode.Owner,
|
Owner: mvNode.Owner,
|
||||||
Firmware: firmware{
|
Firmware: firmware{
|
||||||
Base: mvNode.Firmware.Base,
|
Base: mvNode.Firmware.Base,
|
||||||
Release: mvNode.Firmware.Release,
|
Release: mvNode.Firmware.Release,
|
||||||
},
|
},
|
||||||
Autoupdater: autoupdater{
|
Autoupdater: autoupdater{
|
||||||
Enabled: mvNode.Autoupdater.Enabled,
|
Enabled: mvNode.Autoupdater.Enabled,
|
||||||
Branch: mvNode.Autoupdater.Branch,
|
Branch: mvNode.Autoupdater.Branch,
|
||||||
},
|
},
|
||||||
NProc: mvNode.Nproc,
|
NProc: mvNode.Nproc,
|
||||||
Model: mvNode.Model,
|
Model: mvNode.Model,
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
if mvNode.Location.Latitude == 0 {
|
||||||
|
nodes = append(nodes, node{
|
||||||
|
Firstseen: mvNode.Firstseen,
|
||||||
|
Lastseen: mvNode.Lastseen,
|
||||||
|
IsOnline: mvNode.IsOnline,
|
||||||
|
IsGateway: mvNode.IsGateway,
|
||||||
|
Clients: mvNode.Clients,
|
||||||
|
ClientsWifi24: mvNode.ClientsWifi24,
|
||||||
|
ClientsWifi5: mvNode.ClientsWifi5,
|
||||||
|
ClientsOther: mvNode.ClientsOther,
|
||||||
|
RootFSUsage: int(mvNode.RootfsUsage),
|
||||||
|
LoadAVG: mvNode.Loadavg,
|
||||||
|
MemoryUsage: mvNode.MemoryUsage,
|
||||||
|
Uptime: mvNode.Uptime,
|
||||||
|
GatewayNexthop: mvNode.GatewayNexthop,
|
||||||
|
Gateway: mvNode.Gateway,
|
||||||
|
Location: &mvNode.Location,
|
||||||
|
NodeID: mvNode.NodeID,
|
||||||
|
MAC: mvNode.Mac,
|
||||||
|
Adresses: mvNode.Addresses,
|
||||||
|
Domain: mvNode.Domain,
|
||||||
|
Hostname: mvNode.Hostname,
|
||||||
|
Owner: mvNode.Owner,
|
||||||
|
Firmware: firmware{
|
||||||
|
Base: mvNode.Firmware.Base,
|
||||||
|
Release: mvNode.Firmware.Release,
|
||||||
|
},
|
||||||
|
Autoupdater: autoupdater{
|
||||||
|
Enabled: mvNode.Autoupdater.Enabled,
|
||||||
|
Branch: mvNode.Autoupdater.Branch,
|
||||||
|
},
|
||||||
|
NProc: mvNode.Nproc,
|
||||||
|
Model: mvNode.Model,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for i := range d.Links {
|
for i := range d.Links {
|
||||||
mvNode := d.Links[i]
|
mvNode := d.Links[i]
|
||||||
|
4
types.go
4
types.go
@ -111,10 +111,10 @@ type node struct {
|
|||||||
Uptime string `json:"uptime"`
|
Uptime string `json:"uptime"`
|
||||||
GatewayNexthop string `json:"gateway_nexthop"`
|
GatewayNexthop string `json:"gateway_nexthop"`
|
||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
Location struct {
|
Location *struct {
|
||||||
Longitude float64 `json:"longitude"`
|
Longitude float64 `json:"longitude"`
|
||||||
Latitude float64 `json:"latitude"`
|
Latitude float64 `json:"latitude"`
|
||||||
} `json:"location"`
|
} `json:"location,omitempty"`
|
||||||
NodeID string `json:"node_id"`
|
NodeID string `json:"node_id"`
|
||||||
MAC string `json:"mac"`
|
MAC string `json:"mac"`
|
||||||
Adresses []string `json:"addresses"`
|
Adresses []string `json:"addresses"`
|
||||||
|
Loading…
Reference in New Issue
Block a user