SNMP相关命令
SNMP的相关命令使用方法:
snmpdelta 一直监视SNMP变量中的变化
linux:~ # snmpdelta -c public -v 1 -Cs -CT localhost IF-MIB:ifInUcastPkts.3 IF-MIB:ifOutcastPkts.3
localhost ifInUcastPkts.3 ifOutUcastPkts.3
[20:15:59 6/14] 184.00 184.00
[20:16:00 6/14] 158.00 158.00
[20:16:01 6/14] 184.00 184.00
[20:16:02 6/14] 184.00 184.00
[20:16:03 6/14] 158.00 158.00
[20:16:04 6/14] 184.00 184.00
[20:16:05 6/14] 184.00 184.00
[20:16:06 6/14] 158.00 158.00
localhost ifInUcastPkts.3 ifOutUcastPkts.3
[20:15:59 6/14] 184.00 184.00
[20:16:00 6/14] 158.00 158.00
[20:16:01 6/14] 184.00 184.00
[20:16:02 6/14] 184.00 184.00
[20:16:03 6/14] 158.00 158.00
[20:16:04 6/14] 184.00 184.00
[20:16:05 6/14] 184.00 184.00
[20:16:06 6/14] 158.00 158.00
snmpdf 通过SNMP监视远程主机的磁盘空间
linux:~ # snmpdf -v 1 -c public localhost
Description size (kB) Used Available Used%
0 0 0 0%
Real Memory 0 0 0 0%
Swap Space 0 0 0 0%
/ 5734988 2462884 3272104 42%
/dev/shm 138472 8 138464 0%
/media/cdrecorder 0 0 0 0%
/media/floppy 0 0 0 0%
/proc/bus/usb 0 0 0 0%
linux:~ #
Description size (kB) Used Available Used%
0 0 0 0%
Real Memory 0 0 0 0%
Swap Space 0 0 0 0%
/ 5734988 2462884 3272104 42%
/dev/shm 138472 8 138464 0%
/media/cdrecorder 0 0 0 0%
/media/floppy 0 0 0 0%
/proc/bus/usb 0 0 0 0%
linux:~ #
snmpget 从一个代理得到一个SNMP变量的值
linux:~ # snmpget -v 1 -c public localhost 1.3.6.1.4.1.2021.2.1.5.1
UCD-SNMP-MIB::prCount.1 = INTEGER: 6
linux:~ #
UCD-SNMP-MIB::prCount.1 = INTEGER: 6
linux:~ #
snmpgetnext 从序列中获得下一个变量
linux:~ # snmpgetnext -v 1 -c public localhost 1.3.6.1.4.1.2021.2.1.5.1
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 0
linux:~ #
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 0
linux:~ #
snmpset 设置代理上的一个SNMP变量
linux:~ # snmpset -c private -v 1 test-hub system.sysContact.0 s dpz@noc.rutgers.edu ip.ipforwarding.0 = 2
snmptable 得到一个SNMP变量表
linux:~ # snmptable -c public -v 1 localhost 1.3.6.1.2.1.1.1
Was that a table SNMPv2-MIB::system
linux:~ #
Was that a table SNMPv2-MIB::system
linux:~ #
snmptranslate 搜索并说明MIB结构中的OID
linux:~ # snmptranslate -On -IR sysDescr
.1.3.6.1.2.1.1.1
linux:~ #
.1.3.6.1.2.1.1.1
linux:~ #
snmptrap 生成一次trap告警
linux:~ # snmptrap -v 1 -c public manager enterprises.spider test-hub 3 0 '' interfaces.iftable.ifentry.ifindex.1 i 1
snmpwalk 从某个特定的OID开始遍历MIB
linux:~ # snmpwalk -v 1 -c public localhost 1.3.6.1.4.1.2021.2
UCD-SNMP-MIB::prIndex.1 = INTEGER: 1
UCD-SNMP-MIB::prNames.1 = STRING: httpd2-prefork
UCD-SNMP-MIB::prMin.1 = INTEGER: 0
UCD-SNMP-MIB::prMax.1 = INTEGER: 0
UCD-SNMP-MIB::prCount.1 = INTEGER: 6
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 0
UCD-SNMP-MIB::prErrMessage.1 = STRING:
UCD-SNMP-MIB::prErrFix.1 = INTEGER: 0
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
linux:~ #
UCD-SNMP-MIB::prIndex.1 = INTEGER: 1
UCD-SNMP-MIB::prNames.1 = STRING: httpd2-prefork
UCD-SNMP-MIB::prMin.1 = INTEGER: 0
UCD-SNMP-MIB::prMax.1 = INTEGER: 0
UCD-SNMP-MIB::prCount.1 = INTEGER: 6
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 0
UCD-SNMP-MIB::prErrMessage.1 = STRING:
UCD-SNMP-MIB::prErrFix.1 = INTEGER: 0
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
linux:~ #