summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am8
-rw-r--r--debian/lintian8
-rwxr-xr-xscripts/show_interfaces74
-rwxr-xr-xscripts/show_interfaces_ethernet112
-rwxr-xr-xscripts/show_interfaces_loopback76
-rwxr-xr-xscripts/show_interfaces_statistics123
-rwxr-xr-xscripts/show_interfaces_summary55
-rwxr-xr-xscripts/show_interfaces_system75
-rwxr-xr-xscripts/show_interfaces_tunnel76
-rwxr-xr-xscripts/vyatta-show-interfaces195
-rw-r--r--templates/show/interfaces/ethernet/node.def2
-rw-r--r--templates/show/interfaces/ethernet/node.tag/node.def2
-rw-r--r--templates/show/interfaces/ethernet/node.tag/vif/node.tag/node.def2
-rw-r--r--templates/show/interfaces/ethernet/node.tag/vif/node.tag/physical/node.def2
-rw-r--r--templates/show/interfaces/loopback/node.def2
-rw-r--r--templates/show/interfaces/loopback/node.tag/node.def2
-rw-r--r--templates/show/interfaces/node.def2
-rw-r--r--templates/show/interfaces/system/enabled/node.def2
-rw-r--r--templates/show/interfaces/system/node.def2
-rw-r--r--templates/show/interfaces/tunnel/node.def2
-rw-r--r--templates/show/interfaces/tunnel/node.tag/node.def2
21 files changed, 208 insertions, 616 deletions
diff --git a/Makefile.am b/Makefile.am
index 2bf1de3..65b0a7f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,13 +4,7 @@ completiondir = /etc/bash_completion.d
completion_DATA = etc/bash_completion.d/vyatta-op
opdir = $(datadir)/vyatta-op/templates
-bin_SCRIPTS = scripts/show_interfaces
-bin_SCRIPTS += scripts/show_interfaces_ethernet
-bin_SCRIPTS += scripts/show_interfaces_loopback
-bin_SCRIPTS += scripts/show_interfaces_statistics
-bin_SCRIPTS += scripts/show_interfaces_summary
-bin_SCRIPTS += scripts/show_interfaces_system
-bin_SCRIPTS += scripts/show_interfaces_tunnel
+bin_SCRIPTS = scripts/vyatta-show-interfaces
bin_SCRIPTS += scripts/show_version
cpiop = find . ! -regex '\(.*~\|.*\.bak\|.*\.swp\|.*\#.*\#\)' -print0 | \
diff --git a/debian/lintian b/debian/lintian
index aa0b0d0..99e6c54 100644
--- a/debian/lintian
+++ b/debian/lintian
@@ -1,9 +1,3 @@
vyatta-op: file-in-unusual-dir
vyatta-op: dir-or-file-in-opt
-vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/show_interfaces
-vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/show_interfaces_ethernet
-vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/show_interfaces_loopback
-vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/show_interfaces_statistics
-vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/show_interfaces_summary
-vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/show_interfaces_system
-vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/show_interfaces_tunnel
+vyatta-op: shell-script-fails-syntax-check ./opt/vyatta/bin/vyatta-show-interfaces
diff --git a/scripts/show_interfaces b/scripts/show_interfaces
deleted file mode 100755
index 44b3c8c..0000000
--- a/scripts/show_interfaces
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/bash
-# **** License ****
-# Version: VPL 1.0
-#
-# The contents of this file are subject to the Vyatta Public License
-# Version 1.0 ("License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.vyatta.com/vpl
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and limitations
-# under the License.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Tom Grennan
-# Date: 2007
-#
-# **** End License ****
-
-shopt -s extglob
-shopt -s nullglob
-
-test -f /etc/default/vyatta && source /etc/default/vyatta
-: ${vyatta_bindir:=/opt/vyatta/bin}
-
-declare progname=${0##*/}
-declare -a full_itfs=( /sys/class/net/+(eth|vmnet|lo|sit|wan)* )
-declare -a itfs
-
-_usage ()
-{
- cat <<-EOF
- $progname [ INTERFACE ]
- EOF
-}
-
-_error ()
-{
- ecode=$1
- shift
- echo $@
- if [ $ecode -eq 1 ] ; then
- echo
- _usage
- fi
- exit $ecode
-}
-
-if [ $# -gt 0 ] ; then
- if [[ $1 == --+(usage|help) ]] ; then
- _usage
- exit 0
- elif [[ $1 != +(eth|vmnet|lo|sit|wan)* ]] ; then
- _error 2 \""$1"\" is not an interface name\!
- elif ! test -d /sys/class/net/$1 ; then
- _error 2 $1: no such interface\!
- else
- itfs=( $1 )
- shift
- fi
-else
- itfs=( ${full_itfs[@]##*/} )
-fi
-
-$vyatta_bindir/show_interfaces_statistics ${itfs[@]}
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End:
diff --git a/scripts/show_interfaces_ethernet b/scripts/show_interfaces_ethernet
deleted file mode 100755
index d592018..0000000
--- a/scripts/show_interfaces_ethernet
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/bash
-# **** License ****
-# Version: VPL 1.0
-#
-# The contents of this file are subject to the Vyatta Public License
-# Version 1.0 ("License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.vyatta.com/vpl
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and limitations
-# under the License.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Tom Grennan
-# Date: 2007
-#
-# **** End License ****
-
-test -f /etc/default/vyatta && source /etc/default/vyatta
-: ${vyatta_bindir:=/opt/vyatta/bin}
-
-shopt -s extglob
-shopt -s nullglob
-
-declare progname=${0##*/}
-declare -a itfs
-
-_usage ()
-{
- cat <<-EOF
- $progname
- $progname INTERFACE
- $progname INTERFACE physical
- $progname INTERFACE vif VIF
- $progname INTERFACE vif VIF physical
- EOF
-}
-
-_error ()
-{
- ecode=$1
- shift
- echo $@
- if [ $ecode -eq 1 ] ; then
- echo
- _usage
- fi
- exit $ecode
-}
-
-_show_interfaces_ethernet_physical ()
-{
- if type -t ethtool &>/dev/null ; then
- for eth ; do
- sudo ethtool $eth
- echo
- done
- fi
-}
-
-if [ $# -gt 0 ] ; then
- if [[ $1 == --+(usage|help) ]] ; then
- _usage
- exit 0
- elif [[ $1 != +(eth|vmnet)*([[:digit:]]) ]] ; then
- _error 2 \""$1"\" is not an ethernet device name\!
- elif ! test -d /sys/class/net/$1 ; then
- _error 2 \""$1"\" no such ethernet interface\!
- else
- eth=$1
- shift
- fi
- if [[ $# -gt 0 && $1 == vif ]] ; then
- shift
- if [ $# -gt 0 ] ; then
- vif=$1 ; shift
- itf=${eth}.${vif}
- test -d /sys/class/net/$itf || \
- _error 2 \""$vif"\" no such vif for $eth\!
- else
- _error 1 Missing VIF parameter\!
- fi
- else
- itf=$eth
- fi
- itfs=( $itf )
-else
- declare -a full_eths=( /sys/class/net/+(eth|vmnet)* )
- test ${#full_eths[@]} -gt 0 || \
- _error 2 No ethernet interfaces\!
- itfs=( ${full_eths[@]##*/} )
-fi
-
-case "$1" in
- physical ) cmd=_show_interfaces_ethernet_physical ;;
- "" | statistics ) cmd=$vyatta_bindir/show_interfaces_statistics ;;
- name ) cmd=echo ;;
- * ) _error 1 \""$1"\" is an invalid parameter\! ;;
-esac
-
-eval $cmd ${itfs[@]##*/}
-
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End:
diff --git a/scripts/show_interfaces_loopback b/scripts/show_interfaces_loopback
deleted file mode 100755
index ab1bb5d..0000000
--- a/scripts/show_interfaces_loopback
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/bash
-# **** License ****
-# Version: VPL 1.0
-#
-# The contents of this file are subject to the Vyatta Public License
-# Version 1.0 ("License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.vyatta.com/vpl
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and limitations
-# under the License.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Tom Grennan
-# Date: 2007
-#
-# **** End License ****
-
-test -f /etc/default/vyatta && source /etc/default/vyatta
-: ${vyatta_bindir:=/opt/vyatta/bin}
-
-shopt -s extglob
-shopt -s nullglob
-
-declare progname=${0##*/}
-declare -a itfs
-
-_usage ()
-{
- cat <<-EOF
- $progname [ INTERFACE ]
- EOF
-}
-
-_error ()
-{
- ecode=$1
- shift
- echo $@
- if [ $ecode -eq 1 ] ; then
- echo
- _usage
- fi
- exit $ecode
-}
-
-if [ $# -gt 0 ] ; then
- if [[ $1 == --+(usage|help) ]] ; then
- _usage
- exit 0
- elif [[ $1 != lo* ]] ; then
- _error 2 \""$1"\" is not a loopback device name\!
- elif ! test -d /sys/class/net/$1 ; then
- _error 2 $1: no such loopback interface\!
- else
- itfs=( $1 )
- shift
- fi
-else
- declare -a full_los=( /sys/class/net/lo* )
- test ${#full_los[@]} -gt 0 || \
- _error 2 No loopback interfaces\!
- itfs=( ${full_los[@]##*/} )
-fi
-
-$vyatta_bindir/show_interfaces_statistics ${itfs[@]}
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End:
diff --git a/scripts/show_interfaces_statistics b/scripts/show_interfaces_statistics
deleted file mode 100755
index 40870cc..0000000
--- a/scripts/show_interfaces_statistics
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/bin/bash
-# **** License ****
-# Version: VPL 1.0
-#
-# The contents of this file are subject to the Vyatta Public License
-# Version 1.0 ("License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.vyatta.com/vpl
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and limitations
-# under the License.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Tom Grennan
-# Date: 2007
-#
-# **** End License ****
-
-shopt -s extglob
-shopt -s nullglob
-
-declare progname=${0##*/}
-declare -a full_itfs=( /sys/class/net/+(eth|vmnet|wan|sit|lo)* )
-declare -a itfs
-declare -i rx_bytes rx_packets rx_errors rx_dropped rx_over_errors multicast
-declare -i tx_bytes tx_packets tx_errors tx_dropped tx_carrier_errors collisions
-declare -i rx_missed_errors rx_fifo_errors
-
-_usage ()
-{
- cat <<-EOF
- $progname [ INTERFACE ]
- EOF
-}
-
-_error ()
-{
- ecode=$1
- shift
- echo $@
- if [ $ecode -eq 1 ] ; then
- echo
- _usage
- fi
- exit $ecode
-}
-
-if [ $# -gt 0 ] ; then
- if [[ $1 == --+(usage|help) ]] ; then
- _usage
- exit 0
- else
- itfs=( $@ )
- fi
-else
- itfs=( ${full_itfs[@]##*/} )
-fi
-
-for itf in ${itfs[@]} ; do
- test -d /sys/class/net/$itf || \
- _error 2 $itf: no such interface\!
- for stat in \
- rx_bytes rx_packets rx_errors rx_dropped rx_over_errors multicast \
- tx_bytes tx_packets tx_errors tx_dropped tx_carrier_errors collisions
- do
- full_stat=/sys/class/net/${itf}/statistics/${stat}
- if [ -r $full_stat ] ; then
- eval $stat=$(cat $full_stat)
- else
- eval $stat=0
- fi
- done
- for stat in rx_missed_errors ; do
- full_stat=/sys/class/net/${itf}/statistics/${stat}
- if [ -r $full_stat ] ; then
- let $(( rx_dropped_errors += $(cat $full_stat) ))
- fi
- done
- for stat in rx_fifo_errors ; do
- full_stat=/sys/class/net/${itf}/statistics/${stat}
- if [ -r $full_stat ] ; then
- let $(( rx_over_errors += $(cat $full_stat) ))
- fi
- done
-
- printf -v rx_stats \
- '%10d %10d %10d %10d %10d %10d' \
- $rx_bytes \
- $rx_packets\
- $rx_errors \
- $rx_dropped \
- $rx_over_errors \
- $multicast
-
- printf -v tx_stats \
- '%10d %10d %10d %10d %10d %10d' \
- $tx_bytes \
- $tx_packets\
- $tx_errors \
- $tx_dropped \
- $tx_carrier_errors \
- $collisions
-
- ip -s addr show ${itf} | sed 's/^[0-9]*: //'
- cat <<-EOF
-
- RX: bytes packets errors dropped overrun mcast
- $rx_stats
- TX: bytes packets errors dropped carrier collisions
- $tx_stats
-
- EOF
-done
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End:
diff --git a/scripts/show_interfaces_summary b/scripts/show_interfaces_summary
deleted file mode 100755
index 020ae2c..0000000
--- a/scripts/show_interfaces_summary
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-# **** License ****
-# Version: VPL 1.0
-#
-# The contents of this file are subject to the Vyatta Public License
-# Version 1.0 ("License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.vyatta.com/vpl
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and limitations
-# under the License.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Tom Grennan
-# Date: 2007
-#
-# **** End License ****
-
-shopt -s extglob
-shopt -s nullglob
-
-declare -a full_itfs=( /sys/class/net/+(eth|vmnet|lo|sit|wan)* )
-declare -i rx_bytes rx_packets rx_errors rx_dropped rx_over_errors multicast
-declare -i tx_bytes tx_packets tx_errors tx_dropped tx_carrier_errors collisions
-
-printf '%10s %10s %10s %10s %10s\n' \
- interface packets bytes errors drops
-
-for itf in ${full_itfs[@]##*/} ; do
- for stat in \
- rx_bytes rx_packets rx_errors rx_dropped rx_over_errors multicast \
- tx_bytes tx_packets tx_errors tx_dropped tx_carrier_errors collisions
- do
- full_stat=/sys/class/net/${itf}/statistics/${stat}
- if [ -r $full_stat ] ; then
- eval $stat=$(cat $full_stat)
- else
- eval $stat=0
- fi
- done
- printf '%10s rx %10d %10d %10d %10d\n' \
- $itf $rx_packets $rx_bytes $rx_errors $rx_dropped
- printf '%10s tx %10d %10d %10d %10d\n' \
- '' $tx_packets $tx_bytes $tx_errors $tx_dropped
-done
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End:
diff --git a/scripts/show_interfaces_system b/scripts/show_interfaces_system
deleted file mode 100755
index abc79d4..0000000
--- a/scripts/show_interfaces_system
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# **** License ****
-# Version: VPL 1.0
-#
-# The contents of this file are subject to the Vyatta Public License
-# Version 1.0 ("License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.vyatta.com/vpl
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and limitations
-# under the License.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Tom Grennan
-# Date: 2007
-#
-# **** End License ****
-
-test -f /etc/default/vyatta && source /etc/default/vyatta
-: ${vyatta_bindir:=/opt/vyatta/bin}
-
-shopt -s extglob
-shopt -s nullglob
-
-declare progname=${0##*/}
-declare -a full_itfs=( /sys/class/net/+(eth|vmnet|lo|sit|wan)* )
-declare -a itfs
-declare -i flags
-
-_usage ()
-{
- cat <<-EOF
- $progname [ enabled ]
- EOF
-}
-
-_error ()
-{
- ecode=$1
- shift
- echo $@
- if [ $ecode -eq 1 ] ; then
- _usage
- fi
- exit $ecode
-}
-
-if [ $# -gt 0 ] ; then
- if [[ $1 == --+(usage|help) ]] ; then
- _usage
- exit 0
- elif [[ $1 != enabled ]] ; then
- _error 1 Invalid option: $1
- else
- for itf in ${full_itfs[@]} ; do
- let -i flags="$(cat $itf/flags) & 1"
- [[ $flags -eq 1 ]] && \
- itfs[${#itfs[@]}]=${itf##*/}
- done
- fi
-else
- itfs=( ${full_itfs[@]##*/} )
-fi
-
-$vyatta_bindir/show_interfaces_statistics ${itfs[@]}
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End:
diff --git a/scripts/show_interfaces_tunnel b/scripts/show_interfaces_tunnel
deleted file mode 100755
index d5df7b3..0000000
--- a/scripts/show_interfaces_tunnel
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/bash
-# **** License ****
-# Version: VPL 1.0
-#
-# The contents of this file are subject to the Vyatta Public License
-# Version 1.0 ("License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.vyatta.com/vpl
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and limitations
-# under the License.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Tom Grennan
-# Date: 2007
-#
-# **** End License ****
-
-test -f /etc/default/vyatta && source /etc/default/vyatta
-: ${vyatta_bindir:=/opt/vyatta/bin}
-
-shopt -s extglob
-shopt -s nullglob
-
-declare progname=${0##*/}
-declare -a itfs
-
-_usage ()
-{
- cat <<-EOF
- $progname [ INTERFACE ]
- EOF
-}
-
-_error ()
-{
- ecode=$1
- shift
- echo $@
- if [ $ecode -eq 1 ] ; then
- echo
- _usage
- fi
- exit $ecode
-}
-
-if [ $# -gt 0 ] ; then
- if [[ $1 == --+(usage|help) ]] ; then
- _usage
- exit 0
- elif [[ $1 != sit* ]] ; then
- _error 2 \""$1"\" is not a tunnel device name\!
- elif ! test -d /sys/class/net/$1 ; then
- _error 2 $1: no such tunnel interface\!
- else
- itfs=( $1 )
- shift
- fi
-else
- declare -a full_sits=( /sys/class/net/sit* )
- test ${#full_sits[@]} -gt 0 || \
- _error 2 No tunnel interfaces\!
- itfs=( ${full_sits[@]##*/} )
-fi
-
-$vyatta_bindir/show_interfaces_statistics ${itfs[@]}
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End:
diff --git a/scripts/vyatta-show-interfaces b/scripts/vyatta-show-interfaces
new file mode 100755
index 0000000..1a71c29
--- /dev/null
+++ b/scripts/vyatta-show-interfaces
@@ -0,0 +1,195 @@
+#!/bin/bash
+# **** License ****
+# Version: VPL 1.0
+#
+# The contents of this file are subject to the Vyatta Public License
+# Version 1.0 ("License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://www.vyatta.com/vpl
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# This code was originally developed by Vyatta, Inc.
+# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
+# All Rights Reserved.
+#
+# Author: Tom Grennan
+# Date: 2007
+#
+# **** End License ****
+
+shopt -s extglob
+shopt -s nullglob
+
+declare progname=${0##*/}
+declare -a full_itfs=( /sys/class/net/+(eth|vmnet|lo|sit|wan)* )
+declare -a itfs
+declare _do_show=_show_itf_stats
+
+_error ()
+{
+ ecode=$1
+ shift
+ echo $@
+ if [ $ecode -eq 1 ] ; then
+ echo
+ _usage
+ fi
+ exit $ecode
+}
+
+_show_itf_stats ()
+{
+ local -i rx_bytes rx_packets rx_errors rx_dropped rx_over_errors multicast
+ local -i tx_bytes tx_packets tx_errors tx_dropped tx_carrier_errors \
+ collisions
+ local -i rx_missed_errors rx_fifo_errors
+
+ for itf ; do
+ test -d /sys/class/net/$itf || \
+ _error 2 $itf: no such interface\!
+ for stat in \
+ rx_bytes rx_packets rx_errors rx_dropped rx_over_errors multicast \
+ tx_bytes tx_packets tx_errors tx_dropped tx_carrier_errors \
+ collisions
+ do
+ full_stat=/sys/class/net/${itf}/statistics/${stat}
+ if [ -r $full_stat ] ; then
+ eval $stat=$(cat $full_stat)
+ else
+ eval $stat=0
+ fi
+ done
+ for stat in rx_missed_errors ; do
+ full_stat=/sys/class/net/${itf}/statistics/${stat}
+ if [ -r $full_stat ] ; then
+ let $(( rx_dropped_errors += $(cat $full_stat) ))
+ fi
+ done
+ for stat in rx_fifo_errors ; do
+ full_stat=/sys/class/net/${itf}/statistics/${stat}
+ if [ -r $full_stat ] ; then
+ let $(( rx_over_errors += $(cat $full_stat) ))
+ fi
+ done
+
+ printf -v rx_stats \
+ '%10d %10d %10d %10d %10d %10d' \
+ $rx_bytes \
+ $rx_packets \
+ $rx_errors \
+ $rx_dropped \
+ $rx_over_errors \
+ $multicast
+
+ printf -v tx_stats \
+ '%10d %10d %10d %10d %10d %10d' \
+ $tx_bytes \
+ $tx_packets \
+ $tx_errors \
+ $tx_dropped \
+ $tx_carrier_errors \
+ $collisions
+
+ ip -s addr show ${itf} | sed 's/^[0-9]*: //'
+ cat <<-EOF
+
+ RX: bytes packets errors dropped overrun mcast
+ $rx_stats
+ TX: bytes packets errors dropped carrier collisions
+ $tx_stats
+
+ EOF
+ done
+}
+
+_show_itf_physical ()
+{
+ if type -t ethtool &>/dev/null ; then
+ for eth ; do
+ sudo ethtool $eth
+ echo
+ done
+ fi
+}
+
+_usage ()
+{
+ cat <<-EOF
+ $progname [ INTERFACE ]
+ $progname loopback [ INTERFACE ]
+ $progname tunnel [ INTERFACE ]
+ $progname system [ enabled ]
+ EOF
+}
+
+_add_itfs ()
+{
+ for itf ; do
+ if [[ $itf != +(eth|vmnet|lo|sit|wan)* ]] ; then
+ _error 2 \""$itf"\" is not an interface name\!
+ elif [ ! -d /sys/class/net/$itf ] ; then
+ _error 2 $itf: no such interface\!
+ else
+ itfs+=( $itf )
+ fi
+ done
+}
+
+if [ $# -gt 0 ] ; then
+ if [[ $1 == --+(usage|help) ]] ; then
+ _usage
+ exit 0
+ elif [[ $1 == +(ethernet|loopback|system|tunnel) ]] ; then
+ if [ $# -eq 1 ] ; then
+ case $1 in
+ ethernet )
+ full_itfs=( /sys/class/net/+(eth|vmnet)* ) ;;
+ loopback )
+ full_itfs=( /sys/class/net/lo* ) ;;
+ tunnel )
+ full_itfs=( /sys/class/net/sit* ) ;;
+ esac
+ itfs=( ${full_itfs[@]##*/} )
+ else
+ if [[ $1 == system ]] ; then
+ if [[ $2 == enabled ]] ; then
+ for full_itf in ${full_itfs[@]} ; do
+ let -i flags="$(cat $full_itf/flags) & 1"
+ [[ $flags -eq 1 ]] && _add_itfs ${full_itf##*/}
+ done
+ fi
+ else
+ _add_itfs $2
+ if [ $# -gt 2 ] ; then
+ if [[ $3 == physical ]] ; then
+ _do_show=_show_itf_physical
+ elif [[ $3 == vif ]] ; then
+ if [ $# -gt 3 ] ; then
+ itfs+=.$4
+ if [[ $# -gt 4 && $4 == physical ]] ; then
+ _do_show=_show_itf_physical
+ fi
+ else
+ _error 2 missing VIF number\!
+ fi
+ fi
+ fi
+ fi
+ fi
+ else
+ _add_itfs $*
+ fi
+else
+ itfs=( ${full_itfs[@]##*/} )
+fi
+
+eval $_do_show ${itfs[@]}
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 4
+# End:
diff --git a/templates/show/interfaces/ethernet/node.def b/templates/show/interfaces/ethernet/node.def
index 299c6e2..76e0990 100644
--- a/templates/show/interfaces/ethernet/node.def
+++ b/templates/show/interfaces/ethernet/node.def
@@ -1,2 +1,2 @@
help: "Show ethernet interface information"
-run: ${vyatta_bindir}/show_interfaces_ethernet
+run: ${vyatta_bindir}/vyatta-show-interfaces ethernet
diff --git a/templates/show/interfaces/ethernet/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/node.def
index 1354886..09bd522 100644
--- a/templates/show/interfaces/ethernet/node.tag/node.def
+++ b/templates/show/interfaces/ethernet/node.tag/node.def
@@ -2,4 +2,4 @@ help: "Show given ethernet interface information"
allowed: local -a array ;
array=( /sys/class/net/{eth,vmnet}* ) ;
echo -n ${array[@]##*/}
-run: ${vyatta_bindir}/show_interfaces_ethernet $4
+run: ${vyatta_bindir}/vyatta-show-interfaces ethernet $4
diff --git a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/node.def
index 10eb140..a4dfe2b 100644
--- a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/node.def
+++ b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/node.def
@@ -2,4 +2,4 @@ help: "Show given virtual network interface information"
allowed: for eth in /sys/class/net/eth${4}.* ; do
echo ${eth/*eth${4}./} ;
done
-run: ${vyatta_bindir}/show_interfaces_ethernet $4 vif $6
+run: ${vyatta_bindir}/vyatta-show-interfaces ethernet $4 vif $6
diff --git a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/physical/node.def b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/physical/node.def
index 058e2a1..7f6445f 100644
--- a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/physical/node.def
+++ b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/physical/node.def
@@ -1,2 +1,2 @@
help: "Show given virtual network interface pseudo-physical information"
-run: ${vyatta_bindir}/show_interfaces_ethernet $4 vif $6 physical
+run: sudo ethtool $4.$6
diff --git a/templates/show/interfaces/loopback/node.def b/templates/show/interfaces/loopback/node.def
index 6b36ffc..5394ff0 100644
--- a/templates/show/interfaces/loopback/node.def
+++ b/templates/show/interfaces/loopback/node.def
@@ -1,3 +1,3 @@
help: "Show loopback interface information"
-run: ${vyatta_bindir}/show_interfaces_loopback
+run: ${vyatta_bindir}/vyatta-show-interfaces loopback
diff --git a/templates/show/interfaces/loopback/node.tag/node.def b/templates/show/interfaces/loopback/node.tag/node.def
index 1a90fdc..2b0ee55 100644
--- a/templates/show/interfaces/loopback/node.tag/node.def
+++ b/templates/show/interfaces/loopback/node.tag/node.def
@@ -2,4 +2,4 @@ help: "Show given loopback interface information"
allowed: local -a array ;
array=( /sys/class/net/lo* ) ;
echo -n ${array[@]##*/}
-run: ${vyatta_bindir}/show_interfaces_loopback $4
+run: ${vyatta_bindir}/vyatta-show-interfaces loopback $4
diff --git a/templates/show/interfaces/node.def b/templates/show/interfaces/node.def
index 2a6e891..577db98 100644
--- a/templates/show/interfaces/node.def
+++ b/templates/show/interfaces/node.def
@@ -1,2 +1,2 @@
help: "Show network interface information"
-run: ${vyatta_bindir}/show_interfaces
+run: ${vyatta_bindir}/vyatta-show-interfaces
diff --git a/templates/show/interfaces/system/enabled/node.def b/templates/show/interfaces/system/enabled/node.def
index 9abd87b..d48e1f2 100644
--- a/templates/show/interfaces/system/enabled/node.def
+++ b/templates/show/interfaces/system/enabled/node.def
@@ -1,2 +1,2 @@
help: "Show network information of all enabled interfaces"
-run: ${vyatta_bindir}/show_interfaces_system enabled
+run: ${vyatta_bindir}/vyatta-show-interfaces system enabled
diff --git a/templates/show/interfaces/system/node.def b/templates/show/interfaces/system/node.def
index 46f8bfe..e5de242 100644
--- a/templates/show/interfaces/system/node.def
+++ b/templates/show/interfaces/system/node.def
@@ -1,2 +1,2 @@
help: "Show network information of all interfaces"
-run: ${vyatta_bindir}/show_interfaces_system
+run: ${vyatta_bindir}/vyatta-show-interfaces system
diff --git a/templates/show/interfaces/tunnel/node.def b/templates/show/interfaces/tunnel/node.def
index e95ab4a..a2f5d1c 100644
--- a/templates/show/interfaces/tunnel/node.def
+++ b/templates/show/interfaces/tunnel/node.def
@@ -1,3 +1,3 @@
help: "Show tunnel interface information"
-run: ${vyatta_bindir}/show_interfaces_tunnel
+run: ${vyatta_bindir}/vyatta-show-interfaces tunnel
diff --git a/templates/show/interfaces/tunnel/node.tag/node.def b/templates/show/interfaces/tunnel/node.tag/node.def
index b857b9e..2bc5908 100644
--- a/templates/show/interfaces/tunnel/node.tag/node.def
+++ b/templates/show/interfaces/tunnel/node.tag/node.def
@@ -2,4 +2,4 @@ help: "Show given tunnel interface information"
allowed: local -a array ;
array=( /sys/class/net/sit* ) ;
echo -n ${array[@]##*/}
-run: ${vyatta_bindir}/show_interfaces_tunnel $4
+run: ${vyatta_bindir}/vyatta-show-interfaces tunnel $4