- 浏览: 382361 次
- 性别:
- 来自: 北京
最新评论
-
liuzhongzhou2721:
不错啊
Snmp4j编程简介之三:Snmp -
ahong520:
我在Keystore.getInstance("JK ...
java实现 SSL双向认证 -
tanghanlin:
好吧,还是支持下
Snmp4j编程简介之三:Snmp -
sjp524617477:
mark
java实现 SSL双向认证 -
dikesky:
您好,看了您的这篇文章学到很多东西。希望您提供一个QQ号(发到 ...
httpclient笔记(二)
常用SNMP OID
Linux SNMP OID’s for CPU,Memory and Disk Statistics
SNMP stands for Simple Network Management Protocol and consists of three key components: managed devices, agents, and network-management systems (NMSs). A managed device is a node that has an SNMP agent and resides on a managed network. These devices can be routers and access server, switches and bridges, hubs, computer hosts, or printers. An agent is a software module residing within a device. This agent translates information into a compatible format with SNMP. An NMS runs monitoring applications. They provide the bulk of processing and memory resources required for network management.
SNMP MIBs, OIDs Overview
MIB stands for Management Information Base and is a collection of information organized hierarchically. These are accessed using a protocol such as SNMP. There are two types of MIBs: scalar and tabular. Scalar objects define a single object instance whereas tabular objects define multiple related object instances grouped in MIB tables.
MIB files for specific devices or systems can be downloaded from here
OIDs or Object Identifiers uniquely identify manged objects in a MIB hierarchy. This can be depicted as a tree, the levels of which are assigned by different organizations. Top level MIB object IDs (OIDs) belong to different standard organizations. Vendors define private branches including managed objects for their own products.
Here is a sample structure of an OID
Iso (1).org(3).dod(6).internet(1).private(4).transition(868).products(2).chassis(4).card(1).slotCps(2)
.cpsSlotSummary(1).cpsModuleTable(1).cpsModuleEntry(1).cpsModuleModel(3).3562.3
Most of the people may be looking for OID’s for Linux OID’s for CPU,Memory and Disk Statistics for this first you need to install SNMP server and clients. If you want to install SNMP server and client installation in linux学习 check here
CPU Statistics
Load
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3
CPU
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0
Memory Statistics
Total Swap Size: .1.3.6.1.4.1.2021.4.3.0
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0
Total RAM used: .1.3.6.1.4.1.2021.4.6.0
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0
Disk Statistics
The snmpd.conf needs to be edited. Add the following (assuming a machine with a single ‘/’ partition):
disk / 100000 (or)
includeAllDisks 10% for all partitions and disks
The OIDs are as follows
Path where the disk is mounted: .1.3.6.1.4.1.2021.9.1.2.1
Path of the device for the partition: .1.3.6.1.4.1.2021.9.1.3.1
Total size of the disk/partion (kBytes): .1.3.6.1.4.1.2021.9.1.6.1
Available space on the disk: .1.3.6.1.4.1.2021.9.1.7.1
Used space on the disk: .1.3.6.1.4.1.2021.9.1.8.1
Percentage of space used on disk: .1.3.6.1.4.1.2021.9.1.9.1
Percentage of inodes used on disk: .1.3.6.1.4.1.2021.9.1.10.1
System Uptime: .1.3.6.1.2.1.1.3.0
Examples
These Commands you need to run on the SNMP server
Get available disk space for / on the target host
#snmpget -v 1 -c “community” target_name_or_ip .1.3.6.1.4.1.2021.9.1.7.1
this will return available disk space for the first entry in the ‘disk’ section of snmpd.conf; replace 1 with n for the nth entry
Get the 1-minute system load on the target host
#snmpget -v 1 -c “community” target_name_or_ip .1.3.6.1.4.1.2021.10.1.3.1
Get the 5-minute system load on the target host
#snmpget -v 1 -c “community” target_name_or_ip .1.3.6.1.4.1.2021.10.1.3.2
Get the 15-minute system load on the target host
#snmpget -v 1 -c “community” target_name_or_ip .1.3.6.1.4.1.2021.10.1.3.3
Get amount of available swap space on the target host
#snmpget -v 1 -c “community” target_name_or_ip .1.3.6.1.4.1.2021.4.4.0
import java.io.IOException; import java.net.InetAddress; import java.util.Vector; import org.snmp4j.AbstractTarget; import org.snmp4j.CommunityTarget; import org.snmp4j.PDU; import org.snmp4j.Snmp; import org.snmp4j.TransportMapping; import org.snmp4j.event.ResponseEvent; import org.snmp4j.mp.SnmpConstants; import org.snmp4j.smi.Address; import org.snmp4j.smi.GenericAddress; import org.snmp4j.smi.OID; import org.snmp4j.smi.OctetString; import org.snmp4j.smi.UdpAddress; import org.snmp4j.smi.VariableBinding; import org.snmp4j.transport.DefaultUdpTransportMapping; public class SNMP_oper ...{ public static void main(String[] args) ...{ try ...{ Address targetAddress = GenericAddress.parse("udp:127.0.0.1/161"); TransportMapping transport = new DefaultUdpTransportMapping(); Snmp snmp = new Snmp(transport); transport.listen();//监听 CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public"));//设置共同体名 target.setAddress(targetAddress);//设置目标Agent地址 target.setRetries(2);//重试次数 target.setTimeout(5000);//超时设置 target.setVersion(1);//版本 PDU request = new PDU(); request.setType(PDU.GET);//操作类型GET request.add(new VariableBinding(new OID(".1.3.6.1.2.1.1.1.0")));//OID_sysDescr request.add(new VariableBinding(new OID(".1.3.6.1.2.1.1.2.0")));//OID_sysObjectID request.add(new VariableBinding(new OID(".1.3.6.1.2.1.1.3.0")));//OID_sysUpTime System.out.println("Request UDP:" + request); ResponseEvent respEvt = snmp.send(request, target); //读取得到的绑定变量 if (respEvt != null && respEvt.getResponse()!=null) ...{ Vector <VariableBinding> revBindings = respEvt.getResponse().getVariableBindings(); for (int i=0; i<revBindings.size();i++) ...{ VariableBinding vbs = revBindings.elementAt(i); System.out.println(vbs.getOid()+":"+vbs.getVariable()); } } } catch (IOException e) ...{ e.printStackTrace(); } } }
更详细是资料 http://blog.chinaunix.net/u/10921/showart_202809.html
评论
使用您的这段代码试了一下,能读取到本机的一些信息,然后我把IP改成远程主机的就读取不到信息了,但是我用MG-SOFT MIB Browser能读取到那台的信息,比如已运行时间什么的,这是为什么?
是不是OID的格式有问题,最前面的那个点代表什么?
谢谢
你好又有个问题要问你,table型的数据要怎么全部读出来。例如网络流入数据包这个信息,它的oid是1.3.6.1.2.1.2.2.1.10.0,这个oid对应着是一个表格。如果按照上面讲的方法去做,那么只能读出table的第一个数据。如果想全部读出来要怎么做呢?网上搜来一段程序,如下......OID[] columns = new OID[1]; columns[0] = new VariableBinding(new OID ("1.3.6.1.2.1.2.2.1.10.0")).getOid(); List list = tu.getTable(target, columns, null, null); System.out.println(list.size()); for(int i=0;i<list.size();i++){ System.out.println("aaaaaa"); System.out.println(list); TableEvent te = (TableEvent)list.get(i); System.out.println("bbbb"); VariableBinding [] vbs = te.getColumns(); System.out.println(vbs[0]); for(int j=0;j<vbs.length;j++){ System.out.println(vbs[j]); } }..............但是运行会出错误,不知道该怎么办,能指导下吗,谢谢
上面的例子,返回的是个ResponseEvent,如果返回的是个Table,我觉得应该用TableEvent,这个我没有用到过,你可以试试看。
The TableEvent class reports events in a table retrieval operation.
网上搜来一段程序,如下
......
OID[] columns = new OID[1];
columns[0] = new VariableBinding(new OID ("1.3.6.1.2.1.2.2.1.10.0")).getOid();
List list = tu.getTable(target, columns, null, null);
System.out.println(list.size());
for(int i=0;i<list.size();i++){
System.out.println("aaaaaa");
System.out.println(list);
TableEvent te = (TableEvent)list.get(i);
System.out.println("bbbb");
VariableBinding [] vbs = te.getColumns();
System.out.println(vbs[0]);
for(int j=0;j<vbs.length;j++){
System.out.println(vbs[j]);
}
}
..............
但是运行会出错误,不知道该怎么办,能指导下吗,谢谢
不同硬件设备的OID是不一样的,与设备的制造商有关,通过一些开源的监控设备可以检测到这些OID的值,或者咨询设备生产商。
如果开发通用的监控程序,必须知道你所检测设备中各项功能的OID值,如果只是自己公司内部用的,可以自己实现这些功能,比如监测CPU等信息。
谢谢!明白了
你好,我最近也在做一个snmp4j的开发项目,类似于网络监测系统。要显示服务器的cpu和内存以及磁盘的使用情况。看了你的关于snmp的资料,收获很多。这里有个问题想请教下:服务器的cpu、内存的oid,不同的机器是一样的吗?还是说不同的机器的cpu和内存有不同的oid?我写了一个target的程序,能够读出public的oid,例如系统的名字和运行时间等。那如果要读取cpu的相关信息的话,直接按照你给的oid去读取如:CPUpercentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0raw user cpu time: .1.3.6.1.4.1.2021.11.50.0percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0raw system cpu time: .1.3.6.1.4.1.2021.11.52.0percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0还是要查找针对相应机器的cpu的oid。还有就是如果我想查看我的目标服务器的cpu和内存以及磁盘的oid的话,要怎么做,谢谢!
不同硬件设备的OID是不一样的,与设备的制造商有关,通过一些开源的监控设备可以检测到这些OID的值,或者咨询设备生产商。
如果开发通用的监控程序,必须知道你所检测设备中各项功能的OID值,如果只是自己公司内部用的,可以自己实现这些功能,比如监测CPU等信息。
你好,我最近也在做一个snmp4j的开发项目,类似于网络监测系统。要显示服务器的cpu和内存以及磁盘的使用情况。看了你的关于snmp的资料,收获很多。这里有个问题想请教下:服务器的cpu、内存的oid,不同的机器是一样的吗?还是说不同的机器的cpu和内存有不同的oid?我写了一个target的程序,能够读出public的oid,例如系统的名字和运行时间等。
那如果要读取cpu的相关信息的话,直接按照你给的oid去读取
如:
CPU
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0
还是要查找针对相应机器的cpu的oid。
还有就是如果我想查看我的目标服务器的cpu和内存以及磁盘的oid的话,要怎么做,谢谢!
发表评论
-
OpenNMS® 安裝指南
2011-03-10 16:20 1843THIS DOCUMENT IS FOR OpeNNMS 1. ... -
OSGI学习笔记(三)
2010-09-09 11:08 1149OSGi依赖性管理 OSGi允许您把您的应用程序分成多个模 ... -
OSGI学习笔记(二)
2010-09-09 11:03 1484开发一个简单的Hello World的OSGi Bundle( ... -
OSGI学习笔记(一)
2010-09-09 10:43 1157OSGi是什么 OSGi亦称做Java语言的动态模块系统,它 ... -
Javarebel小试
2010-09-07 16:49 33431 Javarebel简介 JavaRebel是一个JV ... -
240多个jQuery插件下载地址
2009-08-11 17:24 11967概述 jQuery 是继 prototype 之后又一个优秀 ... -
关于SNMP的RFC文档号
2009-05-04 16:10 4550一. SMIv1Full Standards: ... -
JavaCard CPU的设计与FPGA实现
2009-05-04 14:28 21961 JavaCard简介 智能 ... -
Java Card 技术(三)
2009-05-04 14:17 2605Java Card 应用程序的元素 请记住,Java ... -
Java Card 技术(二)
2009-05-04 14:13 2713本系列文章的第 1 部分介绍了 Java Card 技术的 ... -
Extjs学习笔记(一)
2008-12-15 13:39 1598下载extj :http://extjs.com/deploy ... -
ftp4j之FTP
2008-12-01 10:11 3706The ftp4j library implements a ... -
James学习笔记
2008-11-25 15:13 3369Apache James 简称 James, 是 Java ... -
非阻塞的Socket链接(来自老紫竹)
2008-11-25 11:10 1712import java.io.IOException; ... -
java实现 SSL双向认证
2008-11-24 16:36 31187实现技术:JSSE(Java Security Socket ... -
编码传说
2008-11-21 17:38 1298很久很久以前,有一群人,他们决定用8个可以开合的晶体管来 ... -
使用Log4j进行日志操作
2008-10-16 11:36 1108使用Log4j进行日志操作1. 概述1.1. 背景在应用程序中 ... -
linux 下cpu 内存 磁盘 jvm的使用监控
2008-07-24 13:50 2913java 监控linux CPU 内存 磁盘 JVM: imp ... -
snmp4j获取数据agent实例(三)
2008-07-03 11:43 6686agent代理端例子: import java.util. ... -
snmp4j获取数据实例(二)之SnmpTrap示例
2008-07-03 10:27 6587snmp4j的jar包可以在它的官方网站http://www. ...
相关推荐
一个用SNMP4J编的读取OID值的源码 SNMP4J开发trap监听实例 snmp4j获取数据实例
1 windows下安装和配置snmp服务 2 用snmp4j获取本地所有oid 代码
基于java的Oid获取软件.rar Java进行SNMP通信的指南SnmpProgrammingGuideViaJava.doc Java实现snmp的get和walk代码示例.doc snmp4j.chm snmp.chm SnmpMain.java snmp配置说明.doc snmp协议详细讲解.doc ...
通过snmp的OID获取对方主机的内存利用率及CPU的使用率
快速获取SNMP设备oid的软件工具
通过snmp和oid获取电脑的内存硬盘的使用情况和总量
使用SNMP4J可以很方便的实现一个SNMP NMS的功能。 对于SNMPv1/SNMPv2,简单的说,只需要以下几个步骤 1) 创建Snmp对象snmp 2) 创建CommunityTarget对象target,并指定community, version, address, timeout, retry...
Java SNMP Package:这是一个实现了SNMP协议的Java包.它提供对基本的SNMP客户端与在SNMP...这个包提供了一种机制用于取得与设置SNMP对象标识(OID:object identifier)值通过一个简单的通信接口并可用于描述SNMP结构等.
4-FortiGate防火墙SNMP状态监控OID值说明-v1.1归类.pdf
Java来实现snmp的get、walk代码示例
F5 SNMP OID说明rv1 供大家学习! 本资料共包含以下附件: BIG-IPLTMSNMPV9[1].2.x.说明rv1.doc
snmp 获取服务器信息 snmp 获取服务器信息 snmp 获取服务器信息
做网管系统时候获取被监控设备的oid,例如内存,cpu利用率等等
windows上snmp自定义oid工具 配置参考: http://www.cnblogs.com/smallcoderhujin/p/3890233.html
基于本程序可以实现snmp oid为列表类型的获取使用人群 JAVA SNMP4J 应用使用场景:SNMP4J基本应用其他说明:无
通过使用SNMP协议获取某个交换机或服务器相关设备信息,如获取交换机设备,则可以通过设备OID获取相关信息,以及能获取交换机下所有连接的PC机的MAC地址与IP地址以及端口号信息。
snmp 常用oid列表
基于C#编写的通过OID获取SNMP 已正常使用 在大型项目中
Juniper常用SNMP(OID)使用手册_Ver2
列出了SNMP的MIB中常用的OID,根据这些OID可以很容易找到相关的被管对象。供初学SNMP协议的人使用,非常好!