mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-15 19:41:02 +00:00
plugins/traffic-control: add packet loss to the report
This patch add packet loss to the report and the appropriet metadata template.
This commit is contained in:
@@ -146,6 +146,7 @@ func (r *Reporter) getContainerNodes() map[string]node {
|
||||
case Running:
|
||||
nodeID := containerIDToNodeID(containerID)
|
||||
latency, _ := getLatency(container.PID)
|
||||
pktLoss, _ := getPktLoss(container.PID)
|
||||
nodes[nodeID] = node{
|
||||
LatestControls: getTrafficNodeControls(timestamp, dead),
|
||||
Latest: map[string]stringEntry{
|
||||
@@ -153,10 +154,18 @@ func (r *Reporter) getContainerNodes() map[string]node {
|
||||
Timestamp: timestamp,
|
||||
Value: latency,
|
||||
},
|
||||
"traffic-control-pktloss": {
|
||||
Timestamp: timestamp,
|
||||
Value: pktLoss,
|
||||
},
|
||||
"traffic-control-table-latency": {
|
||||
Timestamp: timestamp,
|
||||
Value: latency,
|
||||
},
|
||||
"traffic-control-table-pktloss": {
|
||||
Timestamp: timestamp,
|
||||
Value: pktLoss,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -174,6 +183,14 @@ func getMetadataTemplate() map[string]metadataTemplate {
|
||||
Priority: 13.5,
|
||||
From: "latest",
|
||||
},
|
||||
"traffic-control-pktloss": metadataTemplate{
|
||||
ID: "traffic-control-pktloss",
|
||||
Label: "Packet Loss",
|
||||
Truncate: 0,
|
||||
Datatype: "",
|
||||
Priority: 13.6,
|
||||
From: "latest",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func DoTrafficControl(pid int, latency string) error {
|
||||
} else {
|
||||
trafficControlStatusCache[netNSID] = trafficControlStatus{
|
||||
latency: latency,
|
||||
pktLoss: "0.0%",
|
||||
pktLoss: "-",
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -106,10 +106,11 @@ func getStatus(pid int) (*trafficControlStatus, error) {
|
||||
log.Error(netNSID)
|
||||
return &emptyTrafficControlStatus, fmt.Errorf("failed to get network namespace ID: %v", err)
|
||||
} else {
|
||||
l, _ := parseLatency(output)
|
||||
lat, _ := parseLatency(output)
|
||||
pktL, _ := parsePktLoss(output)
|
||||
trafficControlStatusCache[netNSID] = trafficControlStatus{
|
||||
latency: l,
|
||||
pktLoss: "0.0%",
|
||||
latency: lat,
|
||||
pktLoss: pktL,
|
||||
}
|
||||
}
|
||||
status, _ := trafficControlStatusCache[netNSID]
|
||||
@@ -134,7 +135,7 @@ func parseAttribute(statusString string, attribute string) (string, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return "N/A", fmt.Errorf("%s not found", attribute)
|
||||
return "-", fmt.Errorf("%s not found", attribute)
|
||||
}
|
||||
|
||||
func getNSID(nsPath string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user