- 浏览: 387939 次
- 性别:
- 来自: 北京
最新评论
-
liuzhongzhou2721:
不错啊
Snmp4j编程简介之三:Snmp -
ahong520:
我在Keystore.getInstance("JK ...
java实现 SSL双向认证 -
tanghanlin:
好吧,还是支持下
Snmp4j编程简介之三:Snmp -
sjp524617477:
mark
java实现 SSL双向认证 -
dikesky:
您好,看了您的这篇文章学到很多东西。希望您提供一个QQ号(发到 ...
httpclient笔记(二)
对于更多的net-snmp的资料,可以去www.net-snmp.org中获得.
另外,net-snmp在FC6上可以正确编译通过,在FC4上编译时却发现二个错误,一个是找不到libbeencrypt.la这个文件,第二个错误是无法链接到elf库.
如果出现这二个错误,去网络上下载以下二个软件包进行编译就行了:
1.beecrypt-4.1.2.tar.gz
2.libelf-0.8.10.tar.gz
On Redhat 7.1 or above, NetSnmp has become the default snmp...
But on other linux version. It is still a good guide.
In this tutorial we will
- download and install net-snmp,
- write and install a simple MIB,
- write a subagent to handle to mib.
Download and install net-snmp package
This package was previously known as ucd-snmp
- Download the source from here, or if this link is broken try the net-snmp homepage, to your local directory which we will now refer to as $. For this tutorial we will use net-snmp-5.0-pre2.
- change directory to $, untar and unzip the package using:
$gunzip net-snmp-5.0.pre2.tar.gz $tar xvf net-snmp-5.0.pre2.tar
This will dump all the souce into $/net-snmp-5.0.pre2 - To compile to package:
$./configure --with-mib-modules="agentx" $make $make install $cd local; make install; cd .. $cd mibs; make install; cd ..
The "configure" command configure the agent to use the AgentX protocol. This is a IETF defined protocol that allows a master/client relationship between agents and subagents. The last two command should not theoretically have to be to used ... but without them .. things do not seem to work. Now, we have to setup the snmpd configuration file, before "snmpd" can work properly. - Copy the example configuration file:
$ cp $/EXAMPLE.conf /usr/local/share/snmp/snmpd.conf
- Now we need to modify /usr/local/share/snmp/snmpd.conf as follows:
- Replace COMMUNITY with "democommunity". This is your community string.
- Comment out 2nd "com2sec" line. We do not allow network access for now.
- On a new line at the end of the file add "master agentx". This tells the agents to behave as the master in the master/client AgentX protocol.
- We now need to fix some library links (this is truely awful ... is this a Redhat or a net-snmp "problem"/"feature" ?)(Note: On some machines this is not required e.g RedHat 7.1 ... use your judgement :-))
$ln -s /usr/local/lib/libnetsnmp-0.5.0.0.2.so /lib/libnetsnmp-0.5.0.0.2.so $ln -s /usr/local/lib/libnetsnmpagent-0.5.0.0.2.so /lib/libnetsnmpagent-0.5.0.0.2.so $ln -s /usr/local/lib/libnetsnmphelpers-0.5.0.0.2.so /lib/libnetsnmphelpers-0.5.0.0.2.so $ln -s /usr/local/lib/libnetsnmpmibs-0.5.0.0.2.so /lib/libnetsnmpmibs-0.5.0.0.2.so
- To check "snmpd" do:
become root$ ps awwux | grep snmp
if you see an earlier snmpd deamon ... kill it$ cd $/net-snmp-5.0.pre2/agent $ ./snmpd -f -L
This should start the "snmpd" agent but keep it attached to the current terminal (which is useful since we want to kill it very soon). - On another window:
$snmpget -v 1 -c democommunity localhost system.sysUpTime.0
If snmpd was installed correctly, this gives up the timeticks the snmpd agent has been up (NOT how long your system was up !!). If you get an error .. retrace your steps from the beginning.You can now use "^C" to kill the snmpd deamon in the first window.
Writing and installing a MIB
In this part of the the tutorial we will write and install a simple MIB.
- First write the mib that you want to implement. For our tutorial we write a simple MIB called JM-TEST-1-MIB.txt:
JM-TEST-1-MIB DEFINITIONS ::= BEGIN IMPORTS MODULE-IDENTITY, OBJECT-TYPE, INTEGER FROM SNMPv2-SMI; jmtest MODULE-IDENTITY LAST-UPDATED "200203210000Z" ORGANIZATION "Temple U" CONTACT-INFO "None yet." DESCRIPTION "AgentX testing MIB" REVISION "200203210000Z" DESCRIPTION "None yet." ::= { experimental 72} firstKey OBJECT-TYPE SYNTAX INTEGER (0..100) MAX-ACCESS read-write STATUS current DESCRIPTION "Value initialized to 0 and on each access: - Return current val. - increment" ::= { jmtest 1 } END
This mib represents a resource "firstKey" whose initial value is 0 and whose value gets incremented every time it is queried.
Note that this MIB will be registered under the 1.3.6.1.3.72 heirarchy. This choice is arbitrary and should only be used for experiments. For real world implementation you should get a "real" OID. Existing OIDs and guidelines on getting new ones can be fo und here. This page is maintained by the current (March 2002) IETF/IESG chair, so he probably knows what he is talking about.
Copy this mib into the mibs directory
$cp JM-TEST-1-MIB.txt /usr/local/share/snmp/mibs
- Now we need to get the SNMP tools to recognise this MIB. So:
$echo "mibs +JM-TEST-1-MIB" >> /usr/local/share/snmp/snmp.conf
This adds a directive to the snmp tools configuration asking them load our mib. - To verify if our MIB is loaded use the verstile snmptranslate command:
$snmptranslate -IR -Tp experimental
This command will draw the present tree under the experimental branch. Omit the last parameter and you will get the whole tree (as currenly understood by the snmp tools). The output should look like:Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } +--experimental(3) | +--jmtest(72) +-- -RW- INTEGER firstKey(1) Range: 0..100
If you get the above output, then we are in good shape so far. The real work, howeve still remains. We must now write the subagent that will handle queries on under this OID branch.
Writing and installing a subagent
In this section we will write and install a subagent that serves the mib we installed in the previous section.
The subagent is an independent program that communicates with the master agent (snmpd in our case) using the AgentX protocol.
The basic steps of writing the code is as follows:
- Write the agent code in a C file, say example.c. This can be done using the mib2c tool.
- Create the subagent executable using the net-snmp-config tool.
mib2c is (supposed to) take in the MIB definition as spit out the subagent code. However (as far as I could figure out) the mib2c program distributed with this version of net-snmp does not generate code for simple scalar mibs, instead dealing with mibs th at have tables.
So for an example of subagent code for simple scalar objects look at $/agent/mibgroups/example/example.c.
We have adapted example.c for our mib (JM-TEST-1-MIB.txt) as example2.c.
- Download example2.c and example1.h
$mkdir $/agent/mibgroup/examples/subagent $cp example2.c $/agent/mibgroup/examples/subagent $cp example.h $/agent/mibgroup/examples/subagentNow we create the executable using the net-snmp-config tools as:
$net-snmp-config --compile-subagent example2 example2.c -I../../../mibgroupThis produces a executable called example2. example2 is our subagent. Voila !
To test whether things are still working.
In first window:
$cd $/agent $./snmpd -f -L -DThis will start the snmpd deamon in the debugging mode (you will see LOTS of messages).
In the second window:
$cd agent/mibgroup/examples/subagent $./example2Finally in the third window, the command and output should look like (output is shown in bold):
[root@x mibs]# snmpget -v 1 -c democommunity localhost firstKey.0 Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } JM-TEST-1-MIB::firstKey.0 = 1 [root@x mibs]# snmpget -v 1 -c democommunity localhost 1.3.6.1.3.72.1.0 Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } JM-TEST-1-MIB::firstKey.0 = 2 [root@x mibs]# snmpset -v 1 -c democommunity localhost 1.3.6.1.3.72.1.0 i 10 Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } JM-TEST-1-MIB::firstKey.0 = 10 [root@x mibs]# snmpget -v 1 -c democommunity localhost firstKey.0 Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } JM-TEST-1-MIB::firstKey.0 = 10 [root@x mibs]# snmpget -v 1 -c democommunity localhost 1.3.6.1.3.72.1.0 Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } JM-TEST-1-MIB::firstKey.0 = 11 [root@x mibs]# snmpget -v 1 -c democommunity localhost 1.3.6.1.3.72.1.0 Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } JM-TEST-1-MIB::firstKey.0 = 12 [root@x mibs]# snmpwalk -v 1 -c democommunity localhost firstKey Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 } JM-TEST-1-MIB::firstKey.0 = 13In the output above notice that every snmpget query returns an increasing value of "firstKey" and snmpset lets us set "firstKey" to an arbitrary value (within a defined range).
We now have a working subagent. In real applications the subagent could be embedded in the application to be managed.
--by Jaiwant Mulik, March 2002.
------------------------------------------------------------------------------------------------------------------------
cannot find the library `/usr/lib/libbeecrypt.la'
安装beecrypt包后,还是报相同的错,按说应该安装成功了,为什么还很难找到呢?
发现默认安装时,libbeecrypt.la安装在了/usr/local/lib目录下。
建立符号连接 ln -s /usr/local/lib/libbeecrypt.la /usr/lib/libbeecrypt.la
然后进行安装
./configure --prefix=/usr/local/net-snmp
make
make install
安装成功!
发表评论
-
你可能不知道的10个JavaScript小技巧
2010-09-07 17:05 1075“梦想天空”(网名)曾发表一篇博文,为我们介绍了10个Java ... -
监控利器nagios
2009-04-01 17:32 3067我的Nagios的艰辛.....网络监控之神(一)本贴原创,转 ... -
Tomcat配置指南(转载)
2009-03-11 10:54 1147Tomcat配置指南(转载) 一 ... -
谈谈Unicode编码,简要解释UCS、UTF、BMP、BOM等名词
2009-02-27 14:33 1243这是一篇程序员写给程 ... -
SnmpHibernate
2008-12-18 14:44 1791SnmpHibernate is a MIB/Object ... -
常用的数字编码格式
2008-12-17 17:39 2592常用数字编码1.BCD编码 在数字系统中,各种数据要转换为二进 ... -
Java中四种XML解析技术之不完全测试
2008-12-16 11:00 1014测试环境: AMD毒龙1.4G ... -
Javascript闭包技术
2008-11-24 09:46 1386一、什么是闭包?“官 ... -
多线程
2008-07-25 16:35 1479线程:是指进程中的 ... -
Apache,Resin,JVM 状态监控
2008-07-24 13:21 3259不管你是网站系统管理员,还是WEB开发人员,了解你的WEB应用 ... -
使用Jconsole对java的内存使用情况(JVM)进行监控
2008-07-24 11:26 2814JDK1.5提供JMX remote的管理工具Jconsole ... -
Linux下网络流量监控
2008-07-24 10:23 2017(一) 系统环境:redhat9.0 必备软件: (这些软件都 ... -
net-snmp安装手记
2008-07-23 11:36 7563Installing /usr/share/man/man3/ ... -
RFC1155基于TCP/IP网络的管理结构和标记
2008-07-10 10:37 2303组织:中国互动出版网(http://www.china-pub ... -
Snmp4j编程简介之三:Snmp
2008-07-03 13:03 9529Class Snmp java.lang.Object o ... -
Snmp4j编程简介之二:PDU
2008-07-03 13:00 6704PDU(协议数据单元),用来表示管理站跟代理站点进行通信的数据 ... -
Snmp4j编程简介之一:Target
2008-07-03 12:57 4742关于Snmp4j包,最重要三个概念,也是三个类:Snmp、Ta ... -
Java远程通讯可选技术及原理
2008-06-23 11:45 1351Java远程通讯可选技术及原理 在分布式服务框架中 ... -
基于Spring的远程访问与Web Service(二)
2008-06-20 16:33 5014Spring框架对远程访问技 ... -
通过Spring使用远程访问和web服务
2008-06-20 13:47 1982Spring提供类用于集成各种远程访问技术。这种对远程访问的支 ...
相关推荐
在安装net-snmp-5.9.4之前,确保系统满足依赖项,然后按照官方文档的步骤进行编译和安装。安装完成后,配置文件通常位于/etc/snmp/目录下,包括snmpd.conf(代理配置)和snmp.conf(客户端配置)。根据实际需求,...
3. 安装 Net-SNMP:使用 make install 命令安装 Net-SNMP。 Net-SNMP 工具 Net-SNMP 提供了多种工具,用于实现 SNMP 管理功能,包括: 1. snmpd:响应 SNMP 请求包的代理服务器。 2. snmptrapd:接收并记录 SNMP ...
它包含了net-snmp的安装程序net-snmp-5.5.0-2.x64.exe和一份ReadMe.txt说明文件。在安装前,务必确保你的系统是64位的,以确保软件正常运行。 安装过程中,用户可以选择自定义安装路径。如果选择非默认路径,需要...
在本文中,我们将详细探讨net-snmp-5.8版本,以及如何通过解压、编译和安装来使用这个强大的网络管理工具。 首先,我们关注的是标题中的“net-snmp-5.8.tar.gz”,这是一个gzip压缩过的tar文件,通常用于在Unix/...
首先,让我们来看看"net-snmp-5.6.1.1-1.x86.exe"这个文件。这是一款针对x86架构的Windows系统的可执行安装程序,用于在Windows平台上部署NET-SNMP 5.6.1.1版本。在运行这个文件之前,确保你的系统满足以下基本要求...
《深入理解net-snmp 5.7.2:开源SNMP软件开发的基石》 SNMP(简单网络管理协议)是网络管理员用来监控和管理网络设备的重要工具,而net-snmp是一个广泛使用的开源SNMP软件开发包。net-snmp 5.7.2版本为Linux环境...
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (8137) 0:01:21.37 ... 这些信息包括了系统描述、对象标识、系统uptime 等信息。 在 ...
《深入理解net-snmp-5.7.3:源码编译与安装指南》 net-snmp是一款功能强大的网络管理软件套件,主要用于网络设备的监控、管理和数据收集。其5.7.3版本提供了丰富的功能和改进,适用于各种网络环境。在本文中,我们...
这个源码包,net-snmp-5.9.1.tar.gz,是一个可移植的版本,特别适合开发学习,让开发者能够深入了解SNMP的工作原理以及如何利用它来管理和监控网络设备。 一、SNMP基础 SNMP是Internet标准协议,用于管理网络设备,...
- 示例命令:`wget http://www.net-snmp.org/download/releases/net-snmp-5.3.2.tar.gz` 2. **解压安装包** - 在终端中切换至root用户:`sudo su` - 进入下载文件所在的目录:`cd /path/to/download/folder` -...
《深入理解net-snmp-5.7.2在Cacti安装中的应用》 网络监控是IT运维工作的重要环节,而Cacti作为一款广泛使用的开源网络监控工具,其依赖于net-snmp库来实现对网络设备的SNMP(简单网络管理协议)通信。本文将详述...
net-snmp-5.5-49.el6_5.3.x86_64.rpm net-snmp-devel-5.5-49.el6_5.3.i686.rpm net-snmp-devel-5.5-49.el6_5.3.x86_64.rpm net-snmp-libs-5.5-49.el6_5.3.i686.rpm net-snmp-libs-5.5-49.el6_5.3.x86_64.rpm ...
- **x86 exe 版本**:如果仅需要安装而无需编译,可以选择下载预编译的 x86 exe 版本,如 net-snmp-5.5.0-1.x86.exe。 #### 二、Windows 环境配置 ##### 2.1 编译环境选择 Net-SNMP 支持在多种 Windows 编译环境中...
首先,"net-snmp-5.5x64x86.zip"这个压缩包包含了两个版本的net-snmp工具,分别是"net-snmp-5.5.0-2.x64.exe"和"net-snmp-5.5.0-1.x86.exe",分别适用于64位和32位的Windows系统。这意味着无论你的Windows环境是32位...
《深入理解net-snmp-5.5.0-2.x64:构建高效SNMP网络管理》 在当今的IT环境中,网络管理是一项至关重要的任务,而SNMP(Simple Network Management Protocol)作为网络管理的标准协议,起着核心作用。本文将深入探讨...
在压缩包中,"www.pudn.com.txt"可能是包含相关资源链接或文档的文本文件,而"net-snmp-5.4.1"是实际的源代码或编译后的二进制文件。开发者需要根据实际情况决定如何处理这些文件,例如,源代码可能需要编译以适应...
net-snmp-5.7.3 linux windows macqt-net-snmp library is a C++/Qt abstraction layer over Net-SNMP API that provides a basic support to SNMPv1/2 requests.
yum install -y perl-devel perl-ExtUtils-Embed elfutils-devel elfutils-libelf-devel lm_sensors-devel rpm-devel perl-Tk perl-Mail-Sender perl-JSON perl-IO-Socket-SSL perl-Net-SSLeay perl-IO-Socket-IP ...
net-snmp-5.7.0-1.x86.exe 客户端windows。
"Net-SNMP-5.4.3" 是一个专为Linux系统设计的网络简单网络管理协议(SNMP)工具包。SNMP是一种广泛应用于网络设备管理的标准协议,允许管理员远程监控和管理网络设备,如路由器、交换机、服务器等。Net-SNMP是一个...