diff --git a/main.go b/main.go index 14505d2..f5e5aa0 100644 --- a/main.go +++ b/main.go @@ -77,11 +77,8 @@ func processAPIs() { } if conf.Unifi.Enabled { log.Println("Processing Unifi") - //ucNodes, ucLinks := processUcAPIs() ucNodes, _ := processUcAPIs() nodes = append(nodes, ucNodes...) - //links = append(links, ucLinks...) - //links = links } if conf.Meshviewer.Enabled { log.Println("Processing Meshviewer") @@ -113,6 +110,7 @@ func processAPIs() { } } +// function to get file from meshviewer func getFile(url string) []byte { resp, err := http.Get(url) if err != nil { diff --git a/meshviewer.go b/meshviewer.go index e3538bb..c77530c 100644 --- a/meshviewer.go +++ b/meshviewer.go @@ -2,7 +2,6 @@ package main import ( "encoding/json" - "fmt" "log" ) @@ -17,7 +16,7 @@ func getMeshviewerJSON(url string) (mvDevices, error) { // unmarshal to struct err := json.Unmarshal(jsonFile, &n) if err != nil { - fmt.Println("can´t get Meshviewer Json file from " + url) + log.Println("can´t get Meshviewer Json file from " + url) log.Println(err) } return n, nil diff --git a/unifi.go b/unifi.go index bd3f090..f31052f 100644 --- a/unifi.go +++ b/unifi.go @@ -12,7 +12,7 @@ import ( "time" ) -//Unifi Controller API processing +// Unifi Controller API processing func processUcAPIs() ([]node, []link) { //get list of Unifi devices to display var nodes []node @@ -26,12 +26,12 @@ func processUcAPIs() ([]node, []link) { //get all Sites from Controller sites, err := ucAPI.ucGetSites() if err != nil { - log.Fatalln(err) + log.Println(err) } //get all devices in all sites devices, err := ucAPI.ucGetDevices(sites) if err != nil { - log.Fatalln(err) + log.Println(err) } //build nodes struct @@ -40,7 +40,7 @@ func processUcAPIs() ([]node, []link) { var currentDevice ucDevice var currentJSONDevice device for _, device := range devices { - if strings.ToUpper(device.Mac) == strings.ToUpper(jsonDevice.MAC) { + if strings.EqualFold(device.Mac, jsonDevice.MAC) { currentDevice = device currentJSONDevice = jsonDevice } @@ -63,9 +63,9 @@ func processUcAPIs() ([]node, []link) { load = 0 } var model = lookupModels(currentDevice.Model) - var clients = currentDevice.Users - if conf.Unifi.DisplayUsers == false { - clients = 0 + var clients int + if conf.Unifi.DisplayUsers { + clients = currentDevice.Users } nodes = append(nodes, node{ Firstseen: "0",