[PATCH 4/6] cli: print stats if bearer reports them

Aleksander Morgado aleksander at aleksander.es
Fri Nov 27 05:51:17 PST 2015


---
 cli/mmcli-bearer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/cli/mmcli-bearer.c b/cli/mmcli-bearer.c
index 5829e60..7c4fe62 100644
--- a/cli/mmcli-bearer.c
+++ b/cli/mmcli-bearer.c
@@ -135,10 +135,12 @@ print_bearer_info (MMBearer *bearer)
     MMBearerIpConfig *ipv4_config;
     MMBearerIpConfig *ipv6_config;
     MMBearerProperties *properties;
+    MMBearerStats *stats;
 
     ipv4_config = mm_bearer_get_ipv4_config (bearer);
     ipv6_config = mm_bearer_get_ipv6_config (bearer);
     properties = mm_bearer_get_properties (bearer);
+    stats = mm_bearer_get_stats (bearer);
 
     /* Not the best thing to do, as we may be doing _get() calls twice, but
      * easiest to maintain */
@@ -253,6 +255,26 @@ print_bearer_info (MMBearer *bearer)
             g_print ("                     |      MTU: '%u'\n", mtu);
     }
 
+    if (stats) {
+        guint64 val;
+
+        g_print ("  -------------------------\n"
+                 "  Stats              |          Duration: '%u'\n", mm_bearer_stats_get_duration (stats));
+
+        val = mm_bearer_stats_get_bytes_rx (stats);
+        if (val > 0)
+            g_print ("                     |    Bytes received: '%" G_GUINT64_FORMAT "'\n", val);
+        else
+            g_print ("                     |    Bytes received: 'N/A'\n");
+
+        val = mm_bearer_stats_get_bytes_tx (stats);
+        if (val > 0)
+            g_print ("                     | Bytes transmitted: '%" G_GUINT64_FORMAT "'\n", val);
+        else
+            g_print ("                     | Bytes transmitted: 'N/A'\n");
+    }
+
+    g_clear_object (&stats);
     g_clear_object (&properties);
     g_clear_object (&ipv4_config);
     g_clear_object (&ipv6_config);
-- 
2.6.2



More information about the ModemManager-devel mailing list