snmptable 命令检索 SNMP 表的内容并以表格格式显示内容,即一次一个表行,使得到的输出外观与检索的表类似。这与 snmpwalk 命令不同,后者显示表内容的方式是一次一列。
下面是 snmptable 命令的示例:
% snmptable SNMP_agent sysORTable SNMP table: SNMPv2-MIB::sysORTable sysORID sysORDescr sysORUpTime IF-MIB::ifMIB The MIB module to 0:0:00:00.01 describe generic objects SNMPv2-MIB::snmpMIB The MIB module for SNMPv2 0:0:00:00.02 for network interface entities. TCP-MIB::tcpMIB The MIB module for 0:0:00:00.02 sub-layers. managing TCP UDP implementations. UDP-MIB::udpMIB The MIB module for managing 0:0:00:00.02 RFC1213-MIB::ip The MIB module for managing 0:0:00:00.02 implementations. SNMP-VIEW-BASED-ACM- View-based Access Control 0:0:00:00.02 SNMP-FRAMEWORK-MIB:: The SNMP Management 0:0:00:00.14 IP and ICMP implementations. MIB::vacmBasicGroup Model for SNMP. snmpFrameworkMIB Architecture MIB. Compliance SNMP-MPD-MIB::snmp The MIB for Message 0:0:00:00.14 MPDCompliance Processing and Dispatching. SNMP-USER-BASED-SM- The management information 0:0:00:00.14 MIB::usmMIBCompliance definitions for the SNMP User-based Security Model.
在 snmptable 命令的示例中,使用 -Ci 和 -Cb 选项。例如,下面是带 -Ci 选项的 snmptable 命令:
% snmptable -Ci SNMP_agent sunPlatFanTable SNMP table: SUN-PLATFORM-MIB::sunPlatFanTable index sunPlatFanClass 10 fan 11 fan 17 fan 23 fan 29 fan 30 fan 36 fan 42 fan
下面是不带 -Ci 选项的 snmptable 命令的示例。请注意,不显示索引列:
% snmptable SNMP_agent sunPlatFanTable SNMP table: SUN-PLATFORM-MIB::sunPlatFanTable sunPlatFanClass fan fan fan fan fan
下面是带 -Ci 和 -Cb 选项的 snmptable 命令的示例。输出采用简略形式。
% snmptable -Ci -Cb SNMP_agent entPhysicalTable index Descr VendorType ContainedIn SNMP table: ENTITY ?SNMPv2- 0 chassis -MIB::entPhysical SMI:zeroDotZero 1 Table
下面是带 -Ci 选项但是不带 -Cb 选项的同一 snmptable 命令的示例。同样,输出采用简略形式。请注意,MIB 对象的名称在每个标题上重复。
% snmptable -Ci SNMP_agent entPhysicalTable index entPhysicalDescr entPhysical entPhysical VendorType ContainedIn SNMP table: ENTITY ?SNMPv2- 0 chassis 1 -MIB::entPhysical SMI:zeroDotZero
下面是同时带 -Ci 选项和 -Cb 选项的 snmptable 命令的另一个示例。请注意,MIB 对象并不在每个标题上都重复。
% snmptable -Cb -Ci SNMP_agent ilomCtrlAlertsTable SNMP table: SUN-ILOM-CONTROL-MIB::ilomCtrlAlertsTable in- Sever- Type Destin- Destin- SNMPVer- SNMP-Comm- Email Email dex ity ation- ation- sion unityOr- Event Event 1 criti- email ? 0.0.0.0 v1 public none none IP Email Username Class Type cal 2-15 dis- ipmi- 0.0.0.0 ? v1 public ? ? Filter Filter able pet
因此,将 -Cb 选项与 snmptable 命令一起使用时,表输出更易于读取。
下面是使用 SNMP 协议的版本 3 的 snmptable 命令的示例:
% snmptable -Cb -Ci -mALL -v3 -aMD5 -utestuser -Apassword -lauthNoPriv SNMP_agent:port sunPlatPowerSupplyTable SNMP table: SUN-PLATFORM-MIB::sunPlatPowerSupplyTable index sunPlatPowerSupplyClass 90 powerSupply 92 powerSupply 96 powerSupply
以下 snmptable 命令返回空表。
% snmptable -Cb -Ci SNMP_agent sunPlatBatteryTable SUN-PLATFORM-MIB::sunPlatBatteryTable: No entries