1.snmptranslate介绍
snmptranslate命令是用来获取下一个节点的OID的值。
2.snmptranslate安装
1.snmptranslate安装
命令:
yum -y install net-snmp net-snmp-utils
[root@logstash ~]# yum -y install net-snmp net-snmp-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package matching 1:net-snmp-5.7.2-49.el7.x86_64 already installed. Checking for update.
Package matching 1:net-snmp-utils-5.7.2-49.el7.x86_64 already installed. Checking for update.
Nothing to do
[root@logstash ~]#
修改/etc/snmp/snmpd.conf文件,添加如下内容,并保存,获取所有的数据
com2sec notConfigUser default public #启用
view all included .1 80 #新增
access notConfigGroup "" any noauth exact all none none #新增
2.启动snmpd
命令:
systemctl start snmpd
[root@logstash ~]# systemctl start snmpd
[root@logstash ~]# systemctl status snmpd
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2024-08-28 16:12:18 CST; 5min ago
Main PID: 1638 (snmpd)
Tasks: 1
Memory: 11.9M
CGroup: /system.slice/snmpd.service
└─1638 /usr/sbin/snmpd -LS0-6d -f
Aug 28 16:12:18 logstash systemd[1]: Starting Simple Network Management Protocol (SNM......
Aug 28 16:12:18 logstash systemd[1]: Started Simple Network Management Protocol (SNMP...n..
Hint: Some lines were ellipsized, use -l to show in full.
[root@logstash ~]# netstat -an | grep 161
udp 0 0 0.0.0.0:161 0.0.0.0:*
[root@logstash ~]#
3.snmptranslate工具使用介绍
snmptranslate参数
命令:
snmptranslate -h
[root@logstash ~]# snmptranslate -h
USAGE: snmptranslate [OPTIONS] OID [OID]...
Version: 5.7.2
Web: http://www.net-snmp.org/
Email: net-snmp-coders@lists.sourceforge.net
OPTIONS:
-h display this help message
-V display package version number
-m MIB[:...] load given list of MIBs (ALL loads everything)
-M DIR[:...] look in given list of directories for MIBs
-D[TOKEN[,...]] turn on debugging output for the specified TOKENs
(ALL gives extremely verbose debugging output)
-w WIDTH set width of tree and detail output
-T TRANSOPTS Set various options controlling report produced:
B: print all matching objects for a regex search
d: print full details of the given OID
p: print tree format symbol table
a: print ASCII format symbol table
l: enable labeled OID report
o: enable OID report
s: enable dotted symbolic report
z: enable MIB child OID report
t: enable alternate format symbolic suffix report
-P MIBOPTS Toggle various defaults controlling mib parsing:
u: allow the use of underlines in MIB symbols
c: disallow the use of "--" to terminate comments
d: save the DESCRIPTIONs of the MIB objects
e: disable errors when MIB symbols conflict
w: enable warnings when MIB symbols conflict
W: enable detailed warnings when MIB symbols conflict
R: replace MIB symbols from latest module
-O OUTOPTS Toggle various defaults controlling output display:
0: print leading 0 for single-digit hex characters
a: print all strings in ascii format
b: do not break OID indexes down
e: print enums numerically
E: escape quotes in string indices
f: print full OIDs on output
n: print OIDs numerically
q: quick print for easier parsing
Q: quick print with equal-signs
s: print only last symbolic element of OID
S: print MIB module-id plus last element
t: print timeticks unparsed as numeric integers
T: print human-readable text along with hex strings
u: print OIDs using UCD-style prefix suppression
U: don't print units
v: print values only (not OID = value)
x: print all strings in hex format
X: extended index format
-I INOPTS Toggle various defaults controlling input parsing:
b: do best/regex matching to find a MIB node
h: don't apply DISPLAY-HINTs
r: do not check values for range/type legality
R: do random access to OID labels
u: top-level OIDs must have '.' prefix (UCD-style)
s SUFFIX: Append all textual OIDs with SUFFIX before parsing
S PREFIX: Prepend all textual OIDs with PREFIX before parsing
-L LOGOPTS Toggle various defaults controlling logging:
e: log to standard error
o: log to standard output
n: don't log at all
f file: log to the specified file
s facility: log to syslog (via the specified facility)
(variants)
[EON] pri: log to standard error, output or /dev/null for level 'pri' and above
[EON] p1-p2: log to standard error, output or /dev/null for levels 'p1' to 'p2'
[FS] pri token: log to file/syslog for level 'pri' and above
[FS] p1-p2 token: log to file/syslog for levels 'p1' to 'p2'
[root@logstash ~]#
1.用snmptranslate把symbol 格式的HOST-RESOURCES-MIB::hrSystem 转换为 numberic 格式的oid,用-On(输出数字格式的oid),使用 -IR(允许“随机”访问 MIB)
命令:
snmptranslate -On -IR HOST-RESOURCES-MIB::hrSystem
[root@logstash ~]# snmptranslate -On -IR HOST-RESOURCES-MIB::hrSystem
.1.3.6.1.2.1.25.1
[root@logstash ~]#
2.用snmptranslate把symbol 格式的HOST-RESOURCES-MIB::hrSystem 转换为symbol 格式的 oi


360

被折叠的 条评论
为什么被折叠?



