mac-port: convert mac address to switch port using snmp.

This commit is contained in:
hjp 2001-04-11 14:31:29 +00:00
parent 680e14640f
commit 199019e26a
3 changed files with 74 additions and 0 deletions

14
snmp/GNUmakefile Normal file
View File

@ -0,0 +1,14 @@
# $Id: GNUmakefile,v 1.1 2001-04-11 14:31:28 hjp Exp $
include GNUmakevars
clean:
install: $(SBINDIR)/mac-port-bay $(SBINDIR)/mac-port
include GNUmakerules
# $Log: GNUmakefile,v $
# Revision 1.1 2001-04-11 14:31:28 hjp
# mac-port: convert mac address to switch port using snmp.
#

31
snmp/mac-port Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/perl -w
#
# $Id: mac-port,v 1.1 2001-04-11 14:31:29 hjp Exp $
#
# find the port of a baystack 350 T switch to which a given
# mac address is connected.
#
use strict;
sub usage {
print STDERR "Usage: $0 switch mac-address\n";
exit(1);
}
if (@ARGV != 2) {usage();}
my @hmac = split(/:/, $ARGV[1]);
my $switch = $ARGV[0];
my @dmac = map { hex } @hmac;
my $object = "17.4.3.1.2." . join(".", @dmac);
system("snmpget", $switch, "public", $object);
# $Log: mac-port,v $
# Revision 1.1 2001-04-11 14:31:29 hjp
# mac-port: convert mac address to switch port using snmp.
#

29
snmp/mac-port-bay Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/perl -w
#
# $Id: mac-port-bay,v 1.1 2001-04-11 14:31:29 hjp Exp $
#
# find the port of a baystack 350 T switch to which a given
# mac address is connected.
#
use strict;
sub usage {
print STDERR "Usage: $0 mac-address\n";
exit(1);
}
if (@ARGV != 1) {usage();}
my @hmac = split(/:/, $ARGV[0]);
my @dmac = map { hex } @hmac;
my $object = "17.4.3.1.2." . join(".", @dmac);
system("snmpget", "bay-switch-1", "public", $object);
# $Log: mac-port-bay,v $
# Revision 1.1 2001-04-11 14:31:29 hjp
# mac-port: convert mac address to switch port using snmp.
#