实验二:使用snmp命令查看mib树信息一、实验目的熟悉SNMP协议的操作的特点和功能二、实验内容熟悉SNMP的getrequest、getnextRequest 、SetRequestdeng 操作,通过配置文件熟悉SNMP 协议视图的概念三、实验准备、环境采用开源软件net_snmp(/)Windows操作系统四、实验步骤1 安装net snmnp,单击安装程序net-snmp-5.4.0-1.win32.exe,安装均按缺省,,一般会安装到c:\usr目录下2、熟悉和配置代理段配置文件,从而掌握视图的概念1) 把配置文件snmpd.conf 拷贝到C:\usr\etc\snmp 下,了解其如何间公共体和视图关联起来2) 利用netsnmp的自动配置命令生成snmpd.conf,生成方法建相关ppt在命令窗口中运行命令snmpd -f -Le –d(打开一个窗口,不要关闭)3熟悉snmpde相关操作命令的使用详见文档“简单网络管理协议工具使用”1)GetRequest操作(打开另外一个窗口,执行命令)Netsnmp软件实现命令snmpget.exe命令格式Snmpget –v1(或-v2c) –c 公共体代理主机IP地址(本机为localhost)对象实例标识如Snmpget –v1 –c public localhost sysName.0利用该操作至少检索一个标量对象和标对象实例(对象选择见教材、PPT或monitor.exe软件)2)GetNextRequest操作Netsnmp软件实现命令snmpgetnext.exe命令格式Snmpget –v1(或-v2c) –c 公共体代理主机IP地址(本机为localhost)对象实例标识Snmpgetnext –v1 –c public localhost sysName.03)SetRequest操作Netsnmp软件实现命令snmpset.exe命令格式snmpset [common arguments] MIB-objectID type value [MIB –objectID type value]MIB-objectID是一个要指定新值的MIB数据对象。
参数type表示要修改的数据对象的类型;value表示该数据对象应该设置的新值。
type 是一个字符,它表示数据对象的类型,这些类型是ASN.1定义的。
表13-6列出了snmpset支持的类型。
字符数据对象类型i INTEGERs STRINGx HEXADECIMAL STRINGd DECIMAL STRINGn NULL OBJECTo OBJECTIDt TIMESTICKSa IPADDRESSsnmpset –v1 –c public localhost sysName.0 s mycomputer4)GetBulkRequest 操作///?snmpbulkwalk用于通过SNMPv2 的SNMP GET BULK请求命令与其它网络实体通信。
提供了一种比SNMPv1的GET请求更有效的传输大量数据的机制,netsnmpde Bulk操作。
Netsnmp使用snmpbulkwalk,命令封装该操作。
可以得到某一功能组命令格式snmpbulkwalk –v2c –c public 目标代理IP地址。
如:snmpbulkwalk -v2c -c public localhost system对比,有什么区别?>snmpbulkwalk -v2c -c public localhost system>snmpbulkget -v2c -c public localhost system指定n和m的值snmpbulkget -v2c -Cn1 -Cr5 -c public localhost sysDescr ifInOctets ifOutOctets返回结果如下:NMPv2-MIB::sysDescr.0 = STRING: Windows PXP Professional x86 Family 6 Model 9 StepF-MIB::ifInOctets.1 = Counter32: 193076F-MIB::ifOutOctets.1 = Counter32: 193076//////////////////F-MIB::ifInOctets.2 = Counter32: 42139475F-MIB::ifOutOctets.2 = Counter32: 8222288/////////////////F-MIB::ifInUcastPkts.1 = Counter32: 6130F-MIB::ifOutUcastPkts.1 = Counter32: 6130//////////////////////////////F-MIB::ifInUcastPkts.2 = Counter32: 39376F-MIB::ifOutUcastPkts.2 = Counter32: 3420/////////////////////////F-MIB::ifInNUcastPkts.1 = Counter32: 0F-MIB::ifOutNUcastPkts.1 = Counter32: 0不指定n和m的值snmpbulkget -v2c -c public localhost sysDescr ifInOctets ifOutOctets五、实验要求要求:1)前两种操作至少检索两个被检索对象,其中一个为标量对象、一个为表对象的一行。
2)Set操作设置为system组的几个对象3)GetBulkRequest 为请求某一个系统组所有对象六、实验报告1、各个操作的功能的目的2、提交利用操作对象设置的结果,命令行的操作和响应,说明加拷屏(打印稿)或结果(手写稿)【转】snmpbulkget中文手册 net-snmp转载请注明出自本博客。
原文:NET-SNMP5.5.0 win32平台的net-snmp.chm。
snmpbulkgetNAME------------snmpbulkget - 使用snmp getbulk 请求指令与网络实体进行通讯。
概述-------------snmpbulkget [APPLICATION OPTIONS] [COMMON OPTIONS] OID [OID]...描述-------------snmpbulk 是一个SNMP应用程序,它使用SNMP GETBULK来对网络实体进行信息查询。
在命令行中,它可以处理1个或者多个OID。
每个变量的名字需要遵循variables(5)手册中指定的格式。
如果网络实体在处理请求数据包的时候出现错误,会返回一个错误包,并显示一条信息,帮助指出为什么请求会出现异常。
参数--------------Cn<NUM>设置在GETBULK PDU中不会被迭代查询的OID。
这个参数指定了后面的OID中不被迭代查询的个数。
默认值为0。
-Cr<NUM>设置了GETBULK PDU中最大迭代次数。
这个参数指定了每个OID被迭代查询的次数。
默认值10。
除了这些参数,snmpbulkget还可以使用在snmpcmd(1)手册页中的通用参数。
实例--------------命令:snmpbulkget -v2c -Cn1 -Cr5 -Os -c public zeus system ifTable会收到oid system.sysDescr.0 和ifTable的前5个oid:sysDescr.0 = STRING: "SunOS 4.1.3_U1 1 sun4m"ifIndex.1 = INTEGER: 1ifIndex.2 = INTEGER: 2ifDescr.1 = STRING: "lo0"...注意事项:--------------snmpbulkget使用了SNMP GETBULK操作,这在SNMPv1中是不被支持的。
4th Berkeley Distribution 08 Feb 2002例子:~>#snmpbulkget -Cn0 -Cr5 -v2c -c hsjyjz 192.168.1.6 system iftableSNMPv2-MIB::sysDescr.0 = STRING: OpenBSD fwBackup.my.domain 4.5 GENERIC#1749 i386IF-MIB::ifIndex.1 = INTEGER: 1SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.12IF-MIB::ifIndex.2 = INTEGER: 2DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (18077284) 2 days, 2:12:52.84IF-MIB::ifIndex.3 = INTEGER: 3SNMPv2-MIB::sysContact.0 = STRING: Me <>IF-MIB::ifIndex.4 = INTEGER: 4SNMPv2-MIB::sysName.0 = STRING: fwBackup.my.domainIF-MIB::ifIndex.5 = INTEGER: 5分析:-Cn0 对0个对象不进行迭代查询-Cr5 每个oid对象查询出5个oid注意当Cr<NUM> 指定的数字过大时,不能查询出更多结果,估计和每次bulk操作能带回的数据多少有关系。
原文地址/docs/man/snmpbulkget.htmlSNMP getbulk参数说明分类:技术2009-08-30 12:01 1841人阅读评论(0) 收藏举报SNMPv2 defines the get-bulk operation, which allows a management application to retrieve a large section of a table at once. The standard get operation can attempt to retrieve more than one MIB object at once, but message sizes are limited by the agent's capabilities. If the agent can't return all the requested responses, it returns an error message with no data. The get-bulk operation, on the other hand, tells the agent to send as much of the response back as it can. This means that incomplete responses are possible. Two fields must be set when issuing a get-bulk command: nonrepeaters and max-repetitions. Nonrepeaters tells the get-bulk command that the first N objects can be retrieved with a simple get-next operation. Max-repetitions tells the get-bulk command to attempt up to Mget-next operations to retrieve the remaining objects.Assume we're requesting three bindings: sysDescr, ifInOctets, and ifOutOctets. The total number of variable bindings that we've requested is given by the formula N + (M * R), where N is the number of nonrepeaters (i.e., scalar objects in the request -- in this case 1, because sysDescr is the only scalar object), M is max-repetitions (in this case, we've set it arbitrarily to 3), and R is the number of nonscalar objects in the request (in this case 2, because ifInOctets and ifOutOctets are both nonscalar). Plugging in the numbers from this example, we get 1 + (3 * 2) = 7, which is the total number of variable bindings that can be returned by this get-bulk request.The Net-SNMP package comes with a command for issuing get-bulk queries. If we execute this command using all the parameters previously discussed, it will look like the following:$ snmpbulkget -v2c -B 1 3 public sysDescr ifInOctets ifOutOctetssystem.sysDescr.0 = "Linux linux 2.2.5-15 #3 Thu May 27 19:33:18 EDT 1999 i686"interfaces.ifTable.ifEntry.ifInOctets.1 = 70840interfaces.ifTable.ifEntry.ifOutOctets.1 = 70840interfaces.ifTable.ifEntry.ifInOctets.2 = 143548020interfaces.ifTable.ifEntry.ifOutOctets.2 = 111725152interfaces.ifTable.ifEntry.ifInOctets.3 = 0interfaces.ifTable.ifEntry.ifOutOctets.3 = 0Since get-bulk is an SNMPv2 command, you have to tell snmpgetbulk to use an SNMPv2 PDU with the -v2c option. The nonrepeaters and max-repetitions are set with the -B 1 3 option. This sets nonrepeaters to 1 and max-repetitions to 3. Notice that the command returned seven variable bindings: one for sysDescr and three each for ifInOctets and ifOutOctets.Non-repeaters and maxRepetitionsThey are used in getBulk.Definition of Non-repeaters:- The Non-repeater specifies the number of variables in the variable-bindings list for which a single OID (lexicographic successor) is to be returned.Definition of maxRepetitions :- The max-repetitions specifies the number of OIDs (lexicographic successor)to be returned for the remaining variables (total variables - nonrepeaters)in the variable bindings list.For clearer understanding, Let us assume Nonrepeater=4, and Max-Repetitions=3;If get values with OID lists whichare .1.3.6.1.2.1.11.1.0, .1.3.6.1.2.1.11.2.0 , .1.3.6.1.2.1.11.3.0, .1.3.6.1.2.1.11.4.0, .1.3.6.1.2.1.11.5.0, .1.3.6.1.2.1.11.6.0 , and the method is getNext.NonRepeater value is 4. So the first four variable returns a single lexicographic successor.Request OIDs ----> Response.1.3.6.1.2.1.11.1.0 ---> .1.3.6.1.2.1.11.2.0 and its value.1.3.6.1.2.1.11.2.0 ---> .1.3.6.1.2.1.11.3.0 and its value1.3.6.1.2.1.11.3.0 ---> .1.3.6.1.2.1.11.4.0 and its value.1.3.6.1.2.1.11.4.0 ---> .1.3.6.1.2.1.11.5.0 and its valueThe subsequent OIDs in the OIDs list to be returned the number of max-repetitions lexicographic successor.Request ---> Response.1.3.6.1.2.1.11.5.0 --> .1.3.6.1.2.1.11.6.0, .1.3.6.1.2.1.11.7.0, .1.3.6.1.2.1.11.8.0 and its value.Request ---> Response.1.3.6.1.2.1.11.6.0 --> .1.3.6.1.2.1.11.7.0, .1.3.6.1.2.1.11.8.0 , .1.3.6.1.2.1.11.9.0 and its value.So the response will be,.1.3.6.1.2.1.11.2.0 and its value.1.3.6.1.2.1.11.3.0 and its value.1.3.6.1.2.1.11.4.0 and its value.1.3.6.1.2.1.11.5.0 and its value.1.3.6.1.2.1.11.6.0 and its value.1.3.6.1.2.1.11.7.0 and its value.1.3.6.1.2.1.11.7.0 and its value.1.3.6.1.2.1.11.8.0 and its value.1.3.6.1.2.1.11.8.0 and its value.1.3.6.1.2.1.11.9.0 and its value。