allow snmp::info base class in netdisco-do (#486)
* allow the use of base snmp::info * dont use . * should have been: dont use $_ * also document some extra features * reword
This commit is contained in:
@@ -301,14 +301,30 @@ the leaf (such as C<interfaces> or C<uptime>).
|
||||
|
||||
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>".
|
||||
"C<Layer2::HP::uptime>". Using "C<::>" as the start of the prefix will test
|
||||
against the base "C<SNMP::Info>" class.
|
||||
|
||||
As well, SNMP object 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.
|
||||
|
||||
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 in the C<-p> parameter:
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
=head2 psql
|
||||
|
||||
|
||||
@@ -18,13 +18,14 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
||||
my ($device, $port, $extra) = map {$job->$_} qw/device port extra/;
|
||||
|
||||
$extra ||= 'interfaces'; my $class = undef;
|
||||
($class, $extra) = split(/::([^:]+)$/, $extra);
|
||||
if ($class and $extra) {
|
||||
$class = 'SNMP::Info::'.$class;
|
||||
}
|
||||
else {
|
||||
$extra = $class;
|
||||
undef $class;
|
||||
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 $i = App::Netdisco::Transport::SNMP->reader_for($device, $class);
|
||||
|
||||
Reference in New Issue
Block a user