change for separate uncompressed oid maps in netdisco-mibs
This commit is contained in:
1
Build.PL
1
Build.PL
@@ -51,7 +51,6 @@ Module::Build->new(
|
||||
'Guard' => '1.022',
|
||||
'HTML::Parser' => '3.70',
|
||||
'HTTP::Tiny' => '0.029',
|
||||
'IO::Uncompress::Gunzip' => '0',
|
||||
'IO::Socket::INET6' => '2.72',
|
||||
'IO::Socket::SSL' => '2.048',
|
||||
'JSON' => '2.90',
|
||||
|
||||
@@ -6,9 +6,8 @@ use aliased 'App::Netdisco::Worker::Status';
|
||||
|
||||
use Dancer::Plugin::DBIC 'schema';
|
||||
|
||||
use File::Spec::Functions qw(catdir catfile);
|
||||
use File::Spec::Functions qw(splitdir catfile catdir);
|
||||
use File::Slurper qw(read_lines write_text);
|
||||
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
|
||||
use File::Temp;
|
||||
# use DDP;
|
||||
|
||||
@@ -18,18 +17,25 @@ register_worker({ phase => 'main' }, sub {
|
||||
debug "loadmibs - loading netdisco-mibs object cache";
|
||||
|
||||
my $home = (setting('mibhome') || catdir(($ENV{NETDISCO_HOME} || $ENV{HOME}), 'netdisco-mibs'));
|
||||
my $infile = catfile($home, qw(EXTRAS reports all_oids.gz));
|
||||
my $outfh = File::Temp->new();
|
||||
my $outfile = $outfh->filename;
|
||||
gunzip $infile => $outfile or die "gunzip failed: $GunzipError\n";
|
||||
my @report = read_lines($outfile, 'latin-1');
|
||||
my $reports = catdir( $home, 'EXTRAS', 'reports' );
|
||||
my @maps = map { (splitdir($_))[-1] }
|
||||
grep { ! m/^(?:EXTRAS)$/ }
|
||||
grep { ! m/\./ }
|
||||
grep { -f }
|
||||
glob (catfile( $reports, '*_oids' ));
|
||||
|
||||
my @report = ();
|
||||
push @report, read_lines( catfile( $reports, $_ ), 'latin-1' )
|
||||
for (qw(rfc_oids net-snmp_oids cisco_oids), @maps);
|
||||
|
||||
my @browser = ();
|
||||
my %children = ();
|
||||
my %seenoid = ();
|
||||
|
||||
foreach my $line (@report) {
|
||||
my ($oid, $qual_leaf, $type, $access, $index, $status, $enum, $descr) = split m/,/, $line, 8;
|
||||
next unless defined $oid and defined $qual_leaf;
|
||||
next if ++$seenoid{$oid} > 1;
|
||||
|
||||
my ($mib, $leaf) = split m/::/, $qual_leaf;
|
||||
my @oid_parts = grep {length} (split m/\./, $oid);
|
||||
|
||||
@@ -8,7 +8,7 @@ use App::Netdisco::Transport::SNMP;
|
||||
use App::Netdisco::Util::SNMP 'sortable_oid';
|
||||
use Dancer::Plugin::DBIC 'schema';
|
||||
|
||||
use File::Spec::Functions qw(catdir catfile);
|
||||
use File::Spec::Functions qw(splitdir catdir catfile);
|
||||
use MIME::Base64 'encode_base64';
|
||||
use File::Slurper qw(read_lines write_text);
|
||||
use File::Path 'make_path';
|
||||
@@ -101,12 +101,22 @@ sub getoidmap {
|
||||
debug "snapshot $device - loading netdisco-mibs object cache";
|
||||
|
||||
my $home = (setting('mibhome') || catdir(($ENV{NETDISCO_HOME} || $ENV{HOME}), 'netdisco-mibs'));
|
||||
my @report = read_lines(catfile($home, qw(EXTRAS reports all_oids)), 'latin-1');
|
||||
my $reports = catdir( $home, 'EXTRAS', 'reports' );
|
||||
my @maps = map { (splitdir($_))[-1] }
|
||||
grep { ! m/^(?:EXTRAS)$/ }
|
||||
grep { ! m/\./ }
|
||||
grep { -f }
|
||||
glob (catfile( $reports, '*_oids' ));
|
||||
|
||||
my @report = ();
|
||||
push @report, read_lines( catfile( $reports, $_ ), 'latin-1' )
|
||||
for (qw(rfc_oids net-snmp_oids cisco_oids), @maps);
|
||||
|
||||
my %oidmap = ();
|
||||
foreach my $line (@report) {
|
||||
my ($oid, $qual_leaf, $rest) = split m/,/, $line;
|
||||
next unless defined $oid and defined $qual_leaf;
|
||||
next if exists $oidmap{$oid};
|
||||
my ($mib, $leaf) = split m/::/, $qual_leaf;
|
||||
$oidmap{$oid} = $leaf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user