﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Vincent-随笔分类-snmp</title><link>http://www.blogjava.net/Vincent-chenxj/category/40350.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 18 Jun 2009 10:03:14 GMT</lastBuildDate><pubDate>Thu, 18 Jun 2009 10:03:14 GMT</pubDate><ttl>60</ttl><item><title>OID</title><link>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283089.html</link><dc:creator>Vincent-chen</dc:creator><author>Vincent-chen</author><pubDate>Thu, 18 Jun 2009 09:20:00 GMT</pubDate><guid>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283089.html</guid><wfw:comment>http://www.blogjava.net/Vincent-chenxj/comments/283089.html</wfw:comment><comments>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283089.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Vincent-chenxj/comments/commentRss/283089.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Vincent-chenxj/services/trackbacks/283089.html</trackback:ping><description><![CDATA[熟悉MIB库，收集下列参数的OID信息：IP地址、MAC地址、描述、端口状态、内存利用率、CPU利用率、延时、丢包率、端口利用率等<br />
服务器还包括硬盘利用率。<br />
<br />
<br />
<br />
1、在windows上安装snmp：控制面板-&gt;添加/删除程序-&gt;添加/删除windows组件-&gt;管理和监视工具-&gt;详细信息-&gt;snmp协议<br />
2、请你们先认真了解学习PHP。在机器上安装APACHE+PHP+MYSQL的设计环境，并熟悉环境。有问题随时联系我。<br />
3、你可以在本机安装snmp agent ，之后读取本机的相关参数。 &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
部分重要OID信息：<br />
1、内存大小<br />
服务器内存的OID是：.1.3.6.1.2.1.25.2.2.0，不同的操作系统也是使用一样的OID。但是网络设备内存的OID根据设备的生产厂商不同、型号不同，其OID也是不同的。Cisco的路由器和交换机都是.1.3.6.1.4.1.9.9.48.1.1.1.5.1。华为交换机Huawei 6502、Huawei 3526、Huawei 2403的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.2.0。而华三的H3C E328和H3C E126的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.2.65536。<br />
2、&nbsp; &nbsp; &nbsp; &nbsp; 内存利用率<br />
与内存大小的OID相对应，各被监控对象的内存利用率的OID如下：<br />
服务器内存利用率的OID是.1.3.6.1.4.1.2021.4.6.0；华为交换机的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.3.0。华三交换机的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.3.65536。<br />
3、&nbsp; &nbsp; &nbsp; &nbsp; 硬盘大小及利用率<br />
对于服务器的硬盘空间来说，因为每个服务器的硬盘个数和目录划分都不一样，所以读取到的目录空间大小对应的OID依次为：.1.3.6.1.2.1.25.2.3.1.5.1 、.1.3.6.1.2.1.25.2.3.1.5.2等，并且在读取每个目录空间大小的同时要读取该目录的名称（OID依次为：.1.3.6.1.2.1.25.2.3.1.3.1、.1.3.6.1.2.1.25.2.3.1.3.2等）作为该监控对象的描述。关于目录空间的利用率没有现成的OID，需要先获得目录空间的使用量（OID依次为：.1.3.6.1.2.1.25.2.3.1.6.1、.1.3.6.1.2.1.25.2.3.1.6.2、等），然后通过使用量与空间总量的比较得出利用率。<br />
4、&nbsp; &nbsp; &nbsp; &nbsp; 端口状态<br />
对于服务器来说，有的服务器为了完成复杂的功能需要配置多块网卡，因此也就会有多个端口需要监控。关于端口状态的OID则依次为：.1.3.6.1.2.1.2.2.1.7.1、.1.3.6.1.2.1.2.2.1.7.2、.1.3.6.1.2.1.2.2.1.7.3等，除了端口状态系统还需要知道该端口的名称（OID依次为：.1.3.6.1.2.1.2.2.1。2.1、.1.3.6.1.2.1.2.2.1.2.2、.1.3.6.1.2.1.2.2.1.2.3等）。在获取交换机的端口状态时首先只将状态UP的端口信息记录下来，再通过每个端口的作用来选择是否真的对其进行监控。一般网络管理员只需要监控那些用来与其它的网络设备互连的端口。这些端口的OID有的是连续的，有的则是分散的，但都属于.1.3.6.1.2.1.2.2.1.7的分支。<br />
<br />
<br />
<br />
<br />
CPU Statistics<br />
<br />
Load<br />
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1<br />
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2<br />
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3<br />
<br />
CPU<br />
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0<br />
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0<br />
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0<br />
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0<br />
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0<br />
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0<br />
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0<br />
<br />
Memory Statistics<br />
<br />
Total Swap Size: .1.3.6.1.4.1.2021.4.3.0<br />
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0<br />
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0<br />
Total RAM used: .1.3.6.1.4.1.2021.4.6.0<br />
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0<br />
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0<br />
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0<br />
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0<br />
<br />
Disk Statistics<br />
<br />
The snmpd.conf needs to be edited. Add the following (assuming a machine with a single / partition):<br />
<br />
disk / 100000 (or)<br />
<br />
includeAllDisks 10% for all partitions and disks<br />
<br />
The OIDs are as follows<br />
<br />
Path where the disk is mounted: .1.3.6.1.4.1.2021.9.1.2.1<br />
Path of the device for the partition: .1.3.6.1.4.1.2021.9.1.3.1<br />
Total size of the disk/partion (kBytes): .1.3.6.1.4.1.2021.9.1.6.1<br />
Available space on the disk: .1.3.6.1.4.1.2021.9.1.7.1<br />
Used space on the disk: .1.3.6.1.4.1.2021.9.1.8.1<br />
Percentage of space used on disk: .1.3.6.1.4.1.2021.9.1.9.1<br />
Percentage of inodes used on disk: .1.3.6.1.4.1.2021.9.1.10.1
<img src ="http://www.blogjava.net/Vincent-chenxj/aggbug/283089.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Vincent-chenxj/" target="_blank">Vincent-chen</a> 2009-06-18 17:20 <a href="http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283089.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>OID</title><link>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283090.html</link><dc:creator>Vincent-chen</dc:creator><author>Vincent-chen</author><pubDate>Thu, 18 Jun 2009 09:20:00 GMT</pubDate><guid>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283090.html</guid><wfw:comment>http://www.blogjava.net/Vincent-chenxj/comments/283090.html</wfw:comment><comments>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283090.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Vincent-chenxj/comments/commentRss/283090.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Vincent-chenxj/services/trackbacks/283090.html</trackback:ping><description><![CDATA[熟悉MIB库，收集下列参数的OID信息：IP地址、MAC地址、描述、端口状态、内存利用率、CPU利用率、延时、丢包率、端口利用率等<br />
服务器还包括硬盘利用率。<br />
<br />
<br />
<br />
1、在windows上安装snmp：控制面板-&gt;添加/删除程序-&gt;添加/删除windows组件-&gt;管理和监视工具-&gt;详细信息-&gt;snmp协议<br />
2、请你们先认真了解学习PHP。在机器上安装APACHE+PHP+MYSQL的设计环境，并熟悉环境。有问题随时联系我。<br />
3、你可以在本机安装snmp agent ，之后读取本机的相关参数。 &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
部分重要OID信息：<br />
1、内存大小<br />
服务器内存的OID是：.1.3.6.1.2.1.25.2.2.0，不同的操作系统也是使用一样的OID。但是网络设备内存的OID根据设备的生产厂商不同、型号不同，其OID也是不同的。Cisco的路由器和交换机都是.1.3.6.1.4.1.9.9.48.1.1.1.5.1。华为交换机Huawei 6502、Huawei 3526、Huawei 2403的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.2.0。而华三的H3C E328和H3C E126的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.2.65536。<br />
2、&nbsp; &nbsp; &nbsp; &nbsp; 内存利用率<br />
与内存大小的OID相对应，各被监控对象的内存利用率的OID如下：<br />
服务器内存利用率的OID是.1.3.6.1.4.1.2021.4.6.0；华为交换机的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.3.0。华三交换机的OID是.1.3.6.1.4.1.2011.6.1.2.1.1.3.65536。<br />
3、&nbsp; &nbsp; &nbsp; &nbsp; 硬盘大小及利用率<br />
对于服务器的硬盘空间来说，因为每个服务器的硬盘个数和目录划分都不一样，所以读取到的目录空间大小对应的OID依次为：.1.3.6.1.2.1.25.2.3.1.5.1 、.1.3.6.1.2.1.25.2.3.1.5.2等，并且在读取每个目录空间大小的同时要读取该目录的名称（OID依次为：.1.3.6.1.2.1.25.2.3.1.3.1、.1.3.6.1.2.1.25.2.3.1.3.2等）作为该监控对象的描述。关于目录空间的利用率没有现成的OID，需要先获得目录空间的使用量（OID依次为：.1.3.6.1.2.1.25.2.3.1.6.1、.1.3.6.1.2.1.25.2.3.1.6.2、等），然后通过使用量与空间总量的比较得出利用率。<br />
4、&nbsp; &nbsp; &nbsp; &nbsp; 端口状态<br />
对于服务器来说，有的服务器为了完成复杂的功能需要配置多块网卡，因此也就会有多个端口需要监控。关于端口状态的OID则依次为：.1.3.6.1.2.1.2.2.1.7.1、.1.3.6.1.2.1.2.2.1.7.2、.1.3.6.1.2.1.2.2.1.7.3等，除了端口状态系统还需要知道该端口的名称（OID依次为：.1.3.6.1.2.1.2.2.1。2.1、.1.3.6.1.2.1.2.2.1.2.2、.1.3.6.1.2.1.2.2.1.2.3等）。在获取交换机的端口状态时首先只将状态UP的端口信息记录下来，再通过每个端口的作用来选择是否真的对其进行监控。一般网络管理员只需要监控那些用来与其它的网络设备互连的端口。这些端口的OID有的是连续的，有的则是分散的，但都属于.1.3.6.1.2.1.2.2.1.7的分支。<br />
<br />
<br />
<br />
<br />
CPU Statistics<br />
<br />
Load<br />
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1<br />
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2<br />
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3<br />
<br />
CPU<br />
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0<br />
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0<br />
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0<br />
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0<br />
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0<br />
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0<br />
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0<br />
<br />
Memory Statistics<br />
<br />
Total Swap Size: .1.3.6.1.4.1.2021.4.3.0<br />
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0<br />
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0<br />
Total RAM used: .1.3.6.1.4.1.2021.4.6.0<br />
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0<br />
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0<br />
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0<br />
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0<br />
<br />
Disk Statistics<br />
<br />
The snmpd.conf needs to be edited. Add the following (assuming a machine with a single / partition):<br />
<br />
disk / 100000 (or)<br />
<br />
includeAllDisks 10% for all partitions and disks<br />
<br />
The OIDs are as follows<br />
<br />
Path where the disk is mounted: .1.3.6.1.4.1.2021.9.1.2.1<br />
Path of the device for the partition: .1.3.6.1.4.1.2021.9.1.3.1<br />
Total size of the disk/partion (kBytes): .1.3.6.1.4.1.2021.9.1.6.1<br />
Available space on the disk: .1.3.6.1.4.1.2021.9.1.7.1<br />
Used space on the disk: .1.3.6.1.4.1.2021.9.1.8.1<br />
Percentage of space used on disk: .1.3.6.1.4.1.2021.9.1.9.1<br />
Percentage of inodes used on disk: .1.3.6.1.4.1.2021.9.1.10.1
<img src ="http://www.blogjava.net/Vincent-chenxj/aggbug/283090.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Vincent-chenxj/" target="_blank">Vincent-chen</a> 2009-06-18 17:20 <a href="http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283090.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cisco常用OID</title><link>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283080.html</link><dc:creator>Vincent-chen</dc:creator><author>Vincent-chen</author><pubDate>Thu, 18 Jun 2009 08:48:00 GMT</pubDate><guid>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283080.html</guid><wfw:comment>http://www.blogjava.net/Vincent-chenxj/comments/283080.html</wfw:comment><comments>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283080.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Vincent-chenxj/comments/commentRss/283080.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Vincent-chenxj/services/trackbacks/283080.html</trackback:ping><description><![CDATA[<div>
<pre>系统状态相关：</pre>
<pre>### THIS FILE WAS GENERATED BY MIB2SCHEMA
"org"		"1.3"
"dod"		"1.3.6"
"internet"		"1.3.6.1"
"directory"		"1.3.6.1.1"
"mgmt"		"1.3.6.1.2"
"experimental"		"1.3.6.1.3"
"private"		"1.3.6.1.4"
"enterprises"		"1.3.6.1.4.1"
"cisco"		"1.3.6.1.4.1.9"
"ciscoMgmt"		"1.3.6.1.4.1.9.9"
"ciscoEnvMonMIB"		"1.3.6.1.4.1.9.9.13"
"ciscoEnvMonObjects"		"1.3.6.1.4.1.9.9.13.1"
"ciscoEnvMonMIBNotificationEnables"		"1.3.6.1.4.1.9.9.13.2"
"ciscoEnvMonMIBNotificationPrefix"		"1.3.6.1.4.1.9.9.13.3"
"ciscoEnvMonMIBConformance"		"1.3.6.1.4.1.9.9.13.4"
"ciscoEnvMonPresent"		"1.3.6.1.4.1.9.9.13.1.1"
"ciscoEnvMonVoltageStatusTable"		"1.3.6.1.4.1.9.9.13.1.2"
"ciscoEnvMonTemperatureStatusTable"		"1.3.6.1.4.1.9.9.13.1.3"
"ciscoEnvMonFanStatusTable"		"1.3.6.1.4.1.9.9.13.1.4"
"ciscoEnvMonSupplyStatusTable"		"1.3.6.1.4.1.9.9.13.1.5"
"ciscoEnvMonAlarmContacts"		"1.3.6.1.4.1.9.9.13.1.6"
"ciscoEnvMonVoltageStatusEntry"		"1.3.6.1.4.1.9.9.13.1.2.1"
"ciscoEnvMonVoltageStatusIndex"		"1.3.6.1.4.1.9.9.13.1.2.1.1"
"ciscoEnvMonVoltageStatusDescr"		"1.3.6.1.4.1.9.9.13.1.2.1.2"
"ciscoEnvMonVoltageStatusValue"		"1.3.6.1.4.1.9.9.13.1.2.1.3"
"ciscoEnvMonVoltageThresholdLow"		"1.3.6.1.4.1.9.9.13.1.2.1.4"
"ciscoEnvMonVoltageThresholdHigh"		"1.3.6.1.4.1.9.9.13.1.2.1.5"
"ciscoEnvMonVoltageLastShutdown"		"1.3.6.1.4.1.9.9.13.1.2.1.6"
"ciscoEnvMonVoltageState"		"1.3.6.1.4.1.9.9.13.1.2.1.7"
"ciscoEnvMonTemperatureStatusEntry"		"1.3.6.1.4.1.9.9.13.1.3.1"
"ciscoEnvMonTemperatureStatusIndex"		"1.3.6.1.4.1.9.9.13.1.3.1.1"
"ciscoEnvMonTemperatureStatusDescr"		"1.3.6.1.4.1.9.9.13.1.3.1.2"
"ciscoEnvMonTemperatureStatusValue"		"1.3.6.1.4.1.9.9.13.1.3.1.3"
"ciscoEnvMonTemperatureThreshold"		"1.3.6.1.4.1.9.9.13.1.3.1.4"
"ciscoEnvMonTemperatureLastShutdown"		"1.3.6.1.4.1.9.9.13.1.3.1.5"
"ciscoEnvMonTemperatureState"		"1.3.6.1.4.1.9.9.13.1.3.1.6"
"ciscoEnvMonFanStatusEntry"		"1.3.6.1.4.1.9.9.13.1.4.1"
"ciscoEnvMonFanStatusIndex"		"1.3.6.1.4.1.9.9.13.1.4.1.1"
"ciscoEnvMonFanStatusDescr"		"1.3.6.1.4.1.9.9.13.1.4.1.2"
"ciscoEnvMonFanState"		"1.3.6.1.4.1.9.9.13.1.4.1.3"
"ciscoEnvMonSupplyStatusEntry"		"1.3.6.1.4.1.9.9.13.1.5.1"
"ciscoEnvMonSupplyStatusIndex"		"1.3.6.1.4.1.9.9.13.1.5.1.1"
"ciscoEnvMonSupplyStatusDescr"		"1.3.6.1.4.1.9.9.13.1.5.1.2"
"ciscoEnvMonSupplyState"		"1.3.6.1.4.1.9.9.13.1.5.1.3"
"ciscoEnvMonSupplySource"		"1.3.6.1.4.1.9.9.13.1.5.1.4"
"ciscoEnvMonEnableShutdownNotification"		"1.3.6.1.4.1.9.9.13.2.1"
"ciscoEnvMonEnableVoltageNotification"		"1.3.6.1.4.1.9.9.13.2.2"
"ciscoEnvMonEnableTemperatureNotification"		"1.3.6.1.4.1.9.9.13.2.3"
"ciscoEnvMonEnableFanNotification"		"1.3.6.1.4.1.9.9.13.2.4"
"ciscoEnvMonEnableRedundantSupplyNotification"		"1.3.6.1.4.1.9.9.13.2.5"
"ciscoEnvMonEnableStatChangeNotif"		"1.3.6.1.4.1.9.9.13.2.6"
"ciscoEnvMonMIBNotifications"		"1.3.6.1.4.1.9.9.13.3"
"ciscoEnvMonMIBCompliances"		"1.3.6.1.4.1.9.9.13.4.1"
"ciscoEnvMonMIBGroups"		"1.3.6.1.4.1.9.9.13.4.2"
"ciscoEnvMonMIBCompliance"		"1.3.6.1.4.1.9.9.13.4.1.1"
"ciscoEnvMonMIBComplianceRev1"		"1.3.6.1.4.1.9.9.13.4.1.2"
"ciscoEnvMonMIBGroup"		"1.3.6.1.4.1.9.9.13.4.2.1"
"ciscoEnvMonMIBGroupRev"		"1.3.6.1.4.1.9.9.13.4.2.2"
"ciscoEnvMonEnableStatChangeGroup"		"1.3.6.1.4.1.9.9.13.4.2.3"
"ciscoEnvMonMIBNotifGroup"		"1.3.6.1.4.1.9.9.13.4.2.4"
"ciscoEnvMonStatChangeNotifGroup"		"1.3.6.1.4.1.9.9.13.4.2.5"
"ciscoEnvMonMIBMiscNotifGroup"		"1.3.6.1.4.1.9.9.13.4.2.6"</pre>
<pre>系统内存信息：</pre>
<pre>
<pre>### THIS FILE WAS GENERATED BY MIB2SCHEMA
"org"		"1.3"
"dod"		"1.3.6"
"internet"		"1.3.6.1"
"directory"		"1.3.6.1.1"
"mgmt"		"1.3.6.1.2"
"experimental"		"1.3.6.1.3"
"private"		"1.3.6.1.4"
"enterprises"		"1.3.6.1.4.1"
"cisco"		"1.3.6.1.4.1.9"
"ciscoMgmt"		"1.3.6.1.4.1.9.9"
"ciscoMemoryPoolMIB"		"1.3.6.1.4.1.9.9.48"
"ciscoMemoryPoolObjects"		"1.3.6.1.4.1.9.9.48.1"
"ciscoMemoryPoolNotifications"		"1.3.6.1.4.1.9.9.48.2"
"ciscoMemoryPoolConformance"		"1.3.6.1.4.1.9.9.48.3"
"ciscoMemoryPoolTable"		"1.3.6.1.4.1.9.9.48.1.1"
"ciscoMemoryPoolUtilizationTable"		"1.3.6.1.4.1.9.9.48.1.2"
"ciscoMemoryPoolEntry"		"1.3.6.1.4.1.9.9.48.1.1.1"
"ciscoMemoryPoolType"		"1.3.6.1.4.1.9.9.48.1.1.1.1"
"ciscoMemoryPoolName"		"1.3.6.1.4.1.9.9.48.1.1.1.2"
"ciscoMemoryPoolAlternate"		"1.3.6.1.4.1.9.9.48.1.1.1.3"
"ciscoMemoryPoolValid"		"1.3.6.1.4.1.9.9.48.1.1.1.4"
"ciscoMemoryPoolUsed"		"1.3.6.1.4.1.9.9.48.1.1.1.5"
"ciscoMemoryPoolFree"		"1.3.6.1.4.1.9.9.48.1.1.1.6"
"ciscoMemoryPoolLargestFree"		"1.3.6.1.4.1.9.9.48.1.1.1.7"
"ciscoMemoryPoolUtilizationEntry"		"1.3.6.1.4.1.9.9.48.1.2.1"
"ciscoMemoryPoolUtilization1Min"		"1.3.6.1.4.1.9.9.48.1.2.1.1"
"ciscoMemoryPoolUtilization5Min"		"1.3.6.1.4.1.9.9.48.1.2.1.2"
"ciscoMemoryPoolUtilization10Min"		"1.3.6.1.4.1.9.9.48.1.2.1.3"
"ciscoMemoryPoolCompliances"		"1.3.6.1.4.1.9.9.48.3.1"
"ciscoMemoryPoolGroups"		"1.3.6.1.4.1.9.9.48.3.2"
"ciscoMemoryPoolCompliance"		"1.3.6.1.4.1.9.9.48.3.1.1"
"ciscoMemoryPoolComplianceRev1"		"1.3.6.1.4.1.9.9.48.3.1.2"
"ciscoMemoryPoolGroup"		"1.3.6.1.4.1.9.9.48.3.2.1"
"ciscoMemoryPoolUtilizationGroup"		"1.3.6.1.4.1.9.9.48.3.2.2"
</pre>
</pre>
<pre></pre>
</div>
<img src ="http://www.blogjava.net/Vincent-chenxj/aggbug/283080.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Vincent-chenxj/" target="_blank">Vincent-chen</a> 2009-06-18 16:48 <a href="http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283080.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Communicating with SNMP using C# - The Very Beginning </title><link>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283059.html</link><dc:creator>Vincent-chen</dc:creator><author>Vincent-chen</author><pubDate>Thu, 18 Jun 2009 07:30:00 GMT</pubDate><guid>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283059.html</guid><wfw:comment>http://www.blogjava.net/Vincent-chenxj/comments/283059.html</wfw:comment><comments>http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283059.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Vincent-chenxj/comments/commentRss/283059.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Vincent-chenxj/services/trackbacks/283059.html</trackback:ping><description><![CDATA[<div style="float: right; margin-left: 5px"></div>
<p><span style="font-weight: bold; font-size: 130%; color: rgb(102,0,0)">Who Should Read This</span><br />
</p>
<ol style="color: rgb(0,0,0)">
    <li>You want to program <span style="font-weight: bold">SNMP</span> with <span style="font-weight: bold">C#</span> but have no idea for beginning.
    <li>You've googled for a while, but don't get a simple working example.
    <li>What you're looking for, is just a simple requirement to get a status value from a device through <span style="font-weight: bold">SNMP</span>.</li>
</ol>
<br />
<span style="font-size: 130%; color: rgb(102,0,0)"><span style="font-weight: bold">Introduction</span></span><br />
My purpose is to get an uint value from a temperature sensor through SNMP. This is a very simple requirement, and I don't want to understand the whole detail of SNMP protocol. In JAVA, there's lot of open source resources for SNMP<span style="font-weight: bold"> </span>programming, for example, SNMP<span style="font-weight: bold">4j.</span> How ever, I found no simple guidance for <span style="font-weight: bold">C# </span>SNMP programming. If you have the same problem, you can have following example to start your way toward SNMP.<br />
<br />
<span style="font-size: 130%; color: rgb(102,0,0)"><span style="font-weight: bold">Pre-requirement<br />
</span></span>
<ol>
    <li><span style="font-weight: bold">C# </span>Programming Basics
    <li>A working SNMP<span style="font-weight: bold"> </span>host to communicate with. For example, a temperature sensor, a networked printer or a router with SNMP<span style="font-weight: bold"> </span>functions.<br />
    </li>
</ol>
<span style="font-size: 130%; color: rgb(102,0,0)"><span style="font-weight: bold">Sample SNMP Class<br />
</span></span>Firstly, you have to add a reference to OLEPRNLIB. You can find it from "Add reference" -&gt; "COM". The path of the dll is located at C:\Windows\System32 by Default.<br />
<br />
Here is a sample SNMP Class:<br />
<hr />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using OLEPRNLib;<br />
<br />
namespace MrFu<br />
{<br />
public class SimpleSnmp<br />
{<br />
private String hostIp;<br />
private String oid;<br />
private String communityString;<br />
<br />
int retries = 1;<br />
int timeout = 3000;<br />
<br />
SNMP snmp = new SNMP();<br />
<br />
public SimpleSnmp(String hostIp, String communityString, String oid)<br />
{<br />
this.hostIp = hostIp;<br />
this.communityString = communityString;<br />
this.oid = oid;<br />
<br />
try<br />
{<br />
snmp.Open(this.hostIp, this.communityString, this.retries, this.timeout);<br />
}<br />
catch (Exception ex) {<br />
Console.WriteLine(ex.Message);<br />
}<br />
<br />
}<br />
<br />
public String getValue() {<br />
try<br />
{<br />
uint result = snmp.GetAsByte(this.oid);<br />
return result.ToString();<br />
}<br />
catch (Exception ex) {<br />
Console.WriteLine(ex.Message);<br />
return null;<br />
}<br />
}<br />
}<br />
}<br />
<hr />
<br />
<span style="font-size: 130%; color: rgb(102,0,0)"><span style="font-weight: bold">Description for the Code</span></span><br />
<br />
First line you need to look at is:<br />
<blockquote>snmp.Open(this.hostIp, this.communityString, this.retries, this.timeout);<br />
</blockquote>where the "<span style="font-weight: bold">hostIp</span>" is the IP address of the target, of course,<br />
<br />
the "<span style="font-weight: bold">communityString</span>" is "public" by default for most SNMP device. If you changed it on device configuration, remember to modify it.<br />
<br />
the "<span style="font-weight: bold">retries</span>" and "<span style="font-weight: bold">timeout</span>" indicate how many times the system should retry if connection failed over the milliseconds given by "timeout".<br />
<br />
And, That's All to Connect to A Device Through SNMP. COOL!<br />
<br />
Second line you might want to know is:<br />
<blockquote>uint result = snmp.GetAsByte(this.oid);</blockquote>That's the basic way to get the status or value from your host device. You can convert it into String or any thing you like.<br />
<br />
To explain in a simple way, the "oid" is the unique id for some status on the device. You can obtain the correct oid from your device manual. For example, the <span style="font-weight: bold">oid </span>of my temperature sensor is:<br />
<blockquote style="font-weight: bold">".1.3.6.1.4.1.3854.1.2.2.1.16.1.3.0"</blockquote>So you should be able to find some string looks like that from your device suppliers or documents.<br />
<br />
For more detailed description of SNMP<span style="font-weight: bold"> </span>protocol, you can look into wikipedia.<br />
<br />
That's all. So easy, and you can have a first shot of SNMP<span style="font-weight: bold"> </span>programming with C# now.<br />
<br />
<br />
<span style="font-weight: bold; font-size: 130%; color: rgb(102,0,0)">Conclusin</span><br />
This is quiet a easy way to have a quick look of SNMP<span style="font-weight: bold"> </span>progamming with <span style="font-weight: bold">C#</span>. Surely, the detailed packet parsing or other SNMP<span style="font-weight: bold"> </span>functions are NOT shown in this post. But that's all I need to solve my problem. And I hope this post can help you, too.
<img src ="http://www.blogjava.net/Vincent-chenxj/aggbug/283059.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Vincent-chenxj/" target="_blank">Vincent-chen</a> 2009-06-18 15:30 <a href="http://www.blogjava.net/Vincent-chenxj/archive/2009/06/18/283059.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>