From 1f641ff640b38157fa8bd768d21ed54beb2aee68 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Thu, 11 Dec 2008 16:46:52 -0800 Subject: Add option to show counters for multiple interfaces. --- scripts/vyatta-show-interfaces.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'scripts') 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 = @_; -- cgit v1.2.3 From 77897e426a293114a1aa830b42cfcd3e860ae860 Mon Sep 17 00:00:00 2001 From: Mohit Mehta Date: Tue, 6 Jan 2009 11:22:07 -0800 Subject: Fix Bug 4022 dynamic dns config fails during system boot if interface does not exist - add information for non-existent interface to show command --- scripts/vyatta-op-dynamic-dns.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-op-dynamic-dns.pl b/scripts/vyatta-op-dynamic-dns.pl index d1197c2..3d24c38 100644 --- a/scripts/vyatta-op-dynamic-dns.pl +++ b/scripts/vyatta-op-dynamic-dns.pl @@ -35,12 +35,15 @@ sub print_ddns_stats { if (@ddns_interfaces > 0){ foreach my $configuredinterface (@ddns_interfaces) { + my $no_interface = `ip addr show dev $configuredinterface 2>/dev/null`; my $no_ip = `ip addr show dev $configuredinterface 2>/dev/null | grep "inet "`; my @all_cached_entries = `grep "^atime" $ddclient_cache_dir/ddclient_$configuredinterface.cache 2>/dev/null`; if (@all_cached_entries > 0) { foreach my $each_entry (@all_cached_entries) { print "interface : $configuredinterface"; - if ($no_ip eq ""){ + if ($no_interface eq ""){ + print " [ Interface does not exist ]"; + } elsif ($no_ip eq ""){ print " [ Currently no IP address ]"; } print "\n"; @@ -63,7 +66,9 @@ sub print_ddns_stats { } } else { print "interface : $configuredinterface"; - if ($no_ip eq ""){ + if ($no_interface eq ""){ + print " [ Interface does not exist ]"; + } elsif ($no_ip eq ""){ print " [ Currently no IP address ]"; } else { print " \n[ Status will be updated within 60 seconds ]"; -- cgit v1.2.3