Commit 96d35729 authored by Robert Ricci's avatar Robert Ricci
Browse files

Added a '-v' option that enables debug mode, and spits out a bit

more debugging info
parent 25b362ad
...@@ -31,6 +31,7 @@ use snmpit_cisco; ...@@ -31,6 +31,7 @@ use snmpit_cisco;
use snmpit_foundry; use snmpit_foundry;
use snmpit_nortel; use snmpit_nortel;
use SNMP; use SNMP;
use Getopt::Long;
use strict; use strict;
...@@ -57,14 +58,26 @@ if (!TBAdmin($>)) { ...@@ -57,14 +58,26 @@ if (!TBAdmin($>)) {
die "Sorry, only admins can use this script\n"; die "Sorry, only admins can use this script\n";
} }
if (@ARGV) { my %opt = ();
die "usage: $0\n"; GetOptions(\%opt, 'v');
my $debug = 0;
if ($opt{v}) {
$debug = 1;
}
sub DEBUG {
if ($debug) {
print STDERR @_;
}
} }
# #
# ElabinElab is special; Ask outer boss for the info. # ElabinElab is special; Ask outer boss for the info.
# #
if ($ELABINELAB) { if ($ELABINELAB) {
if ($debug) {
DEBUG "ELABINELAB mode\n";
}
libxmlrpc::Config({"server" => $RPCSERVER, libxmlrpc::Config({"server" => $RPCSERVER,
"verbose" => 0, "verbose" => 0,
"cert" => $RPCCERT, "cert" => $RPCCERT,
...@@ -101,6 +114,10 @@ if ($ELABINELAB) { ...@@ -101,6 +114,10 @@ if ($ELABINELAB) {
# guess which switch they're using # guess which switch they're using
# #
my @test_switches = map {[$_,"experimental"]} getTestSwitches(); my @test_switches = map {[$_,"experimental"]} getTestSwitches();
if (!@test_switches) {
die "Error: No experimental net switches found in database - you need\n" .
"to add them before running this script\n";
}
# #
# Get trunk ports so that we can skip MACs learned on them # Get trunk ports so that we can skip MACs learned on them
...@@ -115,11 +132,11 @@ if (!@control_switches) { ...@@ -115,11 +132,11 @@ if (!@control_switches) {
my @switches = (@test_switches, @control_switches); my @switches = (@test_switches, @control_switches);
my $debug = 0; if ($debug) {
DEBUG "switches in database:\n";
sub DEBUG { foreach my $switch (@switches) {
if ($debug) { my ($name, $type) = @$switch;
print @_; DEBUG " $name ($type)\n";
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment