Bugfixing error on empty Load or Memory
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Stefan Hoffmann 2021-04-29 20:28:28 +02:00
parent 3f0d6fc3d4
commit abc9e01d3a

10
main.go
View File

@ -26,7 +26,7 @@ const (
// flags
var configPath = flag.String("configPath", "config.json", "Path to config.json")
var version = "development"
var delay time.Duration = 60 * time.Second
var delay time.Duration = 5 * time.Second
var conf = loadconfig(*configPath)
var ucDev = getDevices(conf.Unifi.UCDevicesURL)
@ -100,14 +100,16 @@ func processUcAPIs() ([]node, []link) {
if isRemoteMACpublished(jsonDevice.MAC, d.Devices) == true {
links = ucAddLink(jsonDevice, links)
}
load, err := strconv.ParseFloat(currentDevice.Sysstats.CPU, 64)
if err != nil {
log.Fatalln(err)
fmt.Println("Error: ", currentDevice.Name)
//log.Fatalln(err)
load = 0
}
mem, err := strconv.ParseFloat(currentDevice.Sysstats.Memory, 64)
if err != nil {
log.Fatalln(err)
//log.Fatalln(err)
load = 0
}
var model = lookupModels(currentDevice.Model)
var clients = currentDevice.Users