Expose overlay metrics from fastdp
and allow them to pass through OverlaySwitch
This commit is contained in:
1 parent
6d5af85eee
commit
00c86fed42
2 files changed
+38
-5
No files matched your search
+22
-4
@@ -318,6 +318,11 @@ func (fastDatapathOverlay) AddFeaturesTo(features map[string]string) {
|
|||||||
// OverlaySwitch.
|
// OverlaySwitch.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FastDPStatus struct {
|
||||||
|
Vports []VportStatus
|
||||||
|
Flows []FlowStatus
|
||||||
|
}
|
||||||
|
|
||||||
type FlowStatus odp.FlowInfo
|
type FlowStatus odp.FlowInfo
|
||||||
|
|
||||||
func (flowStatus *FlowStatus) MarshalJSON() ([]byte, error) {
|
func (flowStatus *FlowStatus) MarshalJSON() ([]byte, error) {
|
||||||
@@ -374,15 +379,28 @@ func (fastdp fastDatapathOverlay) Diagnostics() interface{} {
|
|||||||
flowStatuses = append(flowStatuses, FlowStatus(flow))
|
flowStatuses = append(flowStatuses, FlowStatus(flow))
|
||||||
}
|
}
|
||||||
|
|
||||||
return struct {
|
return FastDPStatus{
|
||||||
Vports []VportStatus
|
|
||||||
Flows []FlowStatus
|
|
||||||
}{
|
|
||||||
vportStatuses,
|
vportStatuses,
|
||||||
flowStatuses,
|
flowStatuses,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FastDPMetrics struct {
|
||||||
|
Flows int
|
||||||
|
TotalPackets uint64
|
||||||
|
TotalBytes uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s FastDPStatus) Metrics() interface{} {
|
||||||
|
var m FastDPMetrics
|
||||||
|
m.Flows = len(s.Flows)
|
||||||
|
for _, flow := range s.Flows {
|
||||||
|
m.TotalPackets += flow.Packets
|
||||||
|
m.TotalBytes += flow.Bytes
|
||||||
|
}
|
||||||
|
return &m
|
||||||
|
}
|
||||||
|
|
||||||
func (fastdp fastDatapathOverlay) StartConsumingPackets(localPeer *mesh.Peer, peers *mesh.Peers, consumer OverlayConsumer) error {
|
func (fastdp fastDatapathOverlay) StartConsumingPackets(localPeer *mesh.Peer, peers *mesh.Peers, consumer OverlayConsumer) error {
|
||||||
fastdp.lock.Lock()
|
fastdp.lock.Lock()
|
||||||
defer fastdp.lock.Unlock()
|
defer fastdp.lock.Unlock()
|
||||||
|
|||||||
@@ -42,14 +42,29 @@ func (osw *OverlaySwitch) AddFeaturesTo(features map[string]string) {
|
|||||||
features["Overlays"] = strings.Join(osw.overlayNames, " ")
|
features["Overlays"] = strings.Join(osw.overlayNames, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OverlaySwitchDiagnostics map[string]interface{}
|
||||||
|
|
||||||
func (osw *OverlaySwitch) Diagnostics() interface{} {
|
func (osw *OverlaySwitch) Diagnostics() interface{} {
|
||||||
diagnostics := make(map[string]interface{})
|
diagnostics := make(OverlaySwitchDiagnostics)
|
||||||
for name, overlay := range osw.overlays {
|
for name, overlay := range osw.overlays {
|
||||||
diagnostics[name] = overlay.Diagnostics()
|
diagnostics[name] = overlay.Diagnostics()
|
||||||
}
|
}
|
||||||
return diagnostics
|
return diagnostics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MetricsReporter interface {
|
||||||
|
Metrics() interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d OverlaySwitchDiagnostics) Metrics() interface{} {
|
||||||
|
for _, entry := range d {
|
||||||
|
if fastDPEntry, ok := entry.(MetricsReporter); ok {
|
||||||
|
return fastDPEntry.Metrics()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (osw *OverlaySwitch) InvalidateRoutes() {
|
func (osw *OverlaySwitch) InvalidateRoutes() {
|
||||||
for _, overlay := range osw.overlays {
|
for _, overlay := range osw.overlays {
|
||||||
overlay.InvalidateRoutes()
|
overlay.InvalidateRoutes()
|
||||||
|
|||||||
Reference in new issue
Block a user