diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-11-19 14:21:57 -0800 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-11-19 14:21:57 -0800 |
commit | fc48b389b3d124cbf466c44ee4fb22a5e0f244eb (patch) | |
tree | af842c164ca7e95d41dbf8af756f5f4dd57bde89 /scripts | |
parent | 9de12eb4977cc55dd1b4ac5789921c24a5445d2b (diff) | |
download | vyatta-op-fc48b389b3d124cbf466c44ee4fb22a5e0f244eb.tar.gz vyatta-op-fc48b389b3d124cbf466c44ee4fb22a5e0f244eb.zip |
make changes for submodule moved to VyattaMisc
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-show-interfaces.pl | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/scripts/vyatta-show-interfaces.pl b/scripts/vyatta-show-interfaces.pl index a776d65..f006d0f 100755 --- a/scripts/vyatta-show-interfaces.pl +++ b/scripts/vyatta-show-interfaces.pl @@ -25,6 +25,7 @@ use lib "/opt/vyatta/share/perl5/"; use VyattaConfig; +use VyattaMisc; use Getopt::Long; use POSIX; use NetAddr::IP; @@ -109,24 +110,12 @@ sub get_intf_description { } } -sub get_sysfs_value { - my ($intf, $name) = @_; - - open (my $statf, '<', "/sys/class/net/$intf/$name") - or die "Can't open statistics file /sys/class/net/$intf/$name"; - - my $value = <$statf>; - chomp $value if defined $value; - close $statf; - return $value; -} - sub get_intf_stats { my $intf = shift; my %stats = (); foreach my $var (@rx_stat_vars, @tx_stat_vars) { - $stats{$var} = get_sysfs_value($intf, "statistics/$var"); + $stats{$var} = VyattaMisc::get_sysfs_value($intf, "statistics/$var"); } return %stats; } @@ -189,12 +178,12 @@ sub get_state_link { my $intf = shift; my $state; my $link = 'down'; - my $flags = get_sysfs_value($intf, 'flags'); + my $flags = VyattaMisc::get_sysfs_value($intf, 'flags'); my $hex_flags = hex($flags); if ($hex_flags & 0x1) { # IFF_UP $state = 'up'; - my $carrier = get_sysfs_value($intf, 'carrier'); + my $carrier = VyattaMisc::get_sysfs_value($intf, 'carrier'); if ($carrier eq '1') { $link = "up"; } |