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 # _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"