dcsimg
change value
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   hiep_nguyen
Posted On:   Tuesday, January 14, 2003 07:34 PM

i try jdmk to monitor device, using SNMP, i can get value of MIB that i want, now i want to set value for the MIB var, but it always fail, because of time out, i increasd the time but it don't work. this is my code try{ SnmpOid oid = new SnmpOid("1.3.6.1.4.1.24.8.1.0"); //SnmpOid oid = new SnmpOid("1.3.6.1.4.1.8949.1.1.0"); String s = "CMD=1&servicename=hiep&proto=6&port1=8080&port2=8085&ref=2&comment=hiep"; println("cacac "+ s + " acac"); //SnmpString value = new SnmpString(info.toString()); SnmpString value = new SnmpString(s); SnmpVarBind varBind = new SnmpVarBind(oid,value); SnmpVarBindList varBindList    More>>

i try jdmk to monitor device, using SNMP, i can get value of MIB that i want, now i want to set value for the MIB var, but it always fail, because of time out, i increasd the time but it don't work. this is my code



try{
SnmpOid oid = new SnmpOid("1.3.6.1.4.1.24.8.1.0");
//SnmpOid oid = new SnmpOid("1.3.6.1.4.1.8949.1.1.0");
String s = "CMD=1&servicename=hiep&proto=6&port1=8080&port2=8085&ref=2&comment=hiep";
println("cacac "+ s + " acac");
//SnmpString value = new SnmpString(info.toString());
SnmpString value = new SnmpString(s);
SnmpVarBind varBind = new SnmpVarBind(oid,value);
SnmpVarBindList varBindList = new SnmpVarBindList();
varBindList.addVarBind(varBind);
snmpManager.setVarBind(null,varBindList);
println("Service:btOkClick: Ok !");
}catch(Exception e){
println("Service:btOkClick: Error !");
}
============================================================
public SnmpVarBindList setVarBind(SnmpRequestHandler cb, SnmpVarBindList vblst) throws SnmpStatusException{
println("SyncManager:SetVarBind: begin set");
final SnmpRequest request = session.snmpSetRequest(cb,vblst);

final boolean completed = request.waitForCompletion(5000);
if (completed == false) {
println("SyncManager: SetRequest timed out.");
java.lang.System.exit(0);
}

println("SyncManager:SetVarBind: waiting...");
int errorStatus = 0;
errorStatus = request.getErrorStatus();
if (errorStatus != SnmpDefinitions.snmpRspNoError) {
java.lang.System.out.println("Error status = " +
SnmpRequest.snmpErrorToString(errorStatus));
java.lang.System.out.println("Error index = " +
request.getErrorIndex());
java.lang.System.exit(0);
}

final SnmpVarBindList result = request.getResponseVarBindList();

println("~~~~~~~~SyncManager:SetVarBind: " + result);

Enumeration enum = result.getVarBindList();
while(enum.hasMoreElements()){
Object obj = enum.nextElement();
println("@@@@@@@@ SyncManager:Result: " + obj);
}

return result;
}



and i don't know where i can set username and password?

can you help me?
thank you for your help!

   <<Less
About | Sitemap | Contact