Ubuntu snmp的问题


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 localhost
Unlinked OID in IPATM-IPMC-MIB: marsMIB ::= { mib-2 57 }
Undefined identifier: mib-2 near line 18 of /usr/share/mibs/ietf/IPATM-IPMC-MIB
Bad operator (INTEGER): At line 73 in /usr/share/mibs/ietf/SNMPv2-PDU
Undefined OBJECT-GROUP (diffServMIBMultiFieldClfrGroup): At line 2195 in /usr/share/mibs/ietf/IPSEC-SPD-MIB
Undefined OBJECT-GROUP (diffServMultiFieldClfrNextFree): At line 2157 in /usr/share/mibs/ietf/IPSEC-SPD-MIB
Undefined OBJECT-GROUP (diffServMIBMultiFieldClfrGroup): At line 2062 in /usr/share/mibs/ietf/IPSEC-SPD-MIB
Expected "::=" (RFC5644): At line 493 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Expected "{" (EOF): At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Bad object identifier: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Bad parse of OBJECT-IDENTITY: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
 
解决办法:
 
#!/bin/bash
for i in /usr/share/mibs/ietf/IPSEC-SPD-MIB /usr/share/mibs/ietf/IPATM-IPMC-MIB /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-M
IB /usr/share/mibs/ietf/SNMPv2-PDU
do
mv $i /usr/share/mibs
done
 
另外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.2
HOST-RESOURCES-MIB::hrProcessorLoad.768 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.769 = INTEGER: 0
HOST-RESOURCES-MIB::hrProcessorLoad.770 = INTEGER: 0
HOST-RESOURCES-MIB::hrProcessorLoad.771 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.772 = INTEGER: 0
HOST-RESOURCES-MIB::hrProcessorLoad.773 = INTEGER: 0
HOST-RESOURCES-MIB::hrProcessorLoad.774 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.775 = INTEGER: 0
HOST-RESOURCES-MIB::hrProcessorLoad.776 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.777 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.778 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.779 = INTEGER: 2
HOST-RESOURCES-MIB::hrProcessorLoad.780 = INTEGER: 0
HOST-RESOURCES-MIB::hrProcessorLoad.781 = INTEGER: 1
HOST-RESOURCES-MIB::hrProcessorLoad.782 = INTEGER: 0
HOST-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
 

相关内容

    暂无相关文章