stat: support `-ojson` option with srv resources
Policy resources are already supported just like
any other resources. For `srv`, the newly `unauthorized`
field is missed in the json response.
This PR tries to fix that.
@@ -763,6 +763,7 @@ type jsonStats struct {
Leaf string `json:"leaf,omitempty"`
Dst string `json:"dst,omitempty"`
Weight string `json:"weight,omitempty"`
+ Unauthorized *float64 `json:"unauthorized,omitempty"`
}
func printStatJSON(statTables map[string]map[string]*row, w *tabwriter.Writer) {
@@ -803,6 +804,12 @@ func printStatJSON(statTables map[string]map[string]*row, w *tabwriter.Writer) {
entry.Dst = stats[key].dstStats.dst
entry.Weight = stats[key].dstStats.weight
}
+
+ if resourceType == k8s.Server {
+ if stats[key].srvStats != nil {
+ entry.Unauthorized = &stats[key].srvStats.unauthorizedRate
+ }
+ }
entries = append(entries, entry)
}
}
