[TASK] publish statistics (e.g. websocket)

This commit is contained in:
Martin Geno 2017-05-08 19:49:18 +02:00
parent 7de61d62fb
commit 9579f62815
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
1 changed files with 11 additions and 3 deletions

View File

@ -25,14 +25,18 @@ type Node struct {
Wireless data.Wireless `json:"wireless"`
Owner string `json:"owner"`
Address net.IP `json:"address"`
Stats struct {
Wireless data.WirelessStatistics `json:"wireless"`
Clients data.Clients `json:"clients"`
} `json:"statistics"`
}
func NewNode(node *yanicRuntime.Node) *Node {
if nodeinfo := node.Nodeinfo; nodeinfo != nil {
func NewNode(nodeOrigin *yanicRuntime.Node) *Node {
if nodeinfo := nodeOrigin.Nodeinfo; nodeinfo != nil {
node := &Node{
Hostname: nodeinfo.Hostname,
NodeID: nodeinfo.NodeID,
Address: node.Address,
Address: nodeOrigin.Address,
}
if owner := nodeinfo.Owner; owner != nil {
node.Owner = owner.Contact
@ -43,6 +47,10 @@ func NewNode(node *yanicRuntime.Node) *Node {
if wireless := nodeinfo.Wireless; wireless != nil {
node.Wireless = *wireless
}
if stats := nodeOrigin.Statistics; stats != nil {
node.Stats.Clients = stats.Clients
node.Stats.Wireless = stats.Wireless
}
return node
}
return nil