summaryrefslogtreecommitdiffstats
path: root/share/examples
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2016-02-10 04:56:38 +0000
committerdteske <dteske@FreeBSD.org>2016-02-10 04:56:38 +0000
commitd74f32e11a6c60a2c609e341cb1f98df665d51d0 (patch)
tree4290213aa3ebd94150e2cbd0c83f047cee3c79c3 /share/examples
parent6d8e3abce2241628cedda2829cfb0dd997fa62ad (diff)
downloadFreeBSD-src-d74f32e11a6c60a2c609e341cb1f98df665d51d0.zip
FreeBSD-src-d74f32e11a6c60a2c609e341cb1f98df665d51d0.tar.gz
Add `stats' command to get ng_bridge(4) stats
Diffstat (limited to 'share/examples')
-rwxr-xr-xshare/examples/jails/jng34
1 files changed, 34 insertions, 0 deletions
diff --git a/share/examples/jails/jng b/share/examples/jails/jng
index 445803d..ee850ea 100755
--- a/share/examples/jails/jng
+++ b/share/examples/jails/jng
@@ -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
#
OpenPOWER on IntegriCloud