SNMP

(一)安装
yum install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils php-snmp
service snmpd start
chkconfig snmpd on
  SNMP中MIBS的路径:/usr/share/snmp/mibs

(二)snmpwalk工具

   snmpwalk -v 1 -c neusoft localhost .1.3.6.1.2.1.25.3.3.1.2 
  -v:代表版本号,
  -c:是社群,参见下文中有定义,为neusofot
  localhost:代表walk的机器的IP;
  .1.3.6.1.2.1.25.3.3.1.2:则是OID(注意,第一位是带“."的),可以通过mibs browser来看到;
  上面的指令等价于:
   snmpwalk -v 1 -c neusoft localhost hrprocessorLoad 
  每个OID都对应一个名称,这个名称在使用的时候和OID等价;
 
(三)权限控制
  snmp里面的配置有一个很有价值就是他的权限配置,下面的示例配置的就是一个不受控的权限控制:
 1 ## sec.name source community
 2 #com2sec local localhost COMMUNITY
 3 #com2sec mynetwork NETWORK/24 COMMUNITY
 4 com2sec local localhost neusoft
 5 com2sec mynetwork 192.168.80.129/24 neusoft
 6 ## group.name sec.model sec.name
 7 group MyRWGroup any local
 8 group MyROGroup any mynetwork
 9 ## incl/excl subtree mask
10 view all included .1 80
11 ## context sec.model sec.level prefix read write notif
12 access MyROGroup "" any noauth 0 all none none
13 access MyRWGroup "" any noauth 0 all all all
  像上面这样配置之后,就可以通过下面的指令来查看指定的内容:
  snmpwalk -v 1 -c neusoft localhost .1.3.6.1.2.1.25.3.3.1.2
  同样是在配置文件里面,有了一个受控权限控制的Demo:
 1 ####
 2 # First, map the community name "public" into a "security name"
 3 # sec.name source community
 4 com2sec notConfigUser default public
 5 ####
 6 # Second, map the security name into a group name:
 7 # groupName securityModel securityName
 8 group notConfigGroup v1 notConfigUser
 9 group notConfigGroup v2c notConfigUser
10 ####
11 # Third, create a view for us to let the group have rights to:
12 # Make at least snmpwalk -v 1 localhost -c public system fast again.
13 # name incl/excl subtree mask(optional)
14 view systemview included .1.3.6.1.2.1.1
15 view systemview included .1.3.6.1.2.1.25.1.1
16 ####
17 # Finally, grant the group read-only access to the systemview view.
18 # group context sec.model sec.level prefix read write notif
19 access notConfigGroup "" any noauth exact systemview none none

(四)snmptranslate工具

  使用snmptranslate工具可以用于查看你添加的节点是否有正确加载。
  usr/local/net-snmp/bin/snmptranslate -Tp -IR test

posted on 2018-04-05 15:24  张叫兽的技术研究院  阅读(221)  评论(0编辑  收藏  举报

导航