Dont´t output empty fields in struct
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-02-13 19:12:28 +01:00
parent efd3ba1520
commit 7e1841a244
2 changed files with 24 additions and 24 deletions

View File

@ -108,7 +108,7 @@ func processUcAPIs() ([]node, []link) {
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
var model = lookupModels(currentDevice.Model)
nodes = append(nodes, node{ nodes = append(nodes, node{
Firstseen: "0", Firstseen: "0",
Lastseen: time.Unix(int64(currentDevice.LastSeen), 0).Format(iso8601), Lastseen: time.Unix(int64(currentDevice.LastSeen), 0).Format(iso8601),
@ -140,7 +140,7 @@ func processUcAPIs() ([]node, []link) {
Branch: "stable", Branch: "stable",
}, },
NProc: 1, NProc: 1,
Model: lookupModels(currentDevice.Model), Model: model,
}) })
} }
return nodes, links return nodes, links

View File

@ -97,34 +97,34 @@ type link struct {
} }
type node struct { type node struct {
Firstseen string `json:"firstseen"` Firstseen string `json:"firstseen,omitempty"`
Lastseen string `json:"lastseen"` Lastseen string `json:"lastseen,omitempty"`
IsOnline bool `json:"is_online"` IsOnline bool `json:"is_online,omitempty"`
IsGateway bool `json:"is_gateway"` IsGateway bool `json:"is_gateway,omitempty"`
Clients int `json:"clients"` Clients int `json:"clients,omitempty"`
ClientsWifi24 int `json:"clients_wifi24"` ClientsWifi24 int `json:"clients_wifi24,omitempty"`
ClientsWifi5 int `json:"clients_wifi5"` ClientsWifi5 int `json:"clients_wifi5,omitempty"`
ClientsOther int `json:"clients_other"` ClientsOther int `json:"clients_other,omitempty"`
RootFSUsage int `json:"rootfs_usage"` RootFSUsage int `json:"rootfs_usage,omitempty"`
LoadAVG float64 `json:"loadavg"` LoadAVG float64 `json:"loadavg,omitempty"`
MemoryUsage float64 `json:"memory_usage"` MemoryUsage float64 `json:"memory_usage,omitempty"`
Uptime string `json:"uptime"` Uptime string `json:"uptime,omitempty"`
GatewayNexthop string `json:"gateway_nexthop"` GatewayNexthop string `json:"gateway_nexthop,omitempty"`
Gateway string `json:"gateway"` Gateway string `json:"gateway,omitempty"`
Location *struct { Location *struct {
Longitude float64 `json:"longitude"` Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"` Latitude float64 `json:"latitude"`
} `json:"location,omitempty"` } `json:"location,omitempty"`
NodeID string `json:"node_id"` NodeID string `json:"node_id,omitempty"`
MAC string `json:"mac"` MAC string `json:"mac,omitempty"`
Adresses []string `json:"addresses"` Adresses []string `json:"addresses,omitempty"`
Domain string `json:"domain"` Domain string `json:"domain,omitempty"`
Hostname string `json:"hostname"` Hostname string `json:"hostname,omitempty"`
Owner string `json:"owner"` Owner string `json:"owner,omitempty"`
Firmware firmware `json:"firmware"` Firmware firmware `json:"firmware"`
Autoupdater autoupdater `json:"autoupdater"` Autoupdater autoupdater `json:"autoupdater"`
NProc int `json:"nproc"` NProc int `json:"nproc,omitempty"`
Model string `json:"model"` Model string `json:"model,omitempty"`
} }
type firmware struct { type firmware struct {