more direct access to tunnel stats
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Thu, 4 Oct 2012 13:10:26 +0000 (15:10 +0200)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Thu, 4 Oct 2012 13:10:26 +0000 (15:10 +0200)
ovs-appctl netdev-tunnel/get-rx-bytes <iface>
ovs-appctl netdev-tunnel/get-tx-bytes <iface>

lib/netdev-tunnel.c
planetlab/scripts/sliver-ovs.in

index 91220a6..797813b 100644 (file)
@@ -439,12 +439,50 @@ netdev_tunnel_get_port(struct unixctl_conn *conn,
     unixctl_command_reply(conn, buf);
 }
 
+static void
+netdev_tunnel_get_tx_bytes(struct unixctl_conn *conn,
+                     int argc OVS_UNUSED, const char *argv[], void *aux OVS_UNUSED)
+{
+    struct netdev_dev_tunnel *tunnel_dev;
+    char buf[128];
+
+    tunnel_dev = shash_find_data(&tunnel_netdev_devs, argv[1]);
+    if (!tunnel_dev) {
+        unixctl_command_reply_error(conn, "no such tunnel netdev");
+        return;
+    }
+
+    sprintf(buf, "%"PRIu64, tunnel_dev->stats.tx_bytes);
+    unixctl_command_reply(conn, buf);
+}
+
+static void
+netdev_tunnel_get_rx_bytes(struct unixctl_conn *conn,
+                     int argc OVS_UNUSED, const char *argv[], void *aux OVS_UNUSED)
+{
+    struct netdev_dev_tunnel *tunnel_dev;
+    char buf[128];
+
+    tunnel_dev = shash_find_data(&tunnel_netdev_devs, argv[1]);
+    if (!tunnel_dev) {
+        unixctl_command_reply_error(conn, "no such tunnel netdev");
+        return;
+    }
+
+    sprintf(buf, "%"PRIu64, tunnel_dev->stats.rx_bytes);
+    unixctl_command_reply(conn, buf);
+}
+
 
 static int
 netdev_tunnel_init(void)
 {
     unixctl_command_register("netdev-tunnel/get-port", "NAME",
                              1, 1, netdev_tunnel_get_port, NULL);
+    unixctl_command_register("netdev-tunnel/get-tx-bytes", "NAME",
+                             1, 1, netdev_tunnel_get_tx_bytes, NULL);
+    unixctl_command_register("netdev-tunnel/get-rx-bytes", "NAME",
+                             1, 1, netdev_tunnel_get_rx_bytes, NULL);
     return 0;
 }
 
index 08bef1c..d58c1d2 100755 (executable)
@@ -271,8 +271,8 @@ function gmap_report_once () {
     iface=$1; shift
     hostname=$1; shift
     linkid=$1; shift
-    rx_bytes=$(ovs-vsctl get interface $iface statistics:rx_bytes)
-    tx_bytes=$(ovs-vsctl get interface $iface statistics:tx_bytes)
+    rx_bytes=$(ovs-appctl netdev-tunnel/get-rx-bytes $iface)
+    tx_bytes=$(ovs-appctl netdev-tunnel/get-tx-bytes $iface)
     rx_bits=$(($rx_bytes*8))
     tx_bits=$(($tx_bytes*8))
     now=$(date +%s).$(date +%N)