]> granicus.if.org Git - sysstat/commitdiff
%ifutil: Update sadf output to take into account the new metric
authorSebastien GODARD <sysstat@orange.fr.fake>
Sun, 23 Jun 2013 15:07:31 +0000 (17:07 +0200)
committerSebastien GODARD <sysstat@orange.fr.fake>
Sun, 23 Jun 2013 15:07:31 +0000 (17:07 +0200)
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.

json_stats.c
rndr_stats.c
sadf.h
xml/sysstat-2.17.dtd [moved from xml/sysstat-2.16.dtd with 99% similarity]
xml/sysstat.xsd
xml_stats.c

index 1f3a7709740cc9d4cf0c12b1f1713cc2447b4c16..d7fd688dd246cccb1f9958ae2351464c00b2f3ce 100644 (file)
@@ -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");
index 280a0c297816c7b1260f89ecd36bf6ed74e4d316..15d32c2bf434bda2f8f0af2888a0a95fc278eb78 100644 (file)
@@ -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 d1f8ba9ea4a6d30890c410deefca9afa9d1f62c0..77edab3dc14080fab6a0796e91100f115fc28cec 100644 (file)
--- 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
similarity index 99%
rename from xml/sysstat-2.16.dtd
rename to xml/sysstat-2.17.dtd
index 06faed26ba37a2c5f29f13c3519c3a6b6e1a43fa..64baaafd05a82e9b2cb3afb185ead563f984b4ed 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--DTD v2.16 for sysstat. See sadf.h -->
+<!--DTD v2.17 for sysstat. See sadf.h -->
 
 <!ELEMENT sysstat (sysdata-version, host)>
 
        rxcmp CDATA #REQUIRED
        txcmp CDATA #REQUIRED
        rxmcst CDATA #REQUIRED
+       ifutil-percent CDATA #REQUIRED
 >
 
 <!ELEMENT net-edev EMPTY>
index e7fdcc10c6e9572964b7f041b436c25871181e3b..0195a84f72deb9d0d4ff97626e5cbb33ee1f3a07 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://pagesperso-orange.fr/sebastien.godard/sysstat" targetNamespace="http://pagesperso-orange.fr/sebastien.godard/sysstat" elementFormDefault="qualified">
 <xs:annotation>
-       <xs:appinfo>-- XML Schema v2.16 for sysstat. See sadf.h --</xs:appinfo>
+       <xs:appinfo>-- XML Schema v2.17 for sysstat. See sadf.h --</xs:appinfo>
 </xs:annotation>
 
 <xs:element name="sysstat" type="sysstat-type"></xs:element>
        <xs:attribute name="rxcmp" type="hundredth-type"></xs:attribute>
        <xs:attribute name="txcmp" type="hundredth-type"></xs:attribute>
        <xs:attribute name="rxmcst" type="hundredth-type"></xs:attribute>
+       <xs:attribute name="ifutil-percent" type="hundredth-type"></xs:attribute>
 </xs:complexType>
 
 <xs:element name="net-edev" type="net-edev-type"></xs:element>
index 16294ca8e7c2ba8ccbd69c27672339898d719b34..10e6b671803d21783ab24ca1d674df5c909534c8 100644 (file)
@@ -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, "<net-dev iface=\"%s\" "
                        "rxpck=\"%.2f\" "
                        "txpck=\"%.2f\" "
@@ -762,15 +767,17 @@ __print_funct_t xml_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);
        }
        tab--;