aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-04-12 18:09:17 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-04-12 18:09:17 +0200
commit3ff3b0f854fe6f14d5f7f8b8cd7bf91fc2abcaef (patch)
treebf4faafc1d0f94ceaac82d6b01084115e5010e0e /include
parentbb6b9c5cc38ee136ddab5d28f1baae903c38c07c (diff)
Remove nms::snmp, it's not actually used any more.
Diffstat (limited to 'include')
-rw-r--r--include/nms/snmp.pm91
1 files changed, 0 insertions, 91 deletions
diff --git a/include/nms/snmp.pm b/include/nms/snmp.pm
deleted file mode 100644
index 5e3adac..0000000
--- a/include/nms/snmp.pm
+++ /dev/null
@@ -1,91 +0,0 @@
-#! /usr/bin/perl
-use strict;
-use warnings;
-use SNMP;
-use nms;
-package nms::snmp;
-
-use base 'Exporter';
-our @EXPORT = qw();
-
-BEGIN {
- # FIXME: Should be configurable.
- #$SNMP::debugging = 1;
-
- SNMP::initMib();
-
- # FIXME: This is just plain dumb.
- SNMP::addMibDirs("/srv/tgmanage/mibs/StandardMibs");
- SNMP::addMibDirs("/srv/tgmanage/mibs/JuniperMibs");
-
- SNMP::loadModules('SNMPv2-MIB');
- SNMP::loadModules('ENTITY-MIB');
- SNMP::loadModules('IF-MIB');
- SNMP::loadModules('LLDP-MIB');
- SNMP::loadModules('IP-MIB');
- SNMP::loadModules('IP-FORWARD-MIB');
-}
-
-sub snmp_open_session {
- my ($ip, $community, $async) = @_;
-
- $async //= 0;
-
- my %options = (UseEnums => 1);
- if ($ip =~ /:/) {
- $options{'DestHost'} = "udp6:$ip";
- } else {
- $options{'DestHost'} = "udp:$ip";
- }
-
- if ($community =~ /^snmpv3:(.*)$/) {
- my ($username, $authprotocol, $authpassword, $privprotocol, $privpassword) = split /\//, $1;
-
- $options{'SecName'} = $username;
- $options{'SecLevel'} = 'authNoPriv';
- $options{'AuthProto'} = $authprotocol;
- $options{'AuthPass'} = $authpassword;
-
- if (defined($privprotocol) && defined($privpassword)) {
- $options{'SecLevel'} = 'authPriv';
- $options{'PrivProto'} = $privprotocol;
- $options{'PrivPass'} = $privpassword;
- }
-
- $options{'Version'} = 3;
- } else {
- $options{'Community'} = $community;
- $options{'Version'} = 2;
- }
-
- my $session = SNMP::Session->new(%options);
- if (defined($session) && ($async || defined($session->getnext('sysDescr')))) {
- return $session;
- } else {
- die 'Could not open SNMP session to ' . $ip;
- }
-}
-
-# Not currently in use; kept around for reference.
-sub fetch_multi_snmp {
- my ($session, @oids) = @_;
-
- my %results = ();
-
- # Do bulk reads of 40 and 40; seems to be about the right size for 1500-byte packets.
- for (my $i = 0; $i < scalar @oids; $i += 40) {
- my $end = $i + 39;
- $end = $#oids if ($end > $#oids);
- my @oid_slice = @oids[$i..$end];
-
- my $localresults = $session->get_request(-varbindlist => \@oid_slice);
- return undef if (!defined($localresults));
-
- while (my ($key, $value) = each %$localresults) {
- $results{$key} = $value;
- }
- }
-
- return \%results;
-}
-