summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@io.vyatta.com>2008-12-11 16:46:52 -0800
committerStig Thormodsrud <stig@io.vyatta.com>2008-12-11 16:46:52 -0800
commit1f641ff640b38157fa8bd768d21ed54beb2aee68 (patch)
tree91ae365dcb2b0ecc9448cbbb69158399e48dd7b7
parent80d41820b9d1a28db981dcbffc7d6ddb0f04e5f9 (diff)
downloadvyatta-op-1f641ff640b38157fa8bd768d21ed54beb2aee68.tar.gz
vyatta-op-1f641ff640b38157fa8bd768d21ed54beb2aee68.zip
Add option to show counters for multiple interfaces.
-rwxr-xr-xscripts/vyatta-show-interfaces.pl20
-rw-r--r--templates/show/interfaces/counters/node.def2
2 files changed, 22 insertions, 0 deletions
diff --git a/scripts/vyatta-show-interfaces.pl b/scripts/vyatta-show-interfaces.pl
index 02ad8e0..529684f 100755
--- a/scripts/vyatta-show-interfaces.pl
+++ b/scripts/vyatta-show-interfaces.pl
@@ -56,6 +56,7 @@ my %intf_hash = (
my %action_hash = (
'show' => \&run_show_intf,
'show-brief' => \&run_show_intf_brief,
+ 'show-count' => \&run_show_counters,
'clear' => \&run_clear_intf,
'reset' => \&run_reset_intf,
);
@@ -312,6 +313,25 @@ sub run_show_intf_brief {
}
}
+sub run_show_counters {
+ my @intfs = @_;
+
+ my $format = "%-12s %10s %10s %10s %10s\n";
+ printf($format, "Interface","Rx Packets","Rx Bytes","Tx Packets","Tx Bytes");
+ foreach my $intf (@intfs) {
+ my ($state, $link) = get_state_link($intf);
+ next if $state ne 'up';
+ my %clear = get_clear_stats($intf);
+ my %stats = get_intf_stats($intf);
+ printf($format, $intf,
+ get_counter_val($clear{rx_packets}, $stats{rx_packets}),
+ get_counter_val($clear{rx_bytes}, $stats{rx_bytes}),
+ get_counter_val($clear{tx_packets}, $stats{tx_packets}),
+ get_counter_val($clear{tx_bytes}, $stats{tx_bytes})
+ );
+ }
+}
+
sub run_clear_intf {
my @intfs = @_;
diff --git a/templates/show/interfaces/counters/node.def b/templates/show/interfaces/counters/node.def
new file mode 100644
index 0000000..1cef3ee
--- /dev/null
+++ b/templates/show/interfaces/counters/node.def
@@ -0,0 +1,2 @@
+help: Show network interface counters
+run: ${vyatta_bindir}/vyatta-show-interfaces.pl --action=show-count