From: Sebastien GODARD Date: Sun, 23 Jun 2013 15:07:31 +0000 (+0200) Subject: %ifutil: Update sadf output to take into account the new metric X-Git-Tag: v10.1.7~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d768d8759875592de8ed957d1ff181ff77b78e5;p=sysstat %ifutil: Update sadf output to take into account the new metric This patch updates the various output formats of sadf (CSV, ppc, JSON, XML) to take into account the new %ifutil metric added to sar network devices statistics. DTD and XSD documents have also been updated accordingly. --- diff --git a/json_stats.c b/json_stats.c index 1f3a770..d7fd688 100644 --- a/json_stats.c +++ b/json_stats.c @@ -760,6 +760,7 @@ __print_funct_t json_print_net_dev_stats(struct activity *a, int curr, int tab, int i, j; struct stats_net_dev *sndc, *sndp; int sep = FALSE; + double rxkb, txkb, ifutil; if (!IS_SELECTED(a->options) || (a->nr <= 0)) goto close_json_markup; @@ -784,6 +785,10 @@ __print_funct_t json_print_net_dev_stats(struct activity *a, int curr, int tab, } sep = TRUE; + rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv); + txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv); + ifutil = compute_ifutil(sndc, rxkb, txkb); + xprintf0(tab, "{\"iface\": \"%s\", " "\"rxpck\": %.2f, " "\"txpck\": %.2f, " @@ -791,15 +796,17 @@ __print_funct_t json_print_net_dev_stats(struct activity *a, int curr, int tab, "\"txkB\": %.2f, " "\"rxcmp\": %.2f, " "\"txcmp\": %.2f, " - "\"rxmcst\": %.2f}", + "\"rxmcst\": %.2f, " + "\"ifutil-percent\": %.2f}", sndc->interface, S_VALUE(sndp->rx_packets, sndc->rx_packets, itv), S_VALUE(sndp->tx_packets, sndc->tx_packets, itv), - S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024, - S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024, + rxkb / 1024, + txkb / 1024, S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv), S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv), - S_VALUE(sndp->multicast, sndc->multicast, itv)); + S_VALUE(sndp->multicast, sndc->multicast, itv), + ifutil); } printf("\n"); diff --git a/rndr_stats.c b/rndr_stats.c index 280a0c2..15d32c2 100644 --- a/rndr_stats.c +++ b/rndr_stats.c @@ -1126,6 +1126,7 @@ __print_funct_t render_net_dev_stats(struct activity *a, int isdb, char *pre, { int i, j; struct stats_net_dev *sndc, *sndp; + double rxkb, txkb, ifutil; int pt_newlin = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN); @@ -1153,18 +1154,20 @@ __print_funct_t render_net_dev_stats(struct activity *a, int isdb, char *pre, S_VALUE(sndp->tx_packets, sndc->tx_packets, itv), NULL); + rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv); render(isdb, pre, PT_NOFLAG, "%s\trxkB/s", NULL, cons(sv, sndc->interface, NULL), NOVAL, - S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024, + rxkb / 1024, NULL); + txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv); render(isdb, pre, PT_NOFLAG, "%s\ttxkB/s", NULL, cons(sv, sndc->interface, NULL), NOVAL, - S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024, + txkb / 1024, NULL); render(isdb, pre, PT_NOFLAG, @@ -1181,12 +1184,20 @@ __print_funct_t render_net_dev_stats(struct activity *a, int isdb, char *pre, S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv), NULL); - render(isdb, pre, pt_newlin, + render(isdb, pre, PT_NOFLAG, "%s\trxmcst/s", NULL, cons(sv, sndc->interface, NULL), NOVAL, S_VALUE(sndp->multicast, sndc->multicast, itv), NULL); + + ifutil = compute_ifutil(sndc, rxkb, txkb); + render(isdb, pre, pt_newlin, + "%s\t%%ifutil", NULL, + cons(sv, sndc->interface, NULL), + NOVAL, + ifutil, + NULL); } } diff --git a/sadf.h b/sadf.h index d1f8ba9..77edab3 100644 --- a/sadf.h +++ b/sadf.h @@ -9,7 +9,7 @@ #include "sa.h" /* DTD version for XML output */ -#define XML_DTD_VERSION "2.16" +#define XML_DTD_VERSION "2.17" /* Possible actions for functions used to display reports */ #define F_BEGIN 0x01 diff --git a/xml/sysstat-2.16.dtd b/xml/sysstat-2.17.dtd similarity index 99% rename from xml/sysstat-2.16.dtd rename to xml/sysstat-2.17.dtd index 06faed2..64baaaf 100644 --- a/xml/sysstat-2.16.dtd +++ b/xml/sysstat-2.17.dtd @@ -1,5 +1,5 @@ - + @@ -262,6 +262,7 @@ rxcmp CDATA #REQUIRED txcmp CDATA #REQUIRED rxmcst CDATA #REQUIRED + ifutil-percent CDATA #REQUIRED > diff --git a/xml/sysstat.xsd b/xml/sysstat.xsd index e7fdcc1..0195a84 100644 --- a/xml/sysstat.xsd +++ b/xml/sysstat.xsd @@ -1,7 +1,7 @@ - -- XML Schema v2.16 for sysstat. See sadf.h -- + -- XML Schema v2.17 for sysstat. See sadf.h -- @@ -381,6 +381,7 @@ + diff --git a/xml_stats.c b/xml_stats.c index 16294ca..10e6b67 100644 --- a/xml_stats.c +++ b/xml_stats.c @@ -738,6 +738,7 @@ __print_funct_t xml_print_net_dev_stats(struct activity *a, int curr, int tab, { int i, j; struct stats_net_dev *sndc, *sndp; + double rxkb, txkb, ifutil; if (!IS_SELECTED(a->options) || (a->nr <= 0)) goto close_xml_markup; @@ -755,6 +756,10 @@ __print_funct_t xml_print_net_dev_stats(struct activity *a, int curr, int tab, j = check_net_dev_reg(a, curr, !curr, i); sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize); + rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv); + txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv); + ifutil = compute_ifutil(sndc, rxkb, txkb); + xprintf(tab, "", + "rxmcst=\"%.2f\" " + "ifutil-percent=\"%.2f\"/>", sndc->interface, S_VALUE(sndp->rx_packets, sndc->rx_packets, itv), S_VALUE(sndp->tx_packets, sndc->tx_packets, itv), - S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024, - S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024, + rxkb / 1024, + txkb / 1024, S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv), S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv), - S_VALUE(sndp->multicast, sndc->multicast, itv)); + S_VALUE(sndp->multicast, sndc->multicast, itv), + ifutil); } tab--;