#1087 netdisco-do show handles qualified MIB leafs
This commit is contained in:
@@ -323,37 +323,34 @@ create a directory for the output files.
|
||||
|
||||
=head2 show
|
||||
|
||||
Dump the content of an SNMP MIB leaf, which is useful for diagnostics and
|
||||
troubleshooting. You should provide the "C<-e>" option which is the name of
|
||||
the leaf (such as C<interfaces> or C<uptime>).
|
||||
Dump the content of an SNMP MIB Object or an L<SNMP::Info> method, useful for
|
||||
diagnostics and troubleshooting.
|
||||
|
||||
If you wish to test with a device class other than that discovered, prefix the
|
||||
leaf with the class short name, for example "C<Layer3::C3550::interfaces>" or
|
||||
"C<Layer2::HP::uptime>". Using "C<::>" as the start of the prefix will test
|
||||
against the base "C<SNMP::Info>" class.
|
||||
You should provide the "C<-e>" option which is the name of the method or
|
||||
object, such as C<interfaces> or C<uptime> or C<ifDescr>.
|
||||
|
||||
As well, SNMP OID names can be used as an argument for "C<-e>", so you can
|
||||
use C<ifName> for example, which will use the netdisco-mibs files for
|
||||
translations.
|
||||
If you wish to specify the SNMP MIB to load and find the Object in, then
|
||||
you can qualify the "C<-e>" parameter, such as C<IF-MIB::ifDescr>.
|
||||
|
||||
If you wish to test with a specific L<SNMP::Info> device class other than the
|
||||
one discovered, pass this in the "C<-p>" parameter, such as C<Layer3> or
|
||||
C<SNMP::Info::Layer3> (the C<SNMP::Info> prefix is optional).
|
||||
|
||||
All "C<-e>" parameters are case sensitive.
|
||||
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e interfaces
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e Layer2::HP::interfaces
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e ::interfaces
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e ifName
|
||||
|
||||
A parameter may be passed to the C<SNMP::Info> method or SNMP object in the
|
||||
"C<-p>" parameter:
|
||||
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e has_layer -p 3
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e ifName -p 2
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e IF-MIB::ifDescr
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e interfaces -p SNMP::Info::Layer2::HP
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e ifName -p Layer3::Arista
|
||||
|
||||
The "C<-e>" parameter C<specify> will show the used configuration for the
|
||||
specified device.
|
||||
|
||||
~/bin/netdisco-do show -d 192.0.2.1 -e specify
|
||||
|
||||
This command works well with the "C<-I>" debug flag on L<SNMP::Info> (or
|
||||
"C<-II>").
|
||||
|
||||
=head2 psql
|
||||
|
||||
Start an interactive terminal with the Netdisco PostgreSQL database. If you
|
||||
|
||||
@@ -15,25 +15,22 @@ register_worker({ phase => 'check' }, sub {
|
||||
|
||||
register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
||||
my ($job, $workerconf) = @_;
|
||||
my ($device, $port, $extra) = map {$job->$_} qw/device port extra/;
|
||||
|
||||
$extra ||= 'interfaces'; my $class = undef;
|
||||
my @values = split /::/, $extra;
|
||||
$extra = pop @values;
|
||||
if (scalar(@values)) {
|
||||
$class = "SNMP::Info";
|
||||
foreach my $v (@values) {
|
||||
last if ($v eq '');
|
||||
$class = $class.'::'.$v;
|
||||
}
|
||||
}
|
||||
my ($device, $class, $object) = map {$job->$_} qw/device port extra/;
|
||||
|
||||
$class = 'SNMP::Info::'.$class if $class and $class !~ m/^SNMP::Info::/;
|
||||
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device, $class);
|
||||
my $result = sub { eval { $snmp->$extra($port) } || undef };
|
||||
|
||||
$object ||= 'interfaces';
|
||||
my $orig_object = $object;
|
||||
my ($mib, $leaf) = split m/::/, $object;
|
||||
SNMP::loadModules($mib) if $mib and $leaf and $mib ne $leaf;
|
||||
$object =~ s/[-:]/_/g;
|
||||
|
||||
my $result = sub { eval { $snmp->$object() } || undef };
|
||||
Data::Printer::p( $result->() );
|
||||
|
||||
return Status->done(
|
||||
sprintf "Showed %s response from %s", $extra, $device->ip);
|
||||
sprintf "Showed %s response from %s", $orig_object, $device->ip);
|
||||
});
|
||||
|
||||
true;
|
||||
|
||||
Reference in New Issue
Block a user