mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2024-11-15 22:15:13 +08:00
tc: jsonify stats2
Add json output to stats2. Signed-off-by: Jiri Pirko <jiri@mellanox.com>
This commit is contained in:
parent
c91d262f41
commit
4fcec7f366
32
tc/tc_util.c
32
tc/tc_util.c
@ -781,16 +781,19 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
||||
struct gnet_stats_basic bs = {0};
|
||||
|
||||
memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]), sizeof(bs)));
|
||||
fprintf(fp, "%sSent %llu bytes %u pkt",
|
||||
prefix, (unsigned long long) bs.bytes, bs.packets);
|
||||
print_string(PRINT_FP, NULL, "%s", prefix);
|
||||
print_lluint(PRINT_ANY, "bytes", "Sent %llu bytes", bs.bytes);
|
||||
print_uint(PRINT_ANY, "packets", " %u pkt", bs.packets);
|
||||
}
|
||||
|
||||
if (tbs[TCA_STATS_QUEUE]) {
|
||||
struct gnet_stats_queue q = {0};
|
||||
|
||||
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
|
||||
fprintf(fp, " (dropped %u, overlimits %u requeues %u) ",
|
||||
q.drops, q.overlimits, q.requeues);
|
||||
print_uint(PRINT_ANY, "drops", " (dropped %u", q.drops);
|
||||
print_uint(PRINT_ANY, "overlimits", ", overlimits %u",
|
||||
q.overlimits);
|
||||
print_uint(PRINT_ANY, "requeues", " requeues %u) ", q.requeues);
|
||||
}
|
||||
|
||||
if (tbs[TCA_STATS_RATE_EST64]) {
|
||||
@ -799,8 +802,11 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
||||
memcpy(&re, RTA_DATA(tbs[TCA_STATS_RATE_EST64]),
|
||||
MIN(RTA_PAYLOAD(tbs[TCA_STATS_RATE_EST64]),
|
||||
sizeof(re)));
|
||||
fprintf(fp, "\n%srate %s %llupps ",
|
||||
prefix, sprint_rate(re.bps, b1), re.pps);
|
||||
print_string(PRINT_FP, NULL, "\n%s", prefix);
|
||||
print_lluint(PRINT_JSON, "rate", NULL, re.bps);
|
||||
print_string(PRINT_FP, NULL, "rate %s",
|
||||
sprint_rate(re.bps, b1));
|
||||
print_lluint(PRINT_ANY, "pps", " %llupps", re.pps);
|
||||
} else if (tbs[TCA_STATS_RATE_EST]) {
|
||||
struct gnet_stats_rate_est re = {0};
|
||||
|
||||
@ -808,6 +814,11 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
||||
MIN(RTA_PAYLOAD(tbs[TCA_STATS_RATE_EST]), sizeof(re)));
|
||||
fprintf(fp, "\n%srate %s %upps ",
|
||||
prefix, sprint_rate(re.bps, b1), re.pps);
|
||||
print_string(PRINT_FP, NULL, "\n%s", prefix);
|
||||
print_uint(PRINT_JSON, "rate", NULL, re.bps);
|
||||
print_string(PRINT_FP, NULL, "rate %s",
|
||||
sprint_rate(re.bps, b1));
|
||||
print_uint(PRINT_ANY, "pps", " %upps", re.pps);
|
||||
}
|
||||
|
||||
if (tbs[TCA_STATS_QUEUE]) {
|
||||
@ -815,9 +826,12 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
||||
|
||||
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
|
||||
if (!tbs[TCA_STATS_RATE_EST])
|
||||
fprintf(fp, "\n%s", prefix);
|
||||
fprintf(fp, "backlog %s %up requeues %u ",
|
||||
sprint_size(q.backlog, b1), q.qlen, q.requeues);
|
||||
print_string(PRINT_FP, NULL, "\n%s", prefix);
|
||||
print_uint(PRINT_JSON, "backlog", NULL, q.backlog);
|
||||
print_string(PRINT_FP, NULL, "backlog %s",
|
||||
sprint_size(q.backlog, b1));
|
||||
print_uint(PRINT_ANY, "qlen", " %up", q.qlen);
|
||||
print_uint(PRINT_ANY, "requeues", " requeues %u", q.qlen);
|
||||
}
|
||||
|
||||
if (xstats)
|
||||
|
Loading…
Reference in New Issue
Block a user