mib文件中对应的bean
import java.io.Serializable;
import org.opengoss.snmphibernate.api.SmiType;
import org.opengoss.snmphibernate.api.annotation.MibIndex;
import org.opengoss.snmphibernate.api.annotation.MibObjectType;
import org.opengoss.snmphibernate.api.annotation.MibObjectType.Access;
import org.opengoss.snmphibernate.api.annotation.MibTable;
@MibTable
public class Ccm3Entry implements Serializable {
@MibIndex(no = 0, length = 1)
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.1", smiType = SmiType.INTEGER32, access = Access.READ)
public int ccm3id;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.2", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3ServerName;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.3", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3ServerState;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.4", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3ServerIp;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.5", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3OnlineClient;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.6", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3TimeTotalValue;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.7", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3TotalValue;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.8", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3TimeMaxValue;
@MibObjectType(oid = "1.3.6.1.4.1.6001.1.1.4.1.9", smiType = SmiType.DISPLAY_STRING, access = Access.READ)
public String ccm3MaxValue;
public int getCcm3id() {
return ccm3id;
}
public void setCcm3id(int ccm3id) {
this.ccm3id = ccm3id;
}
public String getCcm3ServerName() {
return ccm3ServerName;
}
public void setCcm3ServerName(String ccm3ServerName) {
this.ccm3ServerName = ccm3ServerName;
}
public String getCcm3ServerState() {
return ccm3ServerState;
}
public void setCcm3ServerState(String ccm3ServerState) {
this.ccm3ServerState = ccm3ServerState;
}
public String getCcm3ServerIp() {
return ccm3ServerIp;
}
public void setCcm3ServerIp(String ccm3ServerIp) {
this.ccm3ServerIp = ccm3ServerIp;
}
public String getCcm3OnlineClient() {
return ccm3OnlineClient;
}
public void setCcm3OnlineClient(String ccm3OnlineClient) {
this.ccm3OnlineClient = ccm3OnlineClient;
}
public String getCcm3TimeTotalValue() {
return ccm3TimeTotalValue;
}
public void setCcm3TimeTotalValue(String ccm3TimeTotalValue) {
this.ccm3TimeTotalValue = ccm3TimeTotalValue;
}
public String getCcm3TotalValue() {
return ccm3TotalValue;
}
public void setCcm3TotalValue(String ccm3TotalValue) {
this.ccm3TotalValue = ccm3TotalValue;
}
public String getCcm3TimeMaxValue() {
return ccm3TimeMaxValue;
}
public void setCcm3TimeMaxValue(String ccm3TimeMaxValue) {
this.ccm3TimeMaxValue = ccm3TimeMaxValue;
}
public String getCcm3MaxValue() {
return ccm3MaxValue;
}
public void setCcm3MaxValue(String ccm3MaxValue) {
this.ccm3MaxValue = ccm3MaxValue;
}
}
测试类
import java.util.List;
import org.opengoss.snmphibernate.api.ISnmpClientFacade;
import org.opengoss.snmphibernate.api.ISnmpSession;
import org.opengoss.snmphibernate.api.ISnmpSessionFactory;
import org.opengoss.snmphibernate.api.ISnmpTargetFactory;
import org.opengoss.snmphibernate.impl.snmp4j.Snmp4JClientFacade;
public class TestSnmpHibernate {
public static void main(String []args){
try{
ISnmpClientFacade facade = new Snmp4JClientFacade();
ISnmpSessionFactory sessionFactory = facade.getSnmpSessionFactory();
ISnmpTargetFactory targetFactory = facade.getSnmpTargetFactory();
ISnmpSession session = sessionFactory.newSnmpSession(targetFactory
.newSnmpTarget("192.168.92.22", 11610));
/*System sysMIB = session.get(System.class);
java.lang.System.out.println("sysDesc: " + sysMIB.getSysDesc());
session.set(sysMIB);//更改agent上的值
sysMIB = (System) session.get(System.class,
new String[] { "sysObjectID" });//取得agent中的某一项
java.lang.System.out.println("sysObjectID: " + sysMIB.getSysObjectID());*/
//取得整个table
List list = session.getTable(Ccm3Entry.class);
for (Object o : list) {//循环输出表格内容
java.lang.System.out.println("id: "
+ ((Ccm3Entry) o).getCcm3id());
}
//取得表格中的第n行
Ccm3Entry one=session.getByIndex(Ccm3Entry.class, 1);
System.out.println("one.id= "+one.getCcm3id());
//取得表格中的第n行中的第n列
Ccm3Entry two=session.getByIndex(Ccm3Entry.class, 2,new String[]{"ccm3id"});
System.out.println("two.id= "+two.getCcm3id());
session.close();
}catch(Exception e){
e.printStackTrace();
}
}
}