[snmp++]读取MIB信息最简单的例子
2012-02-11 16:05
585 查看
snmp++自带例子
上面的192.168.15.175是一台xp,只需在这台机的控制面版-添加删除windows组件-管理和监视工具-把里面的两个都装上,就可以通过snmp协议所带的数据解读出来
比如oid
Name: sysUpTime系统开机时间
Oid: 1.3.6.1.2.1.1.3
Name: sysName系统名称
Oid: 1.3.6.1.2.1.1.5
Description: An administratively-assigned name for this managed node. By con
vention , this is the node's fully-qualified domain name.
Snmp Class 的阻塞方式成员函数: Get
阻塞方式的成员函数 get允许从指定 target 的代理端获取对象。调用者必须指定目标 target
以及要请求的 Pdu。
//--------[ get ]-------------------------------------------
int Snmp::get( Pdu &pdu, // Pdu to get
SnmpTarget &target); // specified targe
pdu 与 vb
#include "stdafx.h" #include <snmp_pp.h> #include <iostream.h> //#define SYSDESCR "1.3.6.1.2.1.1.5.0" // Object ID for System Descriptor void main() { Snmp::socket_startup(); int status; // return status CTarget ctarget( (IpAddress) "192.168.15.175");// SNMP++ v1 target Vb vb("1.3.6.1.2.1.1.1.0");// SNMP++ Variable Binding Pdu pdu; // SNMP++ PDU //-------[ Construct a SNMP++ SNMP Object ]--------------------------------------- Snmp snmp( status); // Create a SNMP++ session if ( status != SNMP_CLASS_SUCCESS) { // check creation status cout << snmp.error_msg( status); // if fail, print error string return; } //-------[ Invoke a SNMP++ Get ]------------------------------------------------------- pdu += vb; // add the variable binding if ( (status = snmp.get( pdu, ctarget)) != SNMP_CLASS_SUCCESS) cout << snmp.error_msg( status); else { pdu.get_vb( vb,0); // extract the variable binding cout << "System Descriptor = "<< vb.get_printable_value(); } // print out Snmp::socket_cleanup(); cout<<"\n"; };
上面的192.168.15.175是一台xp,只需在这台机的控制面版-添加删除windows组件-管理和监视工具-把里面的两个都装上,就可以通过snmp协议所带的数据解读出来
比如oid
Name: sysUpTime系统开机时间
Oid: 1.3.6.1.2.1.1.3
Name: sysName系统名称
Oid: 1.3.6.1.2.1.1.5
Description: An administratively-assigned name for this managed node. By con
vention , this is the node's fully-qualified domain name.
Snmp Class 的阻塞方式成员函数: Get
阻塞方式的成员函数 get允许从指定 target 的代理端获取对象。调用者必须指定目标 target
以及要请求的 Pdu。
//--------[ get ]-------------------------------------------
int Snmp::get( Pdu &pdu, // Pdu to get
SnmpTarget &target); // specified targe
pdu 与 vb
相关文章推荐
- 读取AD信息的例子
- php读取XML简单例子
- ADO读取Excel的简单例子
- opencv中读取矩阵信息的简单方法
- 简单测试运行时类信息(RTTI),附详细例子
- 一个综合泛型编程,文件读取和异常处理的简单例子
- 读取AD信息的例子
- select根据省份从xml文件里面读取城市信息的例子(兼容ff与ie)
- 关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 读取文件
- 最简单的基于FFmpeg的AVDevice例子(读取摄像头)
- comet4j 主动向客户端推送信息 简单例子
- Learn Beautiful Soup(4)—— 一个简单抓取图书信息的例子
- snmp 里面oid对应的信息 MIB
- 用Ajax读取RSS种子的简单例子
- android发送xml信息到web服务器简单例子
- java读取文件数据进行一些简单处理的例子
- ColdFusion如何从数据库读取信息例子
- asp.net简单读取xml文件信息
- 最简单的基于FFmpeg的AVDevice例子(读取摄像头)
- 使用Java读取Word文件的简单例子分享