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 agoMain PID: 1638 (snmpd)Tasks: 1Memory: 11.9MCGroup: /system.slice/snmpd.service└─1638 /usr/sbin/snmpd -LS0-6d -fAug 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.2Web: http://www.net-snmp.org/Email: net-snmp-coders@lists.sourceforge.netOPTIONS:-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 searchd: print full details of the given OIDp: print tree format symbol tablea: print ASCII format symbol tablel: enable labeled OID reporto: enable OID reports: enable dotted symbolic reportz: enable MIB child OID reportt: enable alternate format symbolic suffix report-P MIBOPTS Toggle various defaults controlling mib parsing:u: allow the use of underlines in MIB symbolsc: disallow the use of "--" to terminate commentsd: save the DESCRIPTIONs of the MIB objectse: disable errors when MIB symbols conflictw: enable warnings when MIB symbols conflictW: enable detailed warnings when MIB symbols conflictR: replace MIB symbols from latest module-O OUTOPTS Toggle various defaults controlling output display:0: print leading 0 for single-digit hex charactersa: print all strings in ascii formatb: do not break OID indexes downe: print enums numericallyE: escape quotes in string indicesf: print full OIDs on outputn: print OIDs numericallyq: quick print for easier parsingQ: quick print with equal-signss: print only last symbolic element of OIDS: print MIB module-id plus last elementt: print timeticks unparsed as numeric integersT: print human-readable text along with hex stringsu: print OIDs using UCD-style prefix suppressionU: don't print unitsv: print values only (not OID = value)x: print all strings in hex formatX: extended index format-I INOPTS Toggle various defaults controlling input parsing:b: do best/regex matching to find a MIB nodeh: don't apply DISPLAY-HINTsr: do not check values for range/type legalityR: do random access to OID labelsu: top-level OIDs must have '.' prefix (UCD-style)s SUFFIX: Append all textual OIDs with SUFFIX before parsingS PREFIX: Prepend all textual OIDs with PREFIX before parsing-L LOGOPTS Toggle various defaults controlling logging:e: log to standard erroro: log to standard outputn: don't log at allf file: log to the specified files 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 格式的 oid,用-Onf(输出符号格式的oid)
命令:
snmptranslate -Onf -IR HOST-RESOURCES-MIB::hrSystem
[root@logstash ~]# snmptranslate -Onf -IR HOST-RESOURCES