Commit fefb6873 authored by Mac Newbold's avatar Mac Newbold
Browse files

Changes for debugging, ethX notation

parent 6d4939ce
......@@ -16,6 +16,13 @@ BEGIN {
push(@INC,$TB."/lib");
}
my $debug = 0;
#If there is debug, turn it on right now...
if ( join(" ",@ARGV) =~ /-debug\s*(\d*)/ ) {
if ( defined $1 && $1 ne "") { $debug = $1; } else { $debug = 1; }
print "DEBUG MODE ON: Set to level $debug\n";
}
use English;
#Uncomment this when we really need to be able to handle intel switches
......@@ -24,17 +31,10 @@ use snmpit_cisco;
use snmpit_apc;
use snmpit_lib;
snmpit_lib::init($DBNAME);
snmpit_lib::init($DBNAME, $debug);
$| = 1; # Turn off line buffering on output
my $debug = 0;
#If there is debug, turn it on right now...
if ( join(" ",@ARGV) =~ /-debug\s*(\d*)/ ) {
if ( defined $1 && $1 ne "") { $debug = $1; } else { $debug = 1; }
print "DEBUG MODE ON: Set to level $debug\n";
}
my $device;
my $pid;
my $eid;
......@@ -373,8 +373,8 @@ sub ParseArgs {
if (defined macport($vlan[$n])) {
if ($vlan[$n]=~/^([a-f]|\d)*$/i) {
$vlan[$n]=macport($vlan[$n]);
print "Found node $vlan[$n]\n";
}
print "Found node $vlan[$n]\n";
} else {
# Allow people to specify addresses with colons or dots
$vlan[$n] =~ s/[:\.]//g;
......@@ -397,9 +397,12 @@ sub ParseArgs {
print "There were no VLANs in the database table for '$pid' '$eid'\n";
exit(0);
} else {
if ($debug) {
foreach $id (keys %vlantable) {
print "id: $id\t$vlantable{$id}\n";
foreach $id (keys %vlantable) {
print "id: $id\t$vlantable{$id}\n" if $debug;
foreach $node (split (" ",$vlantable{$id})) {
if (!defined macport($node)) {
die("Invalid node found in VLANs table: '$node'\n");
}
}
}
}
......
......@@ -42,8 +42,9 @@ my $init = 0 ; # Start out uninitialized
sub init {
$DBNAME = shift;
$debug = shift || $debug;
$dbh = Mysql->connect("localhost",$DBNAME,"script","none");
print "Database initialized.\n" if $debug;
print "Database initialized. (debug level $debug)\n" if $debug;
&ReadTranslationTable;
return 0;
}
......@@ -167,7 +168,20 @@ sub tableVlans {
$sth = $dbh->
query("select id,members from vlans where pid='$pid' and eid='$eid'");
while (@row = $sth->fetchrow_array()) {
$table{$row[0]} = $row[1];
my @list = split(" ",$row[1]);
foreach $port (@list) {
my ($node,$card) = split(":",$port);
if ($card =~ /[a-zA-Z]/) {
# specified ala ethX
my $sth2 = $dbh->
query("select card from interfaces where node_id='$node' ".
"and iface='$card'");
$card = ($sth2->fetchrow_array())[0];
print "Had '$port', changed to '$node:$card'\n" if $debug;
$port = "$node:$card";
}
}
$table{$row[0]} = join(" ",@list);
}
return %table;
}
......
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