add owner (as tag)
This commit is contained in:
parent
93fe0fadb5
commit
c13185fd51
6
main.go
6
main.go
@ -97,6 +97,10 @@ func onReceive(addr net.UDPAddr, res *data.ResponseData) {
|
||||
nodes.Update(nodeId, res)
|
||||
|
||||
if val := res.Statistics; val != nil && statsDb != nil {
|
||||
statsDb.Add(val)
|
||||
if node := res.NodeInfo; val != nil && statsDb != nil {
|
||||
statsDb.Add(val, node)
|
||||
} else {
|
||||
statsDb.Add(val, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ type Alias struct {
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
Location *data.Location `json:"location,omitempty"`
|
||||
Wireless *data.Wireless `json:"wireless,omitempty"`
|
||||
Owner string `json:"owner,omitempty"`
|
||||
}
|
||||
|
||||
// Nodes struct: cache DB of Node's structs
|
||||
|
@ -44,10 +44,14 @@ func NewStatsDb() *StatsDb {
|
||||
return db
|
||||
}
|
||||
|
||||
func (c *StatsDb) Add(stats *data.Statistics) {
|
||||
func (c *StatsDb) Add(stats *data.Statistics, node *data.NodeInfo) {
|
||||
tags := map[string]string{
|
||||
"nodeid": stats.NodeId,
|
||||
}
|
||||
// Maybe a If
|
||||
if owner := node.Owner; owner != nil {
|
||||
tags["owner"] = owner.Contact
|
||||
}
|
||||
fields := map[string]interface{}{
|
||||
"load": stats.LoadAverage,
|
||||
"idletime": int64(stats.Idletime),
|
||||
|
Loading…
Reference in New Issue
Block a user