import java.io.FileNotFoundException;
import java.io.IOException;import com.adventnet.snmp.beans.*;
import com.adventnet.snmp.mibs.MibException;
public class mibtest{
public static void main(String args[]) {
SnmpTarget target=new SnmpTarget();
try {
target.loadMibs("RFC1213-MIB");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MibException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}               //加载MIB库
target.setTargetHost("localhost");              
target.setSnmpVersion(1);                        
target.setTargetPort(161);                       
target.setCommunity("public");                   
target.setObjectID(".1.3.6.1.2.1.1.1");         
String result=target.snmpGet();
System.out.println("Response:"+result);
}
}错误提示如下:Response:null
java.io.FileNotFoundException: Could not find the file : RFC1213-MIB
at com.adventnet.snmp.mibs.MibOperations.loadModules(MibOperations.java:5015)
at com.adventnet.snmp.mibs.MibOperations.loadMibModule(MibOperations.java:4619)
at com.adventnet.snmp.mibs.MibOperations.loadMibModules(MibOperations.java:4821)
at com.adventnet.snmp.beans.SnmpTarget.loadMibs(SnmpTarget.java:217)
at mymibtest.mibtest.main(mibtest.java:14)

解决方案 »

  1.   

    public static void main(String args[]){ SnmpTable target = new SnmpTable(); 
    target.setTargetHost("localhost"); 
    target.setSnmpVersion(3); 
    target.setPrincipal("laurent"); 
    target.setAuthPassword("setuppassword"); 
    target.setAuthProtocol(target.MD5_AUTH); 
    target.create_v3_tables(); try { 
    target.setMibPath("/home/laurent/ssxg/src/test/snmpTest/mibs"); //你是不是没写这个设定路径?
    target.loadMibs("SNMP-VIEW-BASED-ACM-MIB"); 
    //target.loadMibs("SNMP-USER-BASED-SM-MIB"); pour l'usmUserTable 
    target.setTableOID("vacmSecurityToGroupTable"); 
    }catch(Exception e){ 
    System.out.println(e.getMessage()); 
    } String oid[] = new String[3]; 
    String value[] = new String[3]; oid[0] = new String("vacmGroupName.4"); 
    oid[1] = new String("vacmSecurityToGroupStorageType.4"); 
    oid[2] = newString("vacmSecurityToGroupStatus.4"); 
    //the result is the same with other value (even none) than 4 
    value[0] = new String("MyTestingGroup"); 
    value[1] = new String("4");//permanent 
    value[2] = new String("4");//create & go 
    //value "1" already tested try{ 
    target.addRow(false,oid,value); 
    }catch(Exception e){ 
    System.out.println(e.getMessage()); 

    System.exit(1); 

      

  2.   

    是的,怎么搞,怎么读取本地mib库,mib库要编译吗?