Added list-mac-port.

bay-mac-port is obsolete, won't be installed any more.
This commit is contained in:
hjp 2003-12-03 13:51:47 +00:00
parent 22e6213acb
commit 46f4512ed3
2 changed files with 48 additions and 3 deletions

View File

@ -1,14 +1,18 @@
# $Id: GNUmakefile,v 1.1 2001-04-11 14:31:28 hjp Exp $
# $Id: GNUmakefile,v 1.2 2003-12-03 13:51:47 hjp Exp $
include GNUmakevars
clean:
install: $(SBINDIR)/mac-port-bay $(SBINDIR)/mac-port
install: $(SBINDIR)/mac-port $(SBINDIR)/list-mac-port
include GNUmakerules
# $Log: GNUmakefile,v $
# Revision 1.1 2001-04-11 14:31:28 hjp
# Revision 1.2 2003-12-03 13:51:47 hjp
# Added list-mac-port.
# bay-mac-port is obsolete, won't be installed any more.
#
# Revision 1.1 2001/04/11 14:31:28 hjp
# mac-port: convert mac address to switch port using snmp.
#

41
snmp/list-mac-port Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/perl -w
#
# $Id: list-mac-port,v 1.1 2003-12-03 13:51:47 hjp Exp $
#
# list mac/port mapping of a switch
#
use strict;
sub usage {
print STDERR "Usage: $0 switch\n";
exit(1);
}
if (@ARGV != 1) {usage();}
my $switch = $ARGV[0];
open (W, "snmpwalk $switch public 17.4.3.1.2 |")
or die "cannot invoke snmpwalk: $!";
while(<W>) {
my ($p, $port) = split / = /;
my @p = split(/\./, $p);
my $mac = join(":", map { sprintf("%02x", $_) } @p[-6 .. -1]);
next if ($mac =~ /^00:e0:63:/); # Ignore internal MAC addresses
# of Enterasys switches.
print "$switch\t$mac\t$port";
}
# $Log: list-mac-port,v $
# Revision 1.1 2003-12-03 13:51:47 hjp
# Added list-mac-port.
# bay-mac-port is obsolete, won't be installed any more.
#
# Revision 1.1 2001/04/11 14:31:29 hjp
# mac-port: convert mac address to switch port using snmp.
#