Linux web0273.sh.tyo1 4.18.0-553.141.2.lve.el7h.x86_64 #1 SMP Wed Jul 8 17:20:31 UTC 2026 x86_64
Apache
: 127.0.0.1 | : 216.73.216.133
Cant Read [ /etc/named.conf ]
8.3.31
r2745769
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
share /
perl5 /
vendor_perl /
[ HOME SHELL ]
Name
Size
Permission
Action
Algorithm
[ DIR ]
drwxr-xr-x
Alien
[ DIR ]
drwxr-xr-x
Any
[ DIR ]
drwxr-xr-x
AnyEvent
[ DIR ]
drwxr-xr-x
Apache
[ DIR ]
drwxr-xr-x
Apache2
[ DIR ]
drwxr-xr-x
App
[ DIR ]
drwxr-xr-x
AppConfig
[ DIR ]
drwxr-xr-x
Archive
[ DIR ]
drwxr-xr-x
Array
[ DIR ]
drwxr-xr-x
Astro
[ DIR ]
drwxr-xr-x
Authen
[ DIR ]
drwxr-xr-x
B
[ DIR ]
drwxr-xr-x
BZ
[ DIR ]
drwxr-xr-x
Boulder
[ DIR ]
drwxr-xr-x
Browser
[ DIR ]
drwxr-xr-x
Bundle
[ DIR ]
drwxr-xr-x
Business
[ DIR ]
drwxr-xr-x
Bytes
[ DIR ]
drwxr-xr-x
CGI
[ DIR ]
drwxr-xr-x
CHI
[ DIR ]
drwxr-xr-x
CPAN
[ DIR ]
drwxr-xr-x
CPANPLUS
[ DIR ]
drwxr-xr-x
CSS
[ DIR ]
drwxr-xr-x
Cache
[ DIR ]
drwxr-xr-x
Canary
[ DIR ]
drwxr-xr-x
Carp
[ DIR ]
drwxr-xr-x
Check
[ DIR ]
drwxr-xr-x
Child
[ DIR ]
drwxr-xr-x
Class
[ DIR ]
drwxr-xr-x
Clipboard
[ DIR ]
drwxr-xr-x
Clone
[ DIR ]
drwxr-xr-x
Collectd
[ DIR ]
drwxr-xr-x
Config
[ DIR ]
drwxr-xr-x
ConfigReader
[ DIR ]
drwxr-xr-x
Context
[ DIR ]
drwxr-xr-x
Contextual
[ DIR ]
drwxr-xr-x
Convert
[ DIR ]
drwxr-xr-x
Crypt
[ DIR ]
drwxr-xr-x
Curses
[ DIR ]
drwxr-xr-x
Cwd
[ DIR ]
drwxr-xr-x
DBD
[ DIR ]
drwxr-xr-x
DBIx
[ DIR ]
drwxr-xr-x
DBM
[ DIR ]
drwxr-xr-x
DB_File
[ DIR ]
drwxr-xr-x
Data
[ DIR ]
drwxr-xr-x
Database
[ DIR ]
drwxr-xr-x
Date
[ DIR ]
drwxr-xr-x
DateTime
[ DIR ]
drwxr-xr-x
DateTimeX
[ DIR ]
drwxr-xr-x
Declare
[ DIR ]
drwxr-xr-x
Devel
[ DIR ]
drwxr-xr-x
Digest
[ DIR ]
drwxr-xr-x
Directory
[ DIR ]
drwxr-xr-x
Dist
[ DIR ]
drwxr-xr-x
DynaLoader
[ DIR ]
drwxr-xr-x
Email
[ DIR ]
drwxr-xr-x
Encode
[ DIR ]
drwxr-xr-x
Env
[ DIR ]
drwxr-xr-x
Error
[ DIR ]
drwxr-xr-x
Eval
[ DIR ]
drwxr-xr-x
Excel
[ DIR ]
drwxr-xr-x
Exception
[ DIR ]
drwxr-xr-x
Exporter
[ DIR ]
drwxr-xr-x
ExtUtils
[ DIR ]
drwxr-xr-x
FCGI
[ DIR ]
drwxr-xr-x
Feed
[ DIR ]
drwxr-xr-x
Fennec
[ DIR ]
drwxr-xr-x
File
[ DIR ]
drwxr-xr-x
FileHandle
[ DIR ]
drwxr-xr-x
Filesys
[ DIR ]
drwxr-xr-x
Finance
[ DIR ]
drwxr-xr-x
Font
[ DIR ]
drwxr-xr-x
Frontier
[ DIR ]
drwxr-xr-x
Fsdb
[ DIR ]
drwxr-xr-x
GD
[ DIR ]
drwxr-xr-x
Geography
[ DIR ]
drwxr-xr-x
Getopt
[ DIR ]
drwxr-xr-x
Git
[ DIR ]
drwxr-xr-x
GraphViz
[ DIR ]
drwxr-xr-x
Gtk3
[ DIR ]
drwxr-xr-x
HTML
[ DIR ]
drwxr-xr-x
HTTP
[ DIR ]
drwxr-xr-x
Hash
[ DIR ]
drwxr-xr-x
Heap
[ DIR ]
drwxr-xr-x
Hook
[ DIR ]
drwxr-xr-x
IO
[ DIR ]
drwxr-xr-x
IPC
[ DIR ]
drwxr-xr-x
IPTables
[ DIR ]
drwxr-xr-x
IRC
[ DIR ]
drwxr-xr-x
Image
[ DIR ]
drwxr-xr-x
Import
[ DIR ]
drwxr-xr-x
Inline
[ DIR ]
drwxr-xr-x
JSON
[ DIR ]
drwxr-xr-x
JavaScript
[ DIR ]
drwxr-xr-x
Jcode
[ DIR ]
drwxr-xr-x
LWP
[ DIR ]
drwxr-xr-x
Lexical
[ DIR ]
drwxr-xr-x
Lingua
[ DIR ]
drwxr-xr-x
List
[ DIR ]
drwxr-xr-x
Locale
[ DIR ]
drwxr-xr-x
LockFile
[ DIR ]
drwxr-xr-x
Log
[ DIR ]
drwxr-xr-x
MCE
[ DIR ]
drwxr-xr-x
MIME
[ DIR ]
drwxr-xr-x
MLDBM
[ DIR ]
drwxr-xr-x
MRO
[ DIR ]
drwxr-xr-x
Mail
[ DIR ]
drwxr-xr-x
Math
[ DIR ]
drwxr-xr-x
Messaging
[ DIR ]
drwxr-xr-x
Meta
[ DIR ]
drwxr-xr-x
MetaCPAN
[ DIR ]
drwxr-xr-x
Mixin
[ DIR ]
drwxr-xr-x
Mo
[ DIR ]
drwxr-xr-x
Mock
[ DIR ]
drwxr-xr-x
Modern
[ DIR ]
drwxr-xr-x
Module
[ DIR ]
drwxr-xr-x
Mojo
[ DIR ]
drwxr-xr-x
Mojolicious
[ DIR ]
drwxr-xr-x
Mon
[ DIR ]
drwxr-xr-x
Monitoring
[ DIR ]
drwxr-xr-x
Monkey
[ DIR ]
drwxr-xr-x
MooseX
[ DIR ]
drwxr-xr-x
MouseX
[ DIR ]
drwxr-xr-x
Mozilla
[ DIR ]
drwxr-xr-x
Nagios
[ DIR ]
drwxr-xr-x
Net
[ DIR ]
drwxr-xr-x
NetPacket
[ DIR ]
drwxr-xr-x
Nmap
[ DIR ]
drwxr-xr-x
No
[ DIR ]
drwxr-xr-x
Number
[ DIR ]
drwxr-xr-x
OLE
[ DIR ]
drwxr-xr-x
Object
[ DIR ]
drwxr-xr-x
Ocsinventory
[ DIR ]
drwxr-xr-x
PAR
[ DIR ]
drwxr-xr-x
PCP
[ DIR ]
drwxr-xr-x
PDF
[ DIR ]
drwxr-xr-x
PHP
[ DIR ]
drwxr-xr-x
POD2
[ DIR ]
drwxr-xr-x
POE
[ DIR ]
drwxr-xr-x
PPI
[ DIR ]
drwxr-xr-x
PPIx
[ DIR ]
drwxr-xr-x
PSGI
[ DIR ]
drwxr-xr-x
Package
[ DIR ]
drwxr-xr-x
Parallel
[ DIR ]
drwxr-xr-x
Params
[ DIR ]
drwxr-xr-x
Parse
[ DIR ]
drwxr-xr-x
Path
[ DIR ]
drwxr-xr-x
Perl
[ DIR ]
drwxr-xr-x
Perl4
[ DIR ]
drwxr-xr-x
Perl6
[ DIR ]
drwxr-xr-x
PerlIO
[ DIR ]
drwxr-xr-x
Plack
[ DIR ]
drwxr-xr-x
Pod
[ DIR ]
drwxr-xr-x
Probe
[ DIR ]
drwxr-xr-x
Proc
[ DIR ]
drwxr-xr-x
Protocol
[ DIR ]
drwxr-xr-x
REST
[ DIR ]
drwxr-xr-x
RPC
[ DIR ]
drwxr-xr-x
Razor2
[ DIR ]
drwxr-xr-x
Redis
[ DIR ]
drwxr-xr-x
Ref
[ DIR ]
drwxr-xr-x
Regexp
[ DIR ]
drwxr-xr-x
Return
[ DIR ]
drwxr-xr-x
Role
[ DIR ]
drwxr-xr-x
Rose
[ DIR ]
drwxr-xr-x
SGMLS
[ DIR ]
drwxr-xr-x
SNMP
[ DIR ]
drwxr-xr-x
SOAP
[ DIR ]
drwxr-xr-x
SQL
[ DIR ]
drwxr-xr-x
Safe
[ DIR ]
drwxr-xr-x
Scalar
[ DIR ]
drwxr-xr-x
Schedule
[ DIR ]
drwxr-xr-x
Scope
[ DIR ]
drwxr-xr-x
Set
[ DIR ]
drwxr-xr-x
Shared
[ DIR ]
drwxr-xr-x
Software
[ DIR ]
drwxr-xr-x
Sort
[ DIR ]
drwxr-xr-x
Spiffy
[ DIR ]
drwxr-xr-x
Spreadsheet
[ DIR ]
drwxr-xr-x
StackTrace
[ DIR ]
drwxr-xr-x
Statistics
[ DIR ]
drwxr-xr-x
Stone
[ DIR ]
drwxr-xr-x
String
[ DIR ]
drwxr-xr-x
Sub
[ DIR ]
drwxr-xr-x
Swatch
[ DIR ]
drwxr-xr-x
Symbol
[ DIR ]
drwxr-xr-x
Syntax
[ DIR ]
drwxr-xr-x
Sys
[ DIR ]
drwxr-xr-x
Sysadm
[ DIR ]
drwxr-xr-x
TAP
[ DIR ]
drwxr-xr-x
Tangerine
[ DIR ]
drwxr-xr-x
Task
[ DIR ]
drwxr-xr-x
TeX
[ DIR ]
drwxr-xr-x
Template
[ DIR ]
drwxr-xr-x
Term
[ DIR ]
drwxr-xr-x
Test
[ DIR ]
drwxr-xr-x
Test2
[ DIR ]
drwxr-xr-x
Text
[ DIR ]
drwxr-xr-x
Thread
[ DIR ]
drwxr-xr-x
Thrift
[ DIR ]
drwxr-xr-x
Throwable
[ DIR ]
drwxr-xr-x
Tie
[ DIR ]
drwxr-xr-x
Time
[ DIR ]
drwxr-xr-x
Tk
[ DIR ]
drwxr-xr-x
Tree
[ DIR ]
drwxr-xr-x
Try
[ DIR ]
drwxr-xr-x
Types
[ DIR ]
drwxr-xr-x
UNIVERSAL
[ DIR ]
drwxr-xr-x
URI
[ DIR ]
drwxr-xr-x
Unicode
[ DIR ]
drwxr-xr-x
User
[ DIR ]
drwxr-xr-x
VM
[ DIR ]
drwxr-xr-x
Version
[ DIR ]
drwxr-xr-x
WWW
[ DIR ]
drwxr-xr-x
WebService
[ DIR ]
drwxr-xr-x
X10
[ DIR ]
drwxr-xr-x
X11
[ DIR ]
drwxr-xr-x
X2Go
[ DIR ]
drwxr-xr-x
XBase
[ DIR ]
drwxr-xr-x
XML
[ DIR ]
drwxr-xr-x
XMLRPC
[ DIR ]
drwxr-xr-x
YAML
[ DIR ]
drwxr-xr-x
ZMQ
[ DIR ]
drwxr-xr-x
auto
[ DIR ]
drwxr-xr-x
autobox
[ DIR ]
drwxr-xr-x
autodie
[ DIR ]
drwxr-xr-x
common
[ DIR ]
drwxr-xr-x
constant
[ DIR ]
drwxr-xr-x
inc
[ DIR ]
drwxr-xr-x
lib
[ DIR ]
drwxr-xr-x
local
[ DIR ]
drwxr-xr-x
namespace
[ DIR ]
drwxr-xr-x
odern
[ DIR ]
drwxr-xr-x
perl5i
[ DIR ]
drwxr-xr-x
utf8
[ DIR ]
drwxr-xr-x
AppConfig.pm
31.75
KB
-rw-r--r--
AuthCAS.pm
16.91
KB
-rw-r--r--
BER.pm
27.14
KB
-rw-r--r--
Boulder.pod
6.23
KB
-rw-r--r--
CGI.pm
255.24
KB
-rw-r--r--
CHI.pm
46.06
KB
-rw-r--r--
CLASS.pm
1.44
KB
-rw-r--r--
CPANPLUS.pm
7.05
KB
-rw-r--r--
Carp.pm
19.93
KB
-rw-r--r--
Child.pm
6.31
KB
-rw-r--r--
Clipboard.pm
6.09
KB
-rw-r--r--
Collectd.pm
12.61
KB
-r--r--r--
Digest.pm
10.35
KB
-rw-r--r--
Env.pm
5.39
KB
-rw-r--r--
Error.pm
24.27
KB
-rw-r--r--
Expect.pm
53.44
KB
-rw-r--r--
Expect.pod
42.71
KB
-rw-r--r--
Exporter.pm
18.31
KB
-rw-r--r--
Fatal.pm
45.16
KB
-rw-r--r--
Fennec.pm
32.31
KB
-rw-r--r--
FreezeThaw.pm
24.68
KB
-rw-r--r--
Fsdb.pm
91.97
KB
-rw-r--r--
Git.pm
42.55
KB
-r--r--r--
GraphViz.pm
37.08
KB
-rw-r--r--
Gtk3.pm
68.19
KB
-rw-r--r--
Heap.pm
3.8
KB
-rw-r--r--
Inline-API.pod
12.79
KB
-rw-r--r--
Inline-FAQ.pod
6.83
KB
-rw-r--r--
Inline-Support.pod
3.36
KB
-rw-r--r--
Inline.pm
57.2
KB
-rw-r--r--
Inline.pod
38.48
KB
-rw-r--r--
JSON.pm
67.04
KB
-rw-r--r--
Jcode.pm
22.57
KB
-rw-r--r--
LW.pm
8.13
KB
-rw-r--r--
LW2.pm
191.49
KB
-rw-r--r--
MCE.pm
65.36
KB
-rw-r--r--
MCE.pod
7.62
KB
-rw-r--r--
MLDBM.pm
16.21
KB
-rw-r--r--
Mo.pm
560
B
-rw-r--r--
Mo.pod
3.33
KB
-rw-r--r--
Mojo.pm
1.62
KB
-rw-r--r--
Mojolicious.pm
27.54
KB
-rw-r--r--
Monotone.pm
5.4
KB
-rw-r--r--
NetPacket.pm
4.97
KB
-rw-r--r--
PAR.pm
40.11
KB
-rw-r--r--
POE.pm
26.06
KB
-rw-r--r--
PPI.pm
30.58
KB
-rw-r--r--
PSGI.pm
41
B
-rw-r--r--
PSGI.pod
20.21
KB
-rw-r--r--
ReadMe.pod
3.33
KB
-rw-r--r--
Readonly.pm
21.94
KB
-rw-r--r--
Redis.pm
64.92
KB
-rw-r--r--
SGMLS.pm
26.18
KB
-rw-r--r--
SNMP_Session.pm
34.54
KB
-rw-r--r--
SNMP_util.pm
40.27
KB
-rw-r--r--
SUPER.pm
6.63
KB
-rw-r--r--
Sereal.pm
5.29
KB
-rw-r--r--
Spiffy.pm
32.31
KB
-rw-r--r--
Spiffy.pod
17.43
KB
-rw-r--r--
Stone.pm
30.88
KB
-rw-r--r--
Switch.pm
27.79
KB
-rw-r--r--
Tangerine.pm
6.84
KB
-rw-r--r--
Test2.pm
4.03
KB
-rw-r--r--
Thrift.pm
4.1
KB
-r--r--r--
Throwable.pm
1.77
KB
-rw-r--r--
User.pm
2.47
KB
-rw-r--r--
X10.pm
5.18
KB
-rw-r--r--
XBase.pm
39.44
KB
-rw-r--r--
YAML.pm
24.29
KB
-rw-r--r--
abbrev.pl
819
B
-rw-r--r--
aliased.pm
9.39
KB
-rw-r--r--
asa.pm
5.29
KB
-rw-r--r--
assert.pl
1.27
KB
-rw-r--r--
autodie.pm
11.83
KB
-rw-r--r--
bigfloat.pl
7.14
KB
-rw-r--r--
bigint.pl
8.71
KB
-rw-r--r--
bigrat.pl
4.35
KB
-rw-r--r--
boolean.pm
5.75
KB
-rw-r--r--
cacheout.pl
1.1
KB
-rw-r--r--
chat2.pl
9.73
KB
-rw-r--r--
complete.pl
3.12
KB
-rw-r--r--
constant.pm
13.04
KB
-rw-r--r--
cpanfile-faq.pod
4.39
KB
-rw-r--r--
cpanfile.pod
3.39
KB
-rw-r--r--
ctime.pl
1.93
KB
-rw-r--r--
dotsh.pl
2.12
KB
-rw-r--r--
enum.pm
10.63
KB
-rw-r--r--
exceptions.pl
1.7
KB
-rw-r--r--
experimental.pm
6.83
KB
-rw-r--r--
fastcwd.pl
1019
B
-rw-r--r--
find.pl
1.16
KB
-rw-r--r--
finddepth.pl
1.1
KB
-rw-r--r--
flush.pl
642
B
-rw-r--r--
ftp.pl
23.53
KB
-rw-r--r--
getcwd.pl
1.37
KB
-rw-r--r--
getopt.pl
1.27
KB
-rw-r--r--
getopts.pl
1.35
KB
-rw-r--r--
hostname.pl
727
B
-rw-r--r--
importenv.pl
283
B
-rw-r--r--
look.pl
1.23
KB
-rw-r--r--
newgetopt.pl
2.15
KB
-rw-r--r--
ojo.pm
6.81
KB
-rw-r--r--
ok.pm
946
B
-rw-r--r--
open2.pl
185
B
-rw-r--r--
open3.pl
185
B
-rw-r--r--
parent.pm
2.83
KB
-rw-r--r--
perl5i.pm
32.97
KB
-rw-r--r--
perl5ifaq.pod
14.01
KB
-rw-r--r--
perldoc.pod
8.25
KB
-rw-r--r--
pmtools.pm
2.4
KB
-rw-r--r--
pp.pm
20.05
KB
-rw-r--r--
prefork.pm
10.17
KB
-rw-r--r--
pwd.pl
1.44
KB
-rw-r--r--
shellwords.pl
280
B
-rw-r--r--
skel.pl
4.74
KB
-rw-r--r--
stat.pl
525
B
-rw-r--r--
syslog.pl
4.69
KB
-rw-r--r--
tainted.pl
164
B
-rw-r--r--
termcap.pl
4.02
KB
-rw-r--r--
timelocal.pl
690
B
-rw-r--r--
ttfmod.pl
6.62
KB
-rw-r--r--
validate.pl
3.64
KB
-rw-r--r--
yui.pm
132.76
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : SNMP_util.pm
### - *- mode: Perl -*- ###################################################################### ### SNMP_util -- SNMP utilities using SNMP_Session.pm and BER.pm ###################################################################### ### Copyright (c) 1998-2008, Mike Mitchell. ### ### This program is free software; you can redistribute it under the ### "Artistic License 2.0" included in this distribution ### (file "Artistic"). ###################################################################### ### Created by: Mike Mitchell <Mike.Mitchell@sas.com> ### ### Contributions and fixes by: ### ### Tobias Oetiker <tobi@oetiker.ch>: Basic layout ### Simon Leinen <simon@switch.ch>: SNMP_session.pm/BER.pm ### Jeff Allen <jeff.allen@acm.org>: length() of undefined value ### Johannes Demel <demel@zid.tuwien.ac.at>: MIB file parse problem ### Simon Leinen <simon@switch.ch>: more OIDs from Interface MIB ### Jacques Supcik <supcik@ip-plus.net>: Specify local IP, port ### Tobias Oetiker <tobi@oetiker.ch>: HASH as first OID to set SNMP options ### Simon Leinen <simon@switch.ch>: 'undefined port' bug ### Daniel McDonald <dmcdonald@digicontech.com>: request for getbulk support ### Laurent Girod <it.fb@net2000.ch>: code for snmpwalkhash ### Ian Duplisse <i.duplisse@cablelabs.com>: MIB parsing suggestions ### Jakob Ilves <jakob.ilves@oracle.com>: return_array_refs for snmpwalk() ### Valerio Bontempi <v.bontempi@inwind.it>: IPv6 support ### Lorenzo Colitti <lorenzo@colitti.com>: IPv6 support ### Joerg Kummer <JOERG.KUMMER@Roche.COM>: TimeTicks support in snmpset() ### Christopher J. Tengi <tengi@CS.Princeton.EDU>: Gauge32 support in snmpset() ### Nicolai Petri <nicolai@catpipe.net>: hashref passing for snmpwalkhash() ###################################################################### package SNMP_util; require 5.004; use strict; use vars qw(@ISA @EXPORT $VERSION); use Exporter; use Carp; use BER "1.02"; use SNMP_Session "1.00"; use Socket; $VERSION = '1.13'; @ISA = qw(Exporter); @EXPORT = qw(snmpget snmpgetnext snmpwalk snmpset snmptrap snmpgetbulk snmpmaptable snmpmaptable4 snmpwalkhash snmpmapOID snmpMIB_to_OID snmpLoad_OID_Cache snmpQueue_MIB_File); # The OID numbers from RFC1213 (MIB-II) and RFC1315 (Frame Relay) # are pre-loaded below. %SNMP_util::OIDS = ( 'iso' => '1', 'org' => '1.3', 'dod' => '1.3.6', 'internet' => '1.3.6.1', 'directory' => '1.3.6.1.1', 'mgmt' => '1.3.6.1.2', 'mib-2' => '1.3.6.1.2.1', 'system' => '1.3.6.1.2.1.1', 'sysDescr' => '1.3.6.1.2.1.1.1.0', 'sysObjectID' => '1.3.6.1.2.1.1.2.0', 'sysUpTime' => '1.3.6.1.2.1.1.3.0', 'sysUptime' => '1.3.6.1.2.1.1.3.0', 'sysContact' => '1.3.6.1.2.1.1.4.0', 'sysName' => '1.3.6.1.2.1.1.5.0', 'sysLocation' => '1.3.6.1.2.1.1.6.0', 'sysServices' => '1.3.6.1.2.1.1.7.0', 'interfaces' => '1.3.6.1.2.1.2', 'ifNumber' => '1.3.6.1.2.1.2.1.0', 'ifTable' => '1.3.6.1.2.1.2.2', 'ifEntry' => '1.3.6.1.2.1.2.2.1', 'ifIndex' => '1.3.6.1.2.1.2.2.1.1', 'ifInOctets' => '1.3.6.1.2.1.2.2.1.10', 'ifInUcastPkts' => '1.3.6.1.2.1.2.2.1.11', 'ifInNUcastPkts' => '1.3.6.1.2.1.2.2.1.12', 'ifInDiscards' => '1.3.6.1.2.1.2.2.1.13', 'ifInErrors' => '1.3.6.1.2.1.2.2.1.14', 'ifInUnknownProtos' => '1.3.6.1.2.1.2.2.1.15', 'ifOutOctets' => '1.3.6.1.2.1.2.2.1.16', 'ifOutUcastPkts' => '1.3.6.1.2.1.2.2.1.17', 'ifOutNUcastPkts' => '1.3.6.1.2.1.2.2.1.18', 'ifOutDiscards' => '1.3.6.1.2.1.2.2.1.19', 'ifDescr' => '1.3.6.1.2.1.2.2.1.2', 'ifOutErrors' => '1.3.6.1.2.1.2.2.1.20', 'ifOutQLen' => '1.3.6.1.2.1.2.2.1.21', 'ifSpecific' => '1.3.6.1.2.1.2.2.1.22', 'ifType' => '1.3.6.1.2.1.2.2.1.3', 'ifMtu' => '1.3.6.1.2.1.2.2.1.4', 'ifSpeed' => '1.3.6.1.2.1.2.2.1.5', 'ifPhysAddress' => '1.3.6.1.2.1.2.2.1.6', 'ifAdminHack' => '1.3.6.1.2.1.2.2.1.7', 'ifAdminStatus' => '1.3.6.1.2.1.2.2.1.7', 'ifOperHack' => '1.3.6.1.2.1.2.2.1.8', 'ifOperStatus' => '1.3.6.1.2.1.2.2.1.8', 'ifLastChange' => '1.3.6.1.2.1.2.2.1.9', 'at' => '1.3.6.1.2.1.3', 'atTable' => '1.3.6.1.2.1.3.1', 'atEntry' => '1.3.6.1.2.1.3.1.1', 'atIfIndex' => '1.3.6.1.2.1.3.1.1.1', 'atPhysAddress' => '1.3.6.1.2.1.3.1.1.2', 'atNetAddress' => '1.3.6.1.2.1.3.1.1.3', 'ip' => '1.3.6.1.2.1.4', 'ipForwarding' => '1.3.6.1.2.1.4.1', 'ipOutRequests' => '1.3.6.1.2.1.4.10', 'ipOutDiscards' => '1.3.6.1.2.1.4.11', 'ipOutNoRoutes' => '1.3.6.1.2.1.4.12', 'ipReasmTimeout' => '1.3.6.1.2.1.4.13', 'ipReasmReqds' => '1.3.6.1.2.1.4.14', 'ipReasmOKs' => '1.3.6.1.2.1.4.15', 'ipReasmFails' => '1.3.6.1.2.1.4.16', 'ipFragOKs' => '1.3.6.1.2.1.4.17', 'ipFragFails' => '1.3.6.1.2.1.4.18', 'ipFragCreates' => '1.3.6.1.2.1.4.19', 'ipDefaultTTL' => '1.3.6.1.2.1.4.2', 'ipAddrTable' => '1.3.6.1.2.1.4.20', 'ipAddrEntry' => '1.3.6.1.2.1.4.20.1', 'ipAdEntAddr' => '1.3.6.1.2.1.4.20.1.1', 'ipAdEntIfIndex' => '1.3.6.1.2.1.4.20.1.2', 'ipAdEntNetMask' => '1.3.6.1.2.1.4.20.1.3', 'ipAdEntBcastAddr' => '1.3.6.1.2.1.4.20.1.4', 'ipAdEntReasmMaxSize' => '1.3.6.1.2.1.4.20.1.5', 'ipRouteTable' => '1.3.6.1.2.1.4.21', 'ipRouteEntry' => '1.3.6.1.2.1.4.21.1', 'ipRouteDest' => '1.3.6.1.2.1.4.21.1.1', 'ipRouteAge' => '1.3.6.1.2.1.4.21.1.10', 'ipRouteMask' => '1.3.6.1.2.1.4.21.1.11', 'ipRouteMetric5' => '1.3.6.1.2.1.4.21.1.12', 'ipRouteInfo' => '1.3.6.1.2.1.4.21.1.13', 'ipRouteIfIndex' => '1.3.6.1.2.1.4.21.1.2', 'ipRouteMetric1' => '1.3.6.1.2.1.4.21.1.3', 'ipRouteMetric2' => '1.3.6.1.2.1.4.21.1.4', 'ipRouteMetric3' => '1.3.6.1.2.1.4.21.1.5', 'ipRouteMetric4' => '1.3.6.1.2.1.4.21.1.6', 'ipRouteNextHop' => '1.3.6.1.2.1.4.21.1.7', 'ipRouteType' => '1.3.6.1.2.1.4.21.1.8', 'ipRouteProto' => '1.3.6.1.2.1.4.21.1.9', 'ipNetToMediaTable' => '1.3.6.1.2.1.4.22', 'ipNetToMediaEntry' => '1.3.6.1.2.1.4.22.1', 'ipNetToMediaIfIndex' => '1.3.6.1.2.1.4.22.1.1', 'ipNetToMediaPhysAddress' => '1.3.6.1.2.1.4.22.1.2', 'ipNetToMediaNetAddress' => '1.3.6.1.2.1.4.22.1.3', 'ipNetToMediaType' => '1.3.6.1.2.1.4.22.1.4', 'ipRoutingDiscards' => '1.3.6.1.2.1.4.23', 'ipInReceives' => '1.3.6.1.2.1.4.3', 'ipInHdrErrors' => '1.3.6.1.2.1.4.4', 'ipInAddrErrors' => '1.3.6.1.2.1.4.5', 'ipForwDatagrams' => '1.3.6.1.2.1.4.6', 'ipInUnknownProtos' => '1.3.6.1.2.1.4.7', 'ipInDiscards' => '1.3.6.1.2.1.4.8', 'ipInDelivers' => '1.3.6.1.2.1.4.9', 'icmp' => '1.3.6.1.2.1.5', 'icmpInMsgs' => '1.3.6.1.2.1.5.1', 'icmpInTimestamps' => '1.3.6.1.2.1.5.10', 'icmpInTimestampReps' => '1.3.6.1.2.1.5.11', 'icmpInAddrMasks' => '1.3.6.1.2.1.5.12', 'icmpInAddrMaskReps' => '1.3.6.1.2.1.5.13', 'icmpOutMsgs' => '1.3.6.1.2.1.5.14', 'icmpOutErrors' => '1.3.6.1.2.1.5.15', 'icmpOutDestUnreachs' => '1.3.6.1.2.1.5.16', 'icmpOutTimeExcds' => '1.3.6.1.2.1.5.17', 'icmpOutParmProbs' => '1.3.6.1.2.1.5.18', 'icmpOutSrcQuenchs' => '1.3.6.1.2.1.5.19', 'icmpInErrors' => '1.3.6.1.2.1.5.2', 'icmpOutRedirects' => '1.3.6.1.2.1.5.20', 'icmpOutEchos' => '1.3.6.1.2.1.5.21', 'icmpOutEchoReps' => '1.3.6.1.2.1.5.22', 'icmpOutTimestamps' => '1.3.6.1.2.1.5.23', 'icmpOutTimestampReps' => '1.3.6.1.2.1.5.24', 'icmpOutAddrMasks' => '1.3.6.1.2.1.5.25', 'icmpOutAddrMaskReps' => '1.3.6.1.2.1.5.26', 'icmpInDestUnreachs' => '1.3.6.1.2.1.5.3', 'icmpInTimeExcds' => '1.3.6.1.2.1.5.4', 'icmpInParmProbs' => '1.3.6.1.2.1.5.5', 'icmpInSrcQuenchs' => '1.3.6.1.2.1.5.6', 'icmpInRedirects' => '1.3.6.1.2.1.5.7', 'icmpInEchos' => '1.3.6.1.2.1.5.8', 'icmpInEchoReps' => '1.3.6.1.2.1.5.9', 'tcp' => '1.3.6.1.2.1.6', 'tcpRtoAlgorithm' => '1.3.6.1.2.1.6.1', 'tcpInSegs' => '1.3.6.1.2.1.6.10', 'tcpOutSegs' => '1.3.6.1.2.1.6.11', 'tcpRetransSegs' => '1.3.6.1.2.1.6.12', 'tcpConnTable' => '1.3.6.1.2.1.6.13', 'tcpConnEntry' => '1.3.6.1.2.1.6.13.1', 'tcpConnState' => '1.3.6.1.2.1.6.13.1.1', 'tcpConnLocalAddress' => '1.3.6.1.2.1.6.13.1.2', 'tcpConnLocalPort' => '1.3.6.1.2.1.6.13.1.3', 'tcpConnRemAddress' => '1.3.6.1.2.1.6.13.1.4', 'tcpConnRemPort' => '1.3.6.1.2.1.6.13.1.5', 'tcpInErrs' => '1.3.6.1.2.1.6.14', 'tcpOutRsts' => '1.3.6.1.2.1.6.15', 'tcpRtoMin' => '1.3.6.1.2.1.6.2', 'tcpRtoMax' => '1.3.6.1.2.1.6.3', 'tcpMaxConn' => '1.3.6.1.2.1.6.4', 'tcpActiveOpens' => '1.3.6.1.2.1.6.5', 'tcpPassiveOpens' => '1.3.6.1.2.1.6.6', 'tcpAttemptFails' => '1.3.6.1.2.1.6.7', 'tcpEstabResets' => '1.3.6.1.2.1.6.8', 'tcpCurrEstab' => '1.3.6.1.2.1.6.9', 'udp' => '1.3.6.1.2.1.7', 'udpInDatagrams' => '1.3.6.1.2.1.7.1', 'udpNoPorts' => '1.3.6.1.2.1.7.2', 'udpInErrors' => '1.3.6.1.2.1.7.3', 'udpOutDatagrams' => '1.3.6.1.2.1.7.4', 'udpTable' => '1.3.6.1.2.1.7.5', 'udpEntry' => '1.3.6.1.2.1.7.5.1', 'udpLocalAddress' => '1.3.6.1.2.1.7.5.1.1', 'udpLocalPort' => '1.3.6.1.2.1.7.5.1.2', 'egp' => '1.3.6.1.2.1.8', 'egpInMsgs' => '1.3.6.1.2.1.8.1', 'egpInErrors' => '1.3.6.1.2.1.8.2', 'egpOutMsgs' => '1.3.6.1.2.1.8.3', 'egpOutErrors' => '1.3.6.1.2.1.8.4', 'egpNeighTable' => '1.3.6.1.2.1.8.5', 'egpNeighEntry' => '1.3.6.1.2.1.8.5.1', 'egpNeighState' => '1.3.6.1.2.1.8.5.1.1', 'egpNeighStateUps' => '1.3.6.1.2.1.8.5.1.10', 'egpNeighStateDowns' => '1.3.6.1.2.1.8.5.1.11', 'egpNeighIntervalHello' => '1.3.6.1.2.1.8.5.1.12', 'egpNeighIntervalPoll' => '1.3.6.1.2.1.8.5.1.13', 'egpNeighMode' => '1.3.6.1.2.1.8.5.1.14', 'egpNeighEventTrigger' => '1.3.6.1.2.1.8.5.1.15', 'egpNeighAddr' => '1.3.6.1.2.1.8.5.1.2', 'egpNeighAs' => '1.3.6.1.2.1.8.5.1.3', 'egpNeighInMsgs' => '1.3.6.1.2.1.8.5.1.4', 'egpNeighInErrs' => '1.3.6.1.2.1.8.5.1.5', 'egpNeighOutMsgs' => '1.3.6.1.2.1.8.5.1.6', 'egpNeighOutErrs' => '1.3.6.1.2.1.8.5.1.7', 'egpNeighInErrMsgs' => '1.3.6.1.2.1.8.5.1.8', 'egpNeighOutErrMsgs' => '1.3.6.1.2.1.8.5.1.9', 'egpAs' => '1.3.6.1.2.1.8.6', 'transmission' => '1.3.6.1.2.1.10', 'frame-relay' => '1.3.6.1.2.1.10.32', 'frDlcmiTable' => '1.3.6.1.2.1.10.32.1', 'frDlcmiEntry' => '1.3.6.1.2.1.10.32.1.1', 'frDlcmiIfIndex' => '1.3.6.1.2.1.10.32.1.1.1', 'frDlcmiState' => '1.3.6.1.2.1.10.32.1.1.2', 'frDlcmiAddress' => '1.3.6.1.2.1.10.32.1.1.3', 'frDlcmiAddressLen' => '1.3.6.1.2.1.10.32.1.1.4', 'frDlcmiPollingInterval' => '1.3.6.1.2.1.10.32.1.1.5', 'frDlcmiFullEnquiryInterval' => '1.3.6.1.2.1.10.32.1.1.6', 'frDlcmiErrorThreshold' => '1.3.6.1.2.1.10.32.1.1.7', 'frDlcmiMonitoredEvents' => '1.3.6.1.2.1.10.32.1.1.8', 'frDlcmiMaxSupportedVCs' => '1.3.6.1.2.1.10.32.1.1.9', 'frDlcmiMulticast' => '1.3.6.1.2.1.10.32.1.1.10', 'frCircuitTable' => '1.3.6.1.2.1.10.32.2', 'frCircuitEntry' => '1.3.6.1.2.1.10.32.2.1', 'frCircuitIfIndex' => '1.3.6.1.2.1.10.32.2.1.1', 'frCircuitDlci' => '1.3.6.1.2.1.10.32.2.1.2', 'frCircuitState' => '1.3.6.1.2.1.10.32.2.1.3', 'frCircuitReceivedFECNs' => '1.3.6.1.2.1.10.32.2.1.4', 'frCircuitReceivedBECNs' => '1.3.6.1.2.1.10.32.2.1.5', 'frCircuitSentFrames' => '1.3.6.1.2.1.10.32.2.1.6', 'frCircuitSentOctets' => '1.3.6.1.2.1.10.32.2.1.7', 'frOutOctets' => '1.3.6.1.2.1.10.32.2.1.7', 'frCircuitReceivedFrames' => '1.3.6.1.2.1.10.32.2.1.8', 'frCircuitReceivedOctets' => '1.3.6.1.2.1.10.32.2.1.9', 'frInOctets' => '1.3.6.1.2.1.10.32.2.1.9', 'frCircuitCreationTime' => '1.3.6.1.2.1.10.32.2.1.10', 'frCircuitLastTimeChange' => '1.3.6.1.2.1.10.32.2.1.11', 'frCircuitCommittedBurst' => '1.3.6.1.2.1.10.32.2.1.12', 'frCircuitExcessBurst' => '1.3.6.1.2.1.10.32.2.1.13', 'frCircuitThroughput' => '1.3.6.1.2.1.10.32.2.1.14', 'frErrTable' => '1.3.6.1.2.1.10.32.3', 'frErrEntry' => '1.3.6.1.2.1.10.32.3.1', 'frErrIfIndex' => '1.3.6.1.2.1.10.32.3.1.1', 'frErrType' => '1.3.6.1.2.1.10.32.3.1.2', 'frErrData' => '1.3.6.1.2.1.10.32.3.1.3', 'frErrTime' => '1.3.6.1.2.1.10.32.3.1.4', 'frame-relay-globals' => '1.3.6.1.2.1.10.32.4', 'frTrapState' => '1.3.6.1.2.1.10.32.4.1', 'snmp' => '1.3.6.1.2.1.11', 'snmpInPkts' => '1.3.6.1.2.1.11.1', 'snmpInBadValues' => '1.3.6.1.2.1.11.10', 'snmpInReadOnlys' => '1.3.6.1.2.1.11.11', 'snmpInGenErrs' => '1.3.6.1.2.1.11.12', 'snmpInTotalReqVars' => '1.3.6.1.2.1.11.13', 'snmpInTotalSetVars' => '1.3.6.1.2.1.11.14', 'snmpInGetRequests' => '1.3.6.1.2.1.11.15', 'snmpInGetNexts' => '1.3.6.1.2.1.11.16', 'snmpInSetRequests' => '1.3.6.1.2.1.11.17', 'snmpInGetResponses' => '1.3.6.1.2.1.11.18', 'snmpInTraps' => '1.3.6.1.2.1.11.19', 'snmpOutPkts' => '1.3.6.1.2.1.11.2', 'snmpOutTooBigs' => '1.3.6.1.2.1.11.20', 'snmpOutNoSuchNames' => '1.3.6.1.2.1.11.21', 'snmpOutBadValues' => '1.3.6.1.2.1.11.22', 'snmpOutGenErrs' => '1.3.6.1.2.1.11.24', 'snmpOutGetRequests' => '1.3.6.1.2.1.11.25', 'snmpOutGetNexts' => '1.3.6.1.2.1.11.26', 'snmpOutSetRequests' => '1.3.6.1.2.1.11.27', 'snmpOutGetResponses' => '1.3.6.1.2.1.11.28', 'snmpOutTraps' => '1.3.6.1.2.1.11.29', 'snmpInBadVersions' => '1.3.6.1.2.1.11.3', 'snmpEnableAuthenTraps' => '1.3.6.1.2.1.11.30', 'snmpInBadCommunityNames' => '1.3.6.1.2.1.11.4', 'snmpInBadCommunityUses' => '1.3.6.1.2.1.11.5', 'snmpInASNParseErrs' => '1.3.6.1.2.1.11.6', 'snmpInTooBigs' => '1.3.6.1.2.1.11.8', 'snmpInNoSuchNames' => '1.3.6.1.2.1.11.9', 'ifName' => '1.3.6.1.2.1.31.1.1.1.1', 'ifInMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.2', 'ifInBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.3', 'ifOutMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.4', 'ifOutBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.5', 'ifHCInOctets' => '1.3.6.1.2.1.31.1.1.1.6', 'ifHCInUcastPkts' => '1.3.6.1.2.1.31.1.1.1.7', 'ifHCInMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.8', 'ifHCInBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.9', 'ifHCOutOctets' => '1.3.6.1.2.1.31.1.1.1.10', 'ifHCOutUcastPkts' => '1.3.6.1.2.1.31.1.1.1.11', 'ifHCOutMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.12', 'ifHCOutBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.13', 'ifLinkUpDownTrapEnable' => '1.3.6.1.2.1.31.1.1.1.14', 'ifHighSpeed' => '1.3.6.1.2.1.31.1.1.1.15', 'ifPromiscuousMode' => '1.3.6.1.2.1.31.1.1.1.16', 'ifConnectorPresent' => '1.3.6.1.2.1.31.1.1.1.17', 'ifAlias' => '1.3.6.1.2.1.31.1.1.1.18', 'ifCounterDiscontinuityTime' => '1.3.6.1.2.1.31.1.1.1.19', 'experimental' => '1.3.6.1.3', 'private' => '1.3.6.1.4', 'enterprises' => '1.3.6.1.4.1', ); # GIL my %revOIDS = (); # Reversed %SNMP_util::OIDS hash my $RevNeeded = 1; my $agent_start_time = time; undef $SNMP_util::Host; undef $SNMP_util::Session; undef $SNMP_util::Version; undef $SNMP_util::LHost; undef $SNMP_util::IPv4only; $SNMP_util::Debug = 0; $SNMP_util::CacheFile = "OID_cache.txt"; $SNMP_util::CacheLoaded = 0; $SNMP_util::Return_array_refs = 0; $SNMP_util::Return_hash_refs = 0; srand(time + $$); ### Prototypes sub snmpget ($@); sub snmpgetnext ($@); sub snmpopen ($$$); sub snmpwalk ($@); sub snmpwalk_flg ($$@); sub snmpset ($@); sub snmptrap ($$$$$@); sub snmpgetbulk ($$$@); sub snmpmaptable ($$@); sub snmpmaptable4 ($$$@); sub snmpwalkhash ($$@); sub toOID (@); sub snmpmapOID (@); sub snmpMIB_to_OID ($); sub encode_oid_with_errmsg ($); sub Check_OID ($); sub snmpLoad_OID_Cache ($); sub snmpQueue_MIB_File (@); sub MIB_fill_OID ($); sub version () { $VERSION; } # # Start an snmp session # sub snmpopen ($$$) { my($host, $type, $vars) = @_; my($nhost, $port, $community, $lhost, $lport, $nlhost); my($timeout, $retries, $backoff, $version); my $v4onlystr; $type = 0 if (!defined($type)); $community = "public"; $nlhost = ""; ($community, $host) = ($1, $2) if ($host =~ /^(.*)@([^@]+)$/); # We can't split on the : character because a numeric IPv6 # address contains a variable number of :'s my $opts; if( ($host =~ /^(\[.*\]):(.*)$/) or ($host =~ /^(\[.*\])$/) ) { # Numeric IPv6 address between [] ($host, $opts) = ($1, $2); } else { # Hostname or numeric IPv4 address ($host, $opts) = split(':', $host, 2); } ($port, $timeout, $retries, $backoff, $version, $v4onlystr) = split(':', $opts, 6) if(defined($opts) and (length $opts > 0) ); undef($version) if (defined($version) and length($version) <= 0); $v4onlystr = "" unless defined $v4onlystr; $version = '1' unless defined $version; if (defined($port) and ($port =~ /^([^!]*)!(.*)$/)) { ($port, $lhost) = ($1, $2); $nlhost = $lhost; ($lhost, $lport) = ($1, $2) if ($lhost =~ /^(.*)!(.*)$/); undef($lhost) if (defined($lhost) and (length($lhost) <= 0)); undef($lport) if (defined($lport) and (length($lport) <= 0)); } undef($port) if (defined($port) and length($port) <= 0); $port = 162 if ($type == 1 and !defined($port)); $nhost = "$community\@$host"; $nhost .= ":" . $port if (defined($port)); if ((!defined($SNMP_util::Session)) or ($SNMP_util::Host ne $nhost) or ($SNMP_util::Version ne $version) or ($SNMP_util::LHost ne $nlhost) or ($SNMP_util::IPv4only ne $v4onlystr)) { if (defined($SNMP_util::Session)) { $SNMP_util::Session->close(); undef $SNMP_util::Session; undef $SNMP_util::Host; undef $SNMP_util::Version; undef $SNMP_util::LHost; undef $SNMP_util::IPv4only; } $SNMP_util::Session = ($version =~ /^2c?$/i) ? SNMPv2c_Session->open($host, $community, $port, undef, $lport, undef, $lhost, ($v4onlystr eq 'v4only') ? 1:0 ) : SNMP_Session->open($host, $community, $port, undef, $lport, undef, $lhost, ($v4onlystr eq 'v4only') ? 1:0 ); ($SNMP_util::Host = $nhost, $SNMP_util::Version = $version, $SNMP_util::LHost = $nlhost, $SNMP_util::IPv4only = $v4onlystr) if defined($SNMP_util::Session); } if (defined($SNMP_util::Session)) { if (ref $vars->[0] eq 'HASH') { my $opts = shift @$vars; foreach $type (keys %$opts) { if ($type eq 'return_array_refs') { $SNMP_util::Return_array_refs = $opts->{$type}; } elsif ($type eq 'return_hash_refs') { $SNMP_util::Return_hash_refs = $opts->{$type}; } else { if (exists $SNMP_util::Session->{$type}) { if ($type eq 'timeout') { $SNMP_util::Session->set_timeout($opts->{$type}); } elsif ($type eq 'retries') { $SNMP_util::Session->set_retries($opts->{$type}); } elsif ($type eq 'backoff') { $SNMP_util::Session->set_backoff($opts->{$type}); } else { $SNMP_util::Session->{$type} = $opts->{$type}; } } else { carp "SNMPopen Unknown SNMP Option Key '$type'\n" unless ($SNMP_Session::suppress_warnings > 1); } } } } $SNMP_util::Session->set_timeout($timeout) if (defined($timeout) and (length($timeout) > 0)); $SNMP_util::Session->set_retries($retries) if (defined($retries) and (length($retries) > 0)); $SNMP_util::Session->set_backoff($backoff) if (defined($backoff) and (length($backoff) > 0)); } return $SNMP_util::Session; } # # A restricted snmpget. # sub snmpget ($@) { my($host, @vars) = @_; my(@enoid, $var, $response, $bindings, $binding, $value, $oid, @retvals); my $session; $session = &snmpopen($host, 0, \@vars); if (!defined($session)) { carp "SNMPGET Problem for $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } @enoid = &toOID(@vars); return undef unless defined $enoid[0]; if ($session->get_request_response(@enoid)) { $response = $session->pdu_buffer; ($bindings) = $session->decode_get_response($response); while ($bindings) { ($binding, $bindings) = decode_sequence($bindings); ($oid, $value) = decode_by_template($binding, "%O%@"); my $tempo = pretty_print($value); push @retvals, $tempo; } return wantarray ? @retvals : $retvals[0]; } $var = join(' ', @vars); carp "SNMPGET Problem for $var on $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } # # A restricted snmpgetnext. # sub snmpgetnext ($@) { my($host, @vars) = @_; my(@enoid, $var, $response, $bindings, $binding); my($value, $upoid, $oid, @retvals); my($noid); my $session; $session = &snmpopen($host, 0, \@vars); if (!defined($session)) { carp "SNMPGETNEXT Problem for $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } @enoid = &toOID(@vars); return undef unless defined $enoid[0]; undef @vars; undef @retvals; foreach $noid (@enoid) { $upoid = pretty_print($noid); push(@vars, $upoid); } if ($session->getnext_request_response(@enoid)) { $response = $session->pdu_buffer; ($bindings) = $session->decode_get_response($response); while ($bindings) { ($binding, $bindings) = decode_sequence($bindings); ($oid, $value) = decode_by_template($binding, "%O%@"); my $tempo = pretty_print($oid); my $tempv = pretty_print($value); push @retvals, "$tempo:$tempv"; } return wantarray ? @retvals : $retvals[0]; } else { $var = join(' ', @vars); carp "SNMPGETNEXT Problem for $var on $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } } # # A restricted snmpwalk. # sub snmpwalk ($@) { my($host, @vars) = @_; return(&snmpwalk_flg($host, undef, @vars)); } # # Walk the MIB, putting everything you find into hashes. # sub snmpwalkhash($$@) { # my($host, $hash_sub, @vars) = @_; return(&snmpwalk_flg( @_ )); } sub snmpwalk_flg ($$@) { my($host, $hash_sub, @vars) = @_; my(@enoid, $var, $response, $bindings, $binding); my($value, $upoid, $oid, @retvals, @retvaltmprefs); my($got, @nnoid, $noid, $ok, $ix, @avars); my $session; my(%soid); my(%done, %rethash, $h_ref); $session = &snmpopen($host, 0, \@vars); if (!defined($session)) { carp "SNMPWALK Problem for $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } $h_ref = (ref $vars[$#vars] eq "HASH") ? pop(@vars) : \%rethash; @enoid = toOID(@vars); return undef unless defined $enoid[0]; # GIL # # Create/Refresh a reversed hash with oid -> name # if (defined($hash_sub) and ($RevNeeded)) { %revOIDS = reverse %SNMP_util::OIDS; $RevNeeded = 0; } $got = 0; @nnoid = @enoid; undef @vars; foreach $noid (@enoid) { $upoid = pretty_print($noid); push(@vars, $upoid); } # @vars is the original set of walked variables. # @avars is the current set of walked variables as the # walk goes on. # @vars stays static while @avars may shrink as we reach end # of walk for individual variables during PDU exchange. @avars = @vars; # IlvJa # # Create temporary array of refs to return vals. if ($SNMP_util::Return_array_refs) { for($ix = 0;$ix < scalar @vars; $ix++) { my $tmparray = []; $retvaltmprefs[$ix] = $tmparray; $retvals[$ix] = $tmparray; } } while(($SNMP_util::Version ne '1' and $session->{'use_getbulk'}) ? $session->getbulk_request_response(0, $session->default_max_repetitions(), @nnoid) : $session->getnext_request_response(@nnoid)) { $got = 1; $response = $session->pdu_buffer; ($bindings) = $session->decode_get_response($response); $ix = 0; while ($bindings) { ($binding, $bindings) = decode_sequence($bindings); unless ($nnoid[$ix]) { # IlvJa $ix = ++$ix % (scalar @avars); next; } ($oid, $value) = decode_by_template($binding, "%O%@"); $ok = 0; my $tempo = pretty_print($oid); $noid = $avars[$ix]; # IlvJa if ($tempo =~ /^$noid\./ or $tempo eq $noid ) { $ok = 1; $upoid = $noid; } else { # IlvJa # # The walk for variable $vars[$ix] has been finished as # $nnoid[$ix] no longer is in the $avar[$ix] OID tree. # So we exclude this variable from further requests. $avars[$ix] = ""; $nnoid[$ix] = ""; $retvaltmprefs[$ix] = undef if $SNMP_util::Return_array_refs; } if ($ok) { my $tmp = encode_oid_with_errmsg ($tempo); return undef unless defined $tmp; if (exists($done{$tmp})) { # GIL, Ilvja # # We've detected a loop for $nnoid[$ix], so mark it as finished. # Exclude this variable from further requests. # $avars[$ix] = ""; $nnoid[$ix] = ""; $retvaltmprefs[$ix] = undef if $SNMP_util::Return_array_refs; next; } $nnoid[$ix] = $tmp; # Keep on walking. (IlvJa) my $tempv = pretty_print($value); if (defined($hash_sub)) { # # extract name of the oid, if possible, the rest becomes the instance # my $inst = ""; my $upo = $upoid; while (!exists($revOIDS{$upo}) and length($upo)) { $upo =~ s/(\.\d+?)$//; if (defined($1) and length($1)) { $inst = $1 . $inst; } else { $upo = ""; last; } } if (length($upo) and exists($revOIDS{$upo})) { $upo = $revOIDS{$upo} . $inst; } else { $upo = $upoid; } $inst = ""; while (!exists($revOIDS{$tempo}) and length($tempo)) { $tempo =~ s/(\.\d+?)$//; if (defined($1) and length($1)) { $inst = $1 . $inst; } else { $tempo = ""; last; } } if (length($tempo) and exists($revOIDS{$tempo})) { $var = $revOIDS{$tempo}; } else { $var = pretty_print($oid); } # # call hash_sub # &$hash_sub($h_ref, $host, $var, $tempo, $inst, $tempv, $upo); } else { if ($SNMP_util::Return_array_refs) { $tempo=~s/^$upoid\.//; push @{$retvaltmprefs[$ix]}, "$tempo:$tempv"; } else { $tempo=~s/^$upoid\.// if ($#enoid <= 0); push @retvals, "$tempo:$tempv"; } } $done{$tmp} = 1; # GIL } $ix = ++$ix % (scalar @avars); } # Ok, @nnoid should contain the remaining variables for the # next request. Some or all entries in @nnoid might be the empty # string. If the nth element in @nnoid is "" that means that # the walk related to the nth variable in the last request has been # completed and we should not include that var in subsequent reqs. # Clean up both @nnoid and @avars so "" elements are removed. @nnoid = grep (($_), @nnoid); @avars = grep (($_), @avars); @retvaltmprefs = grep (($_), @retvaltmprefs); last if ($#nnoid < 0); # @nnoid empty means we are done walking. } if ($got) { if (defined($hash_sub)) { return ($h_ref) if ($SNMP_util::Return_hash_refs); return (%$h_ref); } else { return (@retvals); } } else { $var = join(' ', @vars); carp "SNMPWALK Problem for $var on $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } } # # A restricted snmpset. # sub snmpset($@) { my($host, @vars) = @_; my(@enoid, $response, $bindings, $binding); my($oid, @retvals, $type, $value, $val); my $session; $session = &snmpopen($host, 0, \@vars); if (!defined($session)) { carp "SNMPSET Problem for $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } while(@vars) { ($oid) = toOID((shift @vars)); $type = shift @vars; $value = shift @vars; $type =~ tr/A-Z/a-z/; if ($type eq "int") { $val = encode_int($value); } elsif ($type eq "integer") { $val = encode_int($value); } elsif ($type eq "string") { $val = encode_string($value); } elsif ($type eq "octetstring") { $val = encode_string($value); } elsif ($type eq "octet string") { $val = encode_string($value); } elsif ($type eq "oid") { $val = encode_oid_with_errmsg($value); } elsif ($type eq "object id") { $val = encode_oid_with_errmsg($value); } elsif ($type eq "object identifier") { $val = encode_oid_with_errmsg($value); } elsif ($type eq "ipaddr") { $val = encode_ip_address($value); } elsif ($type eq "ip address") { $val = encode_ip_address($value); } elsif ($type eq "timeticks") { $val = encode_timeticks($value); } elsif ($type eq "uint") { $val = encode_uinteger32($value); } elsif ($type eq "uinteger") { $val = encode_uinteger32($value); } elsif ($type eq "uinteger32") { $val = encode_uinteger32($value); } elsif ($type eq "unsigned int") { $val = encode_uinteger32($value); } elsif ($type eq "unsigned integer") { $val = encode_uinteger32($value); } elsif ($type eq "unsigned integer32") { $val = encode_uinteger32($value); } elsif ($type eq "counter") { $val = encode_counter32($value); } elsif ($type eq "counter32") { $val = encode_counter32($value); } elsif ($type eq "counter64") { $val = encode_counter64($value); } elsif ($type eq "gauge") { $val = encode_gauge32($value); } elsif ($type eq "gauge32") { $val = encode_gauge32($value); } else { carp "unknown SNMP type: $type\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } if (!defined($val)) { carp "SNMP type $type value $value didn't encode properly\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } push @enoid, [$oid,$val]; } return undef unless defined $enoid[0]; if ($session->set_request_response(@enoid)) { $response = $session->pdu_buffer; ($bindings) = $session->decode_get_response($response); while ($bindings) { ($binding, $bindings) = decode_sequence($bindings); ($oid, $value) = decode_by_template($binding, "%O%@"); my $tempo = pretty_print($value); push @retvals, $tempo; } return wantarray ? @retvals : $retvals[0]; } return undef; } # # Send an SNMP trap # sub snmptrap($$$$$@) { my($host, $ent, $agent, $gen, $spec, @vars) = @_; my($oid, @retvals, $type, $value); my(@enoid); my $session; $session = &snmpopen($host, 1, \@vars); if (!defined($session)) { carp "SNMPTRAP Problem for $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } if ($agent =~ /^\d+\.\d+\.\d+\.\d+(.*)/ ) { $agent = pack("C*", split /\./, $agent); } else { $agent = inet_aton($agent); } push @enoid, toOID(($ent)); push @enoid, encode_ip_address($agent); push @enoid, encode_int($gen); push @enoid, encode_int($spec); push @enoid, encode_timeticks((time-$agent_start_time) * 100); while(@vars) { ($oid) = toOID((shift @vars)); $type = shift @vars; $value = shift @vars; if ($type =~ /string/i) { $value = encode_string($value); push @enoid, [$oid,$value]; } elsif ($type =~ /ipaddr/i) { $value = encode_ip_address($value); push @enoid, [$oid,$value]; } elsif ($type =~ /int/i) { $value = encode_int($value); push @enoid, [$oid,$value]; } elsif ($type =~ /oid/i) { my $tmp = encode_oid_with_errmsg($value); return undef unless defined $tmp; push @enoid, [$oid,$tmp]; } else { carp "unknown SNMP type: $type\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } } return($session->trap_request_send(@enoid)); } # # A restricted snmpgetbulk. # sub snmpgetbulk ($$$@) { my($host, $nr, $mr, @vars) = @_; my(@enoid, $var, $response, $bindings, $binding); my($value, $upoid, $oid, @retvals); my($noid); my $session; $session = &snmpopen($host, 0, \@vars); if (!defined($session)) { carp "SNMPGETBULK Problem for $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } @enoid = &toOID(@vars); return undef unless defined $enoid[0]; undef @vars; undef @retvals; foreach $noid (@enoid) { $upoid = pretty_print($noid); push(@vars, $upoid); } if ($session->getbulk_request_response($nr, $mr, @enoid)) { $response = $session->pdu_buffer; ($bindings) = $session->decode_get_response($response); while ($bindings) { ($binding, $bindings) = decode_sequence($bindings); ($oid, $value) = decode_by_template($binding, "%O%@"); my $tempo = pretty_print($oid); my $tempv = pretty_print($value); push @retvals, "$tempo:$tempv"; } return (@retvals); } else { $var = join(' ', @vars); carp "SNMPGETBULK Problem for $var on $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } } # # walk a table, calling a user-supplied function for each # column of a table. # sub snmpmaptable($$@) { my($host, $fun, @vars) = @_; return snmpmaptable4($host, $fun, 0, @vars); } sub snmpmaptable4($$$@) { my($host, $fun, $max_reps, @vars) = @_; my(@enoid, $var, $session); $session = &snmpopen($host, 0, \@vars); if (!defined($session)) { carp "SNMPMAPTABLE Problem for $host\n" unless ($SNMP_Session::suppress_warnings > 1); return undef; } foreach $var (toOID(@vars)) { push(@enoid, [split('\.', pretty_print($var))]); } $max_reps = $session->default_max_repetitions() if ($max_reps <= 0); return $session->map_table_start_end( [@enoid], sub() { my ($ind, @vals) = @_; my (@pvals, $val); foreach $val (@vals) { push(@pvals, pretty_print($val)); } &$fun($ind, @pvals); }, "", undef, $max_reps); } # # Given an OID in either ASN.1 or mixed text/ASN.1 notation, return an # encoded OID. # sub toOID(@) { my(@vars) = @_; my($oid, $var, $tmp, $tmpv, @retvar); undef @retvar; foreach $var (@vars) { ($oid, $tmp) = &Check_OID($var); if (!$oid and $SNMP_util::CacheLoaded == 0) { $tmp = $SNMP_Session::suppress_warnings; $SNMP_Session::suppress_warnings = 1000; &snmpLoad_OID_Cache($SNMP_util::CacheFile); $SNMP_util::CacheLoaded = 1; $SNMP_Session::suppress_warnings = $tmp; ($oid, $tmp) = &Check_OID($var); } while (!$oid and $#SNMP_util::MIB_Files >= 0) { $tmp = $SNMP_Session::suppress_warnings; $SNMP_Session::suppress_warnings = 1000; snmpMIB_to_OID(shift(@SNMP_util::MIB_Files)); $SNMP_Session::suppress_warnings = $tmp; ($oid, $tmp) = &Check_OID($var); if ($oid) { open(CACHE, ">>$SNMP_util::CacheFile"); print CACHE "$tmp\t$oid\n"; close(CACHE); } } if ($oid) { $var =~ s/^$tmp/$oid/; } else { carp "Unknown SNMP var $var\n" unless ($SNMP_Session::suppress_warnings > 1); next; } while ($var =~ /\"([^\"]*)\"/) { $tmp = sprintf("%d.%s", length($1), join(".", map(ord, split(//, $1)))); $var =~ s/\"$1\"/$tmp/; } print "toOID: $var\n" if $SNMP_util::Debug; $tmp = encode_oid_with_errmsg($var); return undef unless defined $tmp; push(@retvar, $tmp); } return @retvar; } # # Add passed-in text, OID pairs to the OID mapping table. # sub snmpmapOID(@) { my(@vars) = @_; my($oid, $txt); while($#vars >= 0) { $txt = shift @vars; $oid = shift @vars; next unless($txt =~ /^[a-zA-Z][\w\-]*(\.[a-zA-Z][\w\-])*$/); next unless($oid =~ /^\d+(\.\d+)*$/); $SNMP_util::OIDS{$txt} = $oid; $RevNeeded = 1; print "snmpmapOID: $txt => $oid\n" if $SNMP_util::Debug; } return undef; } # # Open the passed-in file name and read it in to populate # the cache of text-to-OID map table. It expects lines # with two fields, the first the textual string like "ifInOctets", # and the second the OID value, like "1.3.6.1.2.1.2.2.1.10". # # blank lines and anything after a '#' or between '--' is ignored. # sub snmpLoad_OID_Cache ($) { my($arg) = @_; my($txt, $oid); if (!open(CACHE, $arg)) { carp "snmpLoad_OID_Cache: Can't open $arg: $!" unless ($SNMP_Session::suppress_warnings > 1); return -1; } while(<CACHE>) { s/#.*//; # '#' starts a comment s/--.*--//g; # comment delimited by '--', like MIBs s/--.*//; # comment started by '--' next if (/^$/); next unless (/\s/); # must have whitespace as separator chomp; ($txt, $oid) = split(' ', $_, 2); $txt = $1 if ($txt =~ /^[\'\"](.*)[\'\"]/); $oid = $1 if ($oid =~ /^[\'\"](.*)[\'\"]/); if (($txt =~ /^\.?\d+(\.\d+)*\.?$/) and ($oid !~ /^\.?\d+(\.\d+)*\.?$/)) { my($a) = $oid; $oid = $txt; $txt = $a; } $oid =~ s/^\.//; $oid =~ s/\.$//; &snmpmapOID($txt, $oid); } close(CACHE); return 0; } # # Check to see if an OID is in the text-to-OID cache. # Returns the OID and the corresponding text as two separate # elements. # sub Check_OID ($) { my($var) = @_; my($tmp, $tmpv, $oid); if ($var =~ /^[a-zA-Z][\w\-]*(\.[a-zA-Z][\w\-]*)*/) { $tmp = $&; $tmpv = $tmp; for (;;) { last if exists($SNMP_util::OIDS{$tmpv}); last if !($tmpv =~ s/^[^\.]*\.//); } $oid = $SNMP_util::OIDS{$tmpv}; if ($oid) { return ($oid, $tmp); } else { return undef; } } return ($var, $var); } # # Save the passed-in list of MIB files until an OID can't be # found in the existing table. At that time the MIB file will # be loaded, and the lookup attempted again. # sub snmpQueue_MIB_File (@) { my(@files) = @_; my($file); foreach $file (@files) { push(@SNMP_util::MIB_Files, $file); } } # # Read in the passed MIB file, parsing it # for their text-to-OID mappings # sub snmpMIB_to_OID ($) { my($arg) = @_; my($cnt, $quote, $buf, %tOIDs, $tgot); my($var, @parts, $strt, $indx, $ind, $val); if (!open(MIB, $arg)) { carp "snmpMIB_to_OID: Can't open $arg: $!" unless ($SNMP_Session::suppress_warnings > 1); return -1; } print "snmpMIB_to_OID: loading $arg\n" if $SNMP_util::Debug; $cnt = 0; $quote = 0; $tgot = 0; $buf = ''; while(<MIB>) { if ($quote) { next unless /"/; $quote = 0; } else { s/--.*--//g; # throw away comments (-- anything --) s/^\s*--.*//; # throw away comments at start of line } chomp; $buf .= ' ' . $_; $buf =~ s/"[^"]*"//g; if ($buf =~ /"/) { $quote = 1; next; } $buf =~ s/--.*--//g; # throw away comments (-- anything --) $buf =~ s/--.*//; # throw away comments (-- anything EOL) $buf =~ s/\s+/ /g; if ($buf =~ /DEFINITIONS *::= *BEGIN/) { $cnt += MIB_fill_OID(\%tOIDs) if ($tgot); $buf = ''; %tOIDs = (); $tgot = 0; next; } $buf =~ s/OBJECT-TYPE/OBJECT IDENTIFIER/; $buf =~ s/OBJECT-IDENTITY/OBJECT IDENTIFIER/; $buf =~ s/OBJECT-GROUP/OBJECT IDENTIFIER/; $buf =~ s/MODULE-IDENTITY/OBJECT IDENTIFIER/; $buf =~ s/NOTIFICATION-TYPE/OBJECT IDENTIFIER/; $buf =~ s/ IMPORTS .*\;//; $buf =~ s/ SEQUENCE *{.*}//; $buf =~ s/ SYNTAX .*//; $buf =~ s/ [\w\-]+ *::= *OBJECT IDENTIFIER//; $buf =~ s/ OBJECT IDENTIFIER.*::= *{/ OBJECT IDENTIFIER ::= {/; if ($buf =~ / ([\w\-]+) OBJECT IDENTIFIER *::= *{([^}]+)}/) { $var = $1; $buf = $2; $buf =~ s/ +$//; $buf =~ s/\s+\(/\(/g; # remove spacing around '(' $buf =~ s/\(\s+/\(/g; $buf =~ s/\s+\)/\)/g; # remove spacing before ')' @parts = split(' ', $buf); $strt = ''; foreach $indx (@parts) { if ($indx =~ /([\w\-]+)\((\d+)\)/) { $ind = $1; $val = $2; if (exists($tOIDs{$strt})) { $tOIDs{$ind} = $tOIDs{$strt} . '.' . $val; } elsif ($strt ne '') { $tOIDs{$ind} = "${strt}.${val}"; } else { $tOIDs{$ind} = $val; } $strt = $ind; $tgot = 1; } elsif ($indx =~ /^\d+$/) { if (exists($tOIDs{$strt})) { $tOIDs{$var} = $tOIDs{$strt} . '.' . $indx; } else { $tOIDs{$var} = "${strt}.${indx}"; } $tgot = 1; } else { $strt = $indx; } } $buf = ''; } } $cnt += MIB_fill_OID(\%tOIDs) if ($tgot); $RevNeeded = 1 if ($cnt > 0); return $cnt; } # # Fill the OIDS hash with results from the MIB parsing # sub MIB_fill_OID ($) { my($href) = @_; my($cnt, $changed, @del, $var, $val, @parts, $indx); my(%seen); $cnt = 0; do { $changed = 0; @del = (); foreach $var (keys %$href) { $val = $href->{$var}; @parts = split('\.', $val); $val = ''; foreach $indx (@parts) { if ($indx =~ /^\d+$/) { $val .= '.' . $indx; } else { if (exists($SNMP_util::OIDS{$indx})) { $val = $SNMP_util::OIDS{$indx}; } else { $val .= '.' . $indx; } } } if ($val =~ /^[\d\.]+$/) { $val =~ s/^\.+//; if (!exists($SNMP_util::OIDS{$var}) || (length($val) > length($SNMP_util::OIDS{$var}))) { $SNMP_util::OIDS{$var} = $val; print "'$var' => '$val'\n" if $SNMP_util::Debug; $changed = 1; $cnt++; } push @del, $var; } } foreach $var (@del) { delete $href->{$var}; } } while($changed); $Carp::CarpLevel++; foreach $var (sort keys %$href) { $val = $href->{$var}; $val =~ s/\..*//; next if (exists($seen{$val})); $seen{$val} = 1; $seen{$var} = 1; carp "snmpMIB_to_OID: prefix \"$val\" unknown, load the parent MIB first.\n" unless ($SNMP_Session::suppress_warnings > 1); } $Carp::CarpLevel--; return $cnt; } sub encode_oid_with_errmsg ($) { my ($oid) = @_; my $tmp = encode_oid(split(/\./, $oid)); if (! defined $tmp) { carp "cannot encode Object ID $oid: $BER::errmsg" unless ($SNMP_Session::suppress_warnings > 1); return undef; } return $tmp; } 1;
Close