SNMP

学习笔记:

1、SNMP的结构有三个目标:网络管理功能尽量简单化;网络管理协议容易扩充;网络管理结构尽可能独立,与网络设备无关。

2、由三部分组成,管理员(managemet);代理(agent)和管理信息库(MIB)。管理员和管理信息库位于管理工作站上,管理员对代理进行轮询得到所需的管理信息入在管理信息库中。代理位于被管理的计算机和网络设备上,如主机、路由器、交换机、终端服务器和工作站,它是一个软件,负责收集所驻设备的网络信息等待管理员来轮询。

 

1、  OID号码翻译成MIB名称:

#snmptranslate .1.3.6.1.2.1.1.3.0
   #SNMPv2-MIB::sysUpTime.0
 
   MIB名称翻译成OID号:
#snmptranslate -On SNMPv2-MIB::sysUpTime.0
   #.1.3.6.1.2.1.1.3.0
   OID才是真正在通信中供机器使用的。
 
   snmptranslate -IR -Tp bvcom 可查看MIB库是否加载
+--bvcom(26814)
|
+--ipq6800(6800)
|
+--bvcomAgentModules(1)
|
+-- -RW- Integer32 bvcomAgentModuleObject(1)
+-- -RW- Integer32 bvcomAgentSubagentObject(2)
+-- -RW- Integer32 bvcomAgentPluginObject(3)
 
2、INFORM的作用是告知发出TRAP信息的一方“TRAP信息已经收到”。
 
3、SNMPv3是按本地的engineID号来发送TRAP,必须为每一个TRAP将发往的远端用户创建一个远端engineID,这需要创建一个记录着远端用户engineID的数据库。
4、mib2c.conf文件之内的所有命令都包含@标志
 
5、实例:snmpget v2c c public localhost .1.3.6.1.2.1.1.5.0
(注意,SNMP规定一个不成表的标量的实例标识由它的对象标识加上.0组成即叶子对象的实例为该叶子对象标识符加上.0
   -v2c: 使用的是2csnmp版本,可选1|2c|3
   -c publiccommunity 名为public
 
   snmpset –v2c –c public localhost .1.3.6.1.2.1.4.21.1.3.x i 99
 
x:在这里是索引值,表示表项中某一列的第几个数据,根据要求设定 
 
i: 这里是列数据类型,包括i: INTEGER, u: unsigned INTEGER, t: TIMETICKS,
 
6、若编写mib库中的变量都是int型,则选择mib2c.int_watch.conf作为模版:
   #mib2c –c mib2c.int_watch.conf  bvcomAgentModules
    若变量中有string类型,可选用mib2c.scalar.conf
 
7Set processing
SET_RESERVE1 
The purpose of SET_RESERVE1 is to try and detect invalid SET requests as soon as possible. If any of the columns are assigned an impossible value (wrong type, or out-of-range, etc), then the request fails. 
SET_RESERVE2 
The purpose of SET_RESERVE2 is to set up/allocate the data structure for a new row or perform any resource allocation needed for further processing (e.g. database locks). 
SET_FREE 
The purpose of SET_FREE is to undo anything done in the two SET_RESERVE passes, if some aspect of the request proves unacceptable. This means possibly releasing the data structure for a new row, if one has just been created. 
SET_ACTION 
SET_ACTION assigns the appropriate column values to the data structure for this row (either the new structure created in the SET_RESERVE2 step, or an existing row structure). 
SET_UNDO 
SET_UNDO reverses anything done in the two SET_RESERVE steps or SET_ACTION - called if some part of the SET_ACTION processing fails. This is similar to the SET_FREE processing, but also needs to reverse any newly assigned values. 
SET_COMMIT 
The purpose of SET_COMMIT is to confirm that the processing of the SET request has completed successfully, and perform any "irreversible" actions. 
 
8snmp.conf用于配置添加的mib库:
   #vi snmp.conf
mibs +BAMBOO-MIB     //添加自己编写的MIB
 
snmpd.conf 配置代理和管理端通信文件:
# 只读安全体名称,相当于访问帐号
rocommunity      publicr 
# 可读写安全体名称
rwcommunity      publicw
# 监听端口 默认161
agentaddress      161
注意:只读安全体名称如:publicr和可读写安全名称如:publicw 必须不一致,否则可能会出现set操作时无写权限的错误!
 
9、在配置net-snmp-5.2.1时:
   #./configure  --with-mib-modules=”XXX-MIB YYY-MIB”//包含这些MIB
   #./configure  --with-out-mib-modules=XXX-MIB YYY-MIB”//不包含
   利用这两种方式可实现对MIB库德裁剪和添加。
10、

Snmp2的mib:NOTIFICATION-TEST-MIB.txt:

NOTIFICATION-TEST-MIB DEFINITIONS ::= BEGIN

       IMPORTS ucdavis FROM UCD-SNMP-MIB;

 demonotifs OBJECT IDENTIFIER ::= { ucdavis 991 }

 demo-notif NOTIFICATION-TYPE

         STATUS current

         OBJECTS { sysLocation }

         DESCRIPTION "Just a test notification"

         ::= { demonotifs 17 }

 END
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值