Reputation: 577
Is there a way to test SNMP connection availability in java? I am using Ireasoning api.
try {
long timeTicks = System.currentTimeMillis();
while (timeTicks > 4294967295L) { timeTicks-= 4294967295L; }
SnmpTrap trap = new SnmpTrap(timeTicks, new SnmpOID(oid));
try {
InetAddress inet = InetAddress.getByName(agentIp);
agentIp = inet.getHostAddress();
} catch (Exception e2) {
System.out.println("SendSNMPTrap::sendVersion2c unable to resolve "+agentIp+" to real IP. Exception="+e2.toString());
}
trap.addVarBinds(vb.getVarbinds());
SnmpTrapSender.sendTrap(destHost, port, trap, true, community);
} catch (Exception e) {
logger.error("SendSNMPTrap::sendVersion2c Exception="+e.toString());
result = false;
}
Upvotes: 0
Views: 1230
Reputation: 6566
You can use INFORM PDU instead of TRAP PDU. This way the Trap Receiver will send you a response back to acknowledge that it has received the INFORM.
Upvotes: 0
Reputation: 311018
The best way to test the availability of any resources to try to use it. You have to deal with failure when you use it anyway. Why write the same code twice? And why try to predict the future?
Upvotes: 1