App-MonM
view release on metacpan or search on metacpan
bin/monm_snmp view on Meta::CPAN
Returns storage table
=back
=head1 DEPENDENCES
L<SNMP> as Net-SNMP (see down)
=head1 REQUIREMENTS
=over
=item Net-SNMP
To use this module, you must have Net-SNMP installed on your system.
More specifically you need the Perl modules that come with it.
DO NOT INSTALL SNMP or Net::SNMP from CPAN!
The SNMP module is matched to an install of net-snmp, and must be installed
from the net-snmp source tree.
The Perl module C<SNMP> is found inside the net-snmp distribution. Go to the
F<perl/> directory of the distribution to install it, or run
C<./configure --with-perl-modules> from the top directory of the net-snmp
distribution.
Net-SNMP can be found at http://net-snmp.sourceforge.net
Version 5.3.2 or greater is recommended.
B<Redhat Users>: Some versions that come with certain versions of
Redhat/Fedora don't have the Perl library installed. Uninstall the RPM and
install by hand.
B<Ubuntu Users>: sudo apt-get install snmp snmp-mibs-downloader libsnmp-perl
=back
=head1 AUTHOR
Serż Minus (Sergey Lepenkov) L<https://www.serzik.com> E<lt>abalama@cpan.orgE<gt>
=head1 COPYRIGHT
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved
=head1 LICENSE
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See L<https://dev.perl.org/licenses/>
=cut
use Getopt::Long;
use Pod::Usage;
use Module::Loaded;
use Try::Tiny;
use App::MonM::Util qw/explain/;
use App::MonM::Const qw/
IS_TTY SCREENWIDTH
OK DONE ERROR SKIPPED PASSED FAILED UNKNOWN PROBLEM
/;
use constant {
HOST => 'localhost',
PORT => 161,
TIMEOUT => 1000000,
RETRIES => 5,
COMMUNITY => 'public',
VER => '2c',
TESTOBJ => '.1.3.6.1.2.1.1.3.0',
OBJ => 'SNMPv2-MIB::sysDescr.0', # .1.3.6.1.2.1.1.1.0
TBL => 'ifTable',
};
$SIG{INT} = sub { die "ABORTED\n"; };
$| = 1; # autoflush
my $options = {};
Getopt::Long::Configure("bundling");
GetOptions($options,
# Information
"help|usage|h", # Show help page
"longhelp|H|?", # Show long help page
# General
"host|server|s=s", # Host SNMT (default = localhost)
"strict|S", # Strict mode: 0/1
"community|comm|c=s", # Community (default = public)
"timeout|time|t=i", # Timeout (default = 1000000)
"version|v=s", # Version (default = 2c)
"table|astable|tab|T", # As table
"mibs|mib|M=s", # MIBS
) || pod2usage(-exitval => 1, -verbose => 0, -output => \*STDERR);
pod2usage(-exitval => 0, -verbose => 1) if $options->{help};
pod2usage(-exitval => 0, -verbose => 2) if $options->{longhelp};
my $host = $options->{host} || HOST;
my $timeout = $options->{timeout} || TIMEOUT;
my $strictm = $options->{strict} || 0;
my $community = $options->{community} || COMMUNITY;
my $ver = $options->{version} || VER;
my $istable = $options->{table} || 0;
my $obj = shift(@ARGV) // ($istable ? TBL : OBJ);
# Load module Net-SNMP
my $SNMPV = 0;
try {
require SNMP;
$SNMPV = SNMP->VERSION;
} catch {
print STDERR "Module SNMP 5.3.2 is not loaded. Please install Net-SNMP from official site of Net-SNMP project\n";
print STDERR $_, "\n";
( run in 2.840 seconds using v1.01-cache-2.11-cpan-98e64b0badf )