Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3049188
  • 博文数量: 535
  • 博客积分: 15788
  • 博客等级: 上将
  • 技术积分: 6507
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 09:11
文章分类

全部博文(535)

文章存档

2016年(1)

2015年(1)

2014年(10)

2013年(26)

2012年(43)

2011年(86)

2010年(76)

2009年(136)

2008年(97)

2007年(59)

分类: LINUX

2013-04-08 12:46:57

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

  1. #
  2. # As the snmp packages come without MIB files due to license reasons, loading
  3. # of MIBs is disabled by default. If you added the MIBs you can reenable
  4. # loaging them by commenting out the following line.
  5. mibs :

Sure, but how can I install them ?

Fortunately there is a package to deal with that.

  1. $ 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

  1. $ sudo download-mibs

You can repeat this command later to update any new MIB file.

安装完成后,测试

  1. snmpwalk -v 2c -c public localhost
  2. Unlinked OID in IPATM-IPMC-MIB: marsMIB ::= { mib-2 57 }
  3. Undefined identifier: mib-2 near line 18 of /usr/share/mibs/ietf/IPATM-IPMC-MIB
  4. Bad operator (INTEGER): At line 73 in /usr/share/mibs/ietf/SNMPv2-PDU
  5. Undefined OBJECT-GROUP (diffServMIBMultiFieldClfrGroup): At line 2195 in /usr/share/mibs/ietf/IPSEC-SPD-MIB
  6. Undefined OBJECT-GROUP (diffServMultiFieldClfrNextFree): At line 2157 in /usr/share/mibs/ietf/IPSEC-SPD-MIB
  7. Undefined OBJECT-GROUP (diffServMIBMultiFieldClfrGroup): At line 2062 in /usr/share/mibs/ietf/IPSEC-SPD-MIB
  8. Expected "::=" (RFC5644): At line 493 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
  9. Expected "{" (EOF): At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
  10. Bad object identifier: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
  11. Bad parse of OBJECT-IDENTITY: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB

解决办法:

  1. #!/bin/bash
  2. 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
  3. IB /usr/share/mibs/ietf/SNMPv2-PDU
  4. do
  5. mv $i /usr/share/mibs
  6. 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

  1. snmpwalk -v 2c -c public 192.168.1.1 .1.3.6.1.2.1.25.3.3.1.2
  2. HOST-RESOURCES-MIB::hrProcessorLoad.768 = INTEGER: 1
  3. HOST-RESOURCES-MIB::hrProcessorLoad.769 = INTEGER: 0
  4. HOST-RESOURCES-MIB::hrProcessorLoad.770 = INTEGER: 0
  5. HOST-RESOURCES-MIB::hrProcessorLoad.771 = INTEGER: 1
  6. HOST-RESOURCES-MIB::hrProcessorLoad.772 = INTEGER: 0
  7. HOST-RESOURCES-MIB::hrProcessorLoad.773 = INTEGER: 0
  8. HOST-RESOURCES-MIB::hrProcessorLoad.774 = INTEGER: 1
  9. HOST-RESOURCES-MIB::hrProcessorLoad.775 = INTEGER: 0
  10. HOST-RESOURCES-MIB::hrProcessorLoad.776 = INTEGER: 1
  11. HOST-RESOURCES-MIB::hrProcessorLoad.777 = INTEGER: 1
  12. HOST-RESOURCES-MIB::hrProcessorLoad.778 = INTEGER: 1
  13. HOST-RESOURCES-MIB::hrProcessorLoad.779 = INTEGER: 2
  14. HOST-RESOURCES-MIB::hrProcessorLoad.780 = INTEGER: 0
  15. HOST-RESOURCES-MIB::hrProcessorLoad.781 = INTEGER: 1
  16. HOST-RESOURCES-MIB::hrProcessorLoad.782 = INTEGER: 0
  17. HOST-RESOURCES-MIB::hrProcessorLoad.783 = INTEGER: 0

另;精简的snmpd.conf

  1. ####
  2.     # First, map the community name "public" into a "security name"
  3.     #ec.name source community
  4.     com2sec my_user 192.168.1.1 public
  5.     ####
  6.     # Second, map the security name into a group name:
  7.     # groupName securityModel securityName
  8.     group my_group v2c my_user
  9.     ####
  10.     # Third, create a view for us to let the group have rights to:
  11.     # name incl/excl subtree mask(optional)
  12.     view all included .1 80
  13.     ####
  14.     # Finally, grant the group read-only access to the systemview view.
  15.     # group context sec.model sec.level prefix read write notif
  16.     access my_group "" any noauth exact all none none
  17.     ####
  18.     # Customer
  19.     pass_persist .1.3.6.1.3.1 /usr/bin/perl /usr/local/bin/iostat-persist.pl


阅读(3493) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~