From abc9e01d3a8dddc6431f4d51c261b6a12a6f6bec Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Thu, 29 Apr 2021 20:28:28 +0200 Subject: [PATCH] Bugfixing error on empty Load or Memory --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 0e0bb20..4607828 100644 --- a/main.go +++ b/main.go @@ -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