Tidy things up
This commit is contained in:
parent
926153b8e7
commit
16dd56e320
4
main.go
4
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 {
|
||||
|
@ -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
|
||||
|
12
unifi.go
12
unifi.go
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user