netmaker/models/metrics.go

51 lines
2.2 KiB
Go
Raw Normal View History

2022-09-14 03:25:56 +08:00
package models
2022-12-08 16:50:50 +08:00
import (
"time"
)
2022-09-14 03:25:56 +08:00
// Metrics - metrics struct
type Metrics struct {
2023-01-11 13:31:22 +08:00
Network string `json:"network" bson:"network" yaml:"network"`
NodeID string `json:"node_id" bson:"node_id" yaml:"node_id"`
NodeName string `json:"node_name" bson:"node_name" yaml:"node_name"`
Connectivity map[string]Metric `json:"connectivity" bson:"connectivity" yaml:"connectivity"`
FailoverPeers map[string]string `json:"needsfailover" bson:"needsfailover" yaml:"needsfailover"`
2022-09-14 03:25:56 +08:00
}
// Metric - holds a metric for data between nodes
type Metric struct {
NodeName string `json:"node_name" bson:"node_name" yaml:"node_name"`
Uptime int64 `json:"uptime" bson:"uptime" yaml:"uptime"`
TotalTime int64 `json:"totaltime" bson:"totaltime" yaml:"totaltime"`
Latency int64 `json:"latency" bson:"latency" yaml:"latency"`
TotalReceived int64 `json:"totalreceived" bson:"totalreceived" yaml:"totalreceived"`
TotalSent int64 `json:"totalsent" bson:"totalsent" yaml:"totalsent"`
ActualUptime time.Duration `json:"actualuptime" bson:"actualuptime" yaml:"actualuptime"`
PercentUp float64 `json:"percentup" bson:"percentup" yaml:"percentup"`
Connected bool `json:"connected" bson:"connected" yaml:"connected"`
}
// IDandAddr - struct to hold ID and primary Address
type IDandAddr struct {
ID string `json:"id" bson:"id" yaml:"id"`
Address string `json:"address" bson:"address" yaml:"address"`
Name string `json:"name" bson:"name" yaml:"name"`
IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
2023-01-04 12:34:17 +08:00
Network string `json:"network" bson:"network" yaml:"network" validate:"network"`
2022-09-14 03:25:56 +08:00
}
// PeerMap - peer map for ids and addresses in metrics
type PeerMap map[string]IDandAddr
2023-01-06 23:57:40 +08:00
// HostPeerMap - host peer map for ids and addresses
2023-01-04 12:34:17 +08:00
type HostPeerMap map[string]map[string]IDandAddr
2022-09-14 03:25:56 +08:00
// MetricsMap - map for holding multiple metrics in memory
type MetricsMap map[string]Metrics
// NetworkMetrics - metrics model for all nodes in a network
type NetworkMetrics struct {
Nodes MetricsMap `json:"nodes" bson:"nodes" yaml:"nodes"`
}