Date: Wed, 10 Feb 2016 04:56:38 +0000 (UTC) From: Devin Teske <dteske@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295460 - head/share/examples/jails Message-ID: <201602100456.u1A4uc9Z003416@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dteske Date: Wed Feb 10 04:56:38 2016 New Revision: 295460 URL: https://svnweb.freebsd.org/changeset/base/295460 Log: Add `stats' command to get ng_bridge(4) stats Modified: head/share/examples/jails/jng Modified: head/share/examples/jails/jng ============================================================================== --- head/share/examples/jails/jng Wed Feb 10 04:43:08 2016 (r295459) +++ head/share/examples/jails/jng Wed Feb 10 04:56:38 2016 (r295460) @@ -154,6 +154,7 @@ usage() show \ show1 \ shutdown \ + stats \ ; do eval usage=\"\$jng_${action}_usage\" [ "$usage" ] || continue @@ -414,6 +415,39 @@ jng_shutdown() jng_show "$name" | xargs -rn1 -I eiface ngctl shutdown eiface: } +jng_stats_usage="stats NAME" +jng_stats_descr="Show ng_bridge link statistics for NAME interfaces" +jng_stats() +{ + local OPTIND=1 OPTARG flag + while getopts "" flag; do + case "$flag" in + *) action_usage stats # NOTREACHED + esac + done + shift $(( $OPTIND -1 )) + local name="$1" + [ "${name:-x}" = "${name#*[!0-9a-zA-Z_]}" -a $# -eq 1 ] || + action_usage stats # NOTREACHED + mustberoot_to_continue + for eiface in $( jng_show "$name" ); do + echo "$eiface:" + ngctl show $eiface: | awk ' + $3 == "bridge" && $5 ~ /^link/ { + bridge = $2 + link = substr($5, 5) + system(sprintf("ngctl msg %s: getstats %u", + bridge, link)) + }' | fmt 2 | awk ' + /=/ && fl = index($0, "=") { + printf "%20s = %s\n", + substr($0, 0, fl-1), + substr($0, 0, fl+1) + } + ' # END-QUOTE + done +} + ############################################################ MAIN #
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602100456.u1A4uc9Z003416>