From 39c75bbb08a7284082352046068e6c54c93843e5 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 31 Dec 2017 09:32:33 +0100 Subject: [PATCH] sar: Print items' name on the right of the report Some items' name (devices, network interfaces) may sometimes be long enough to create a shift in the statistics displayed by sar which are no longer in their original column. So display them at the end of the line on the right. Signed-off-by: Sebastien GODARD --- pr_stats.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pr_stats.c b/pr_stats.c index 8071bf7..edfa2de 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -1028,7 +1028,7 @@ __print_funct_t print_disk_stats(struct activity *a, int prev, int curr, } if (dis) { - print_hdr_line(timestamp[!curr], a, FIRST, 0, 9); + print_hdr_line(timestamp[!curr], a, FIRST, -1, 9); } for (i = 0; i < a->nr[curr]; i++) { @@ -1070,7 +1070,6 @@ __print_funct_t print_disk_stats(struct activity *a, int prev, int curr, printf("%-11s", timestamp[curr]); - cprintf_in(IS_STR, " %9s", dev_name, 0); cprintf_f(NO_UNIT, 1, 9, 2, S_VALUE(sdp->nr_ios, sdc->nr_ios, itv)); cprintf_f(unit, 2, 9, 2, @@ -1085,7 +1084,7 @@ __print_funct_t print_disk_stats(struct activity *a, int prev, int curr, xds.svctm); cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, xds.util / 10.0); - printf("\n"); + cprintf_in(IS_STR, " %s\n", dev_name, 0); } } @@ -1116,7 +1115,7 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr, } if (dis) { - print_hdr_line(timestamp[!curr], a, FIRST, 0, 9); + print_hdr_line(timestamp[!curr], a, FIRST, -1, 9); } for (i = 0; i < a->nr[curr]; i++) { @@ -1133,7 +1132,6 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr, } printf("%-11s", timestamp[curr]); - cprintf_in(IS_STR, " %9s", sndc->interface, 0); rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv); txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv); @@ -1150,7 +1148,7 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr, S_VALUE(sndp->multicast, sndc->multicast, itv)); ifutil = compute_ifutil(sndc, rxkb, txkb); cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, ifutil); - printf("\n"); + cprintf_in(IS_STR, " %s\n", sndc->interface, 0); } } @@ -1174,7 +1172,7 @@ __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr, memset(&snedzero, 0, STATS_NET_EDEV_SIZE); if (dis) { - print_hdr_line(timestamp[!curr], a, FIRST, 0, 9); + print_hdr_line(timestamp[!curr], a, FIRST, -1, 9); } for (i = 0; i < a->nr[curr]; i++) { @@ -1191,7 +1189,6 @@ __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr, } printf("%-11s", timestamp[curr]); - cprintf_in(IS_STR, " %9s", snedc->interface, 0); cprintf_f(NO_UNIT, 9, 9, 2, S_VALUE(snedp->rx_errors, snedc->rx_errors, itv), @@ -1203,7 +1200,7 @@ __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr, S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv), S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv), S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv)); - printf("\n"); + cprintf_in(IS_STR, " %s\n", snedc->interface, 0); } } -- 2.40.0