Ubuntu snmp的問題 Ubuntu 12.04 didn’t install the MIB files. Even if you install the SNMP applications. Just check the preamble of /etc/snmp/snmp.conf ## As the snmp packages come without MIB files due to license reasons, loading# of MIBs is disabled by default. If you added the MIBs you can reenable# loaging them by commenting out the following line.mibs : Sure, but how can I install them ? Fortunately there is a package to deal with that. $ sudo apt-get install snmp-mibs-downloader It will download the IETF MIB files and install them under the usual /usr/share/mibs/ If for any reason you don’t see it happen force it with $ sudo download-mibs You can repeat this command later to update any new MIB file. 安裝完成後,測試 snmpwalk -v 2c -c public localhostUnlinked OID in IPATM-IPMC-MIB: marsMIB ::= { mib-2 57 }Undefined identifier: mib-2 near line 18 of /usr/share/mibs/ietf/IPATM-IPMC-MIBBad operator (INTEGER): At line 73 in /usr/share/mibs/ietf/SNMPv2-PDUUndefined OBJECT-GROUP (diffServMIBMultiFieldClfrGroup): At line 2195 in /usr/share/mibs/ietf/IPSEC-SPD-MIBUndefined OBJECT-GROUP (diffServMultiFieldClfrNextFree): At line 2157 in /usr/share/mibs/ietf/IPSEC-SPD-MIBUndefined OBJECT-GROUP (diffServMIBMultiFieldClfrGroup): At line 2062 in /usr/share/mibs/ietf/IPSEC-SPD-MIBExpected "::=" (RFC5644): At line 493 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIBExpected "{" (EOF): At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIBBad object identifier: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIBBad parse of OBJECT-IDENTITY: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB 解決辦法: #!/bin/bashfor i in /usr/share/mibs/ietf/IPSEC-SPD-MIB /usr/share/mibs/ietf/IPATM-IPMC-MIB /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB /usr/share/mibs/ietf/SNMPv2-PDUdomv $i /usr/share/mibsdone 另外snmpwalk -v 2c -c public 192.168.1.1 mem可以使用,snmpwalk -v 2c -c public 192.168.1.1 cpu不能使用,因為不存在cpu這個logical name,所以,直接使用OID,snmpwalk -v 2c -c public 192.168.1.1 .1.3.6.1.2.1.25.3.3.1.2 snmpwalk -v 2c -c public 192.168.1.1 .1.3.6.1.2.1.25.3.3.1.2HOST-RESOURCES-MIB::hrProcessorLoad.768 = INTEGER: 1HOST-RESOURCES-MIB::hrProcessorLoad.769 = INTEGER: 0HOST-RESOURCES-MIB::hrProcessorLoad.770 = INTEGER: 0HOST-RESOURCES-MIB::hrProcessorLoad.771 = INTEGER: 1HOST-RESOURCES-MIB::hrProcessorLoad.772 = INTEGER: 0HOST-RESOURCES-MIB::hrProcessorLoad.773 = INTEGER: 0HOST-RESOURCES-MIB::hrProcessorLoad.774 = INTEGER: 1HOST-RESOURCES-MIB::hrProcessorLoad.775 = INTEGER: 0HOST-RESOURCES-MIB::hrProcessorLoad.776 = INTEGER: 1HOST-RESOURCES-MIB::hrProcessorLoad.777 = INTEGER: 1HOST-RESOURCES-MIB::hrProcessorLoad.778 = INTEGER: 1HOST-RESOURCES-MIB::hrProcessorLoad.779 = INTEGER: 2HOST-RESOURCES-MIB::hrProcessorLoad.780 = INTEGER: 0HOST-RESOURCES-MIB::hrProcessorLoad.781 = INTEGER: 1HOST-RESOURCES-MIB::hrProcessorLoad.782 = INTEGER: 0HOST-RESOURCES-MIB::hrProcessorLoad.783 = INTEGER: 0 另;精簡的snmpd.conf #### # First, map the community name "public" into a "security name" #ec.name source community com2sec my_user 192.168.1.1 public #### # Second, map the security name into a group name: # groupName securityModel securityName group my_group v2c my_user #### # Third, create a view for us to let the group have rights to: # name incl/excl subtree mask(optional) view all included .1 80 #### # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif access my_group "" any noauth exact all none none #### # Customer pass_persist .1.3.6.1.3.1 /usr/bin/perl /usr/local/bin/iostat-persist.pl