From 255e0223c069bbd8d23b941a1408e6ebc6d8e27b Mon Sep 17 00:00:00 2001 From: Giuseppe Lettieri Date: Thu, 4 Oct 2012 15:10:26 +0200 Subject: [PATCH] more direct access to tunnel stats ovs-appctl netdev-tunnel/get-rx-bytes ovs-appctl netdev-tunnel/get-tx-bytes --- lib/netdev-tunnel.c | 38 +++++++++++++++++++++++++++++++++ planetlab/scripts/sliver-ovs.in | 4 ++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/netdev-tunnel.c b/lib/netdev-tunnel.c index 91220a6c0..797813b05 100644 --- a/lib/netdev-tunnel.c +++ b/lib/netdev-tunnel.c @@ -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; } diff --git a/planetlab/scripts/sliver-ovs.in b/planetlab/scripts/sliver-ovs.in index 08bef1cd3..d58c1d2d1 100755 --- a/planetlab/scripts/sliver-ovs.in +++ b/planetlab/scripts/sliver-ovs.in @@ -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) -- 2.43.0