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:
Alessandro Puccetti
2016-08-12 17:44:17 +02:00
parent 8cbd2c2db6
commit 6eefb70628
2 changed files with 23 additions and 5 deletions

View File

@@ -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",
},
}
}

View File

@@ -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) {