diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-06-27 11:19:00 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-06-27 11:19:00 +0200 |
commit | f7d48ceda6b45f8965d90916cb06e053cfaf3afe (patch) | |
tree | 8080eac4a0c210da6bd3c2bf79ecf4951299182f | |
parent | 3d84a304ca0b92ec0f1d83f320d3ae5f6fd69647 (diff) | |
download | vyatta-op-f7d48ceda6b45f8965d90916cb06e053cfaf3afe.tar.gz vyatta-op-f7d48ceda6b45f8965d90916cb06e053cfaf3afe.zip |
T2546: Migrate "show interfaces bonding * slaves" to vyos-1x
-rw-r--r-- | Makefile.am | 1 | ||||
-rwxr-xr-x | scripts/vyatta-show-bonding.pl | 123 | ||||
-rw-r--r-- | templates/show/interfaces/bonding/node.tag/slaves/node.def | 2 | ||||
-rw-r--r-- | templates/show/interfaces/bonding/slaves/node.def | 2 |
4 files changed, 0 insertions, 128 deletions
diff --git a/Makefile.am b/Makefile.am index 1bc20b5..d66bb69 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,6 @@ bin_SCRIPTS = scripts/vyatta-show-interfaces bin_SCRIPTS += scripts/vyatta-show-interfaces.pl bin_SCRIPTS += scripts/vyatta-show-dhclient.pl bin_SCRIPTS += scripts/vyatta-show-dmi -bin_SCRIPTS += scripts/vyatta-show-bonding.pl bin_SCRIPTS += scripts/vyatta-gettime.pl bin_SCRIPTS += scripts/show-dhcp-leases.pl bin_SCRIPTS += scripts/vyatta-boot-image.pl diff --git a/scripts/vyatta-show-bonding.pl b/scripts/vyatta-show-bonding.pl deleted file mode 100755 index c34a89e..0000000 --- a/scripts/vyatta-show-bonding.pl +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/perl -# -# Module: vyatta-show-interfaces.pl -# -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Stephen Hemminger -# Date: September 2008 -# Description: Script to display bonding information -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; -use Getopt::Long; -use Vyatta::Misc; -use Vyatta::Interface; - -use strict; -use warnings; - -sub usage { - print "Usage: $0 --brief\n"; - print " $0 interface(s)\n"; - exit 1; -} - -sub get_state_link { - my $intf = shift; - my $state; - my $link = 'down'; - my $flags = 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' ); - if ( $carrier eq '1' ) { - $link = "up"; - } - } - else { - $state = 'down'; - } - - return ( $state, $link ); -} - -my @modes = ( "round-robin", - "active-backup", - "xor-hash", - "broadcast", - "802.3ad", - "transmit-load-balance", - "adaptive-load-balance" -); - -sub show_brief { - my @interfaces = grep { /^bond[\d]+$/ } getInterfaces(); - my $format = "%-12s %-22s %-8s %-6s %s\n"; - - printf $format, 'Interface', 'Mode', 'State', 'Link', 'Slaves'; - foreach my $intf (sort @interfaces) { - die "Invalid bonding interface: $intf\n" - unless (-d "/sys/class/net/$intf/bonding" ); - - my $mode = get_sysfs_value( $intf, "bonding/mode" ); - my ( $name, $num ) = split (/ /, $mode); - $mode = $modes[$num] ? $modes[$num] : $name; - - my ( $state, $link ) = get_state_link($intf); - my $slaves = get_sysfs_value( $intf, "bonding/slaves" ); - printf $format, $intf, $mode, $state, $link, - $slaves ? $slaves : ''; - } - exit 0; -} - -sub show { - my @interfaces = @_; - my $format = "%-16s %-10s %-10s %-10s %-10s\n"; - - printf $format, "Interface", "RX: bytes", "packets", "TX: bytes", "packets"; - foreach my $intf (sort @interfaces) { - die "Invalid bonding interface: $intf\n" - unless (-d "/sys/class/net/$intf/bonding" ); - - my $slaves = get_sysfs_value( $intf, "bonding/slaves" ); - next unless $slaves; - - printf $format, $intf, get_sysfs_value( $intf, "statistics/rx_bytes" ), - get_sysfs_value( $intf, "statistics/rx_packets" ), - get_sysfs_value( $intf, "statistics/tx_bytes" ), - get_sysfs_value( $intf, "statistics/tx_packets" ); - - foreach my $slave (sort split( / /, $slaves)) { - printf $format, ' ' . $slave, - get_sysfs_value( $slave, "statistics/rx_bytes" ), - get_sysfs_value( $slave, "statistics/rx_packets" ), - get_sysfs_value( $slave, "statistics/tx_bytes" ), - get_sysfs_value( $slave, "statistics/tx_packets" ); - } - } -} - -my $brief; -GetOptions( 'brief' => \$brief, ) or usage(); - -show_brief() if ($brief); -show(@ARGV); - diff --git a/templates/show/interfaces/bonding/node.tag/slaves/node.def b/templates/show/interfaces/bonding/node.tag/slaves/node.def deleted file mode 100644 index 2eeff74..0000000 --- a/templates/show/interfaces/bonding/node.tag/slaves/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show specified bonding interface information -run: ${vyatta_bindir}/vyatta-show-bonding.pl "$4" diff --git a/templates/show/interfaces/bonding/slaves/node.def b/templates/show/interfaces/bonding/slaves/node.def deleted file mode 100644 index da85752..0000000 --- a/templates/show/interfaces/bonding/slaves/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show bonding interface information -run: ${vyatta_bindir}/vyatta-show-bonding.pl --brief |