use of org.opennms.protocols.snmp.SnmpObjectId in project opennms by OpenNMS.
the class JoeSnmpStrategy method getNext.
@Override
public SnmpValue[] getNext(SnmpAgentConfig snmpAgentConfig, SnmpObjId[] oids) {
JoeSnmpAgentConfig agentConfig = new JoeSnmpAgentConfig(snmpAgentConfig);
SnmpSession session = null;
SnmpValue[] values = { null };
try {
SnmpPeer peer = createPeer(agentConfig);
SnmpParameters params = new SnmpParameters();
setParameters(agentConfig, params);
peer.setParameters(params);
configurePeer(peer, agentConfig);
session = new SnmpSession(peer);
SnmpObjectId[] jOids = convertOids(oids);
SnmpSyntax[] results = session.getNext(jOids);
values = convertSnmpSyntaxs(results);
} catch (SocketException e) {
LOG.error("Could not create JoeSNMP session using AgentConfig: {}", agentConfig);
} finally {
if (session != null) {
session.close();
}
}
return values;
}
use of org.opennms.protocols.snmp.SnmpObjectId in project opennms by OpenNMS.
the class JoeSnmpStrategy method get.
@Override
public SnmpValue[] get(SnmpAgentConfig snmpAgentConfig, SnmpObjId[] oids) {
JoeSnmpAgentConfig agentConfig = new JoeSnmpAgentConfig(snmpAgentConfig);
SnmpSession session = null;
SnmpValue[] values = { null };
try {
SnmpPeer peer = createPeer(agentConfig);
SnmpParameters params = new SnmpParameters();
setParameters(agentConfig, params);
peer.setParameters(params);
configurePeer(peer, agentConfig);
session = new SnmpSession(peer);
SnmpObjectId[] jOids = convertOids(oids);
SnmpSyntax[] results = session.get(jOids);
values = convertSnmpSyntaxs(results);
} catch (SocketException e) {
LOG.error("Could not create JoeSNMP session using AgentConfig: {}", agentConfig);
} finally {
if (session != null) {
session.close();
}
}
return values;
}
use of org.opennms.protocols.snmp.SnmpObjectId in project opennms by OpenNMS.
the class JoeSnmpV1TrapBuilder method addVarBind.
@Override
public void addVarBind(SnmpObjId name, SnmpValue value) {
SnmpSyntax val = ((JoeSnmpValue) value).getSnmpSyntax();
trap.addVarBind(new SnmpVarBind(new SnmpObjectId(name.getIds()), val));
}
use of org.opennms.protocols.snmp.SnmpObjectId in project opennms by OpenNMS.
the class JoeSnmpV2TrapBuilder method addVarBind.
@Override
public void addVarBind(SnmpObjId name, SnmpValue value) {
SnmpSyntax val = ((JoeSnmpValue) value).getSnmpSyntax();
m_pdu.addVarBind(new SnmpVarBind(new SnmpObjectId(name.getIds()), val));
}
use of org.opennms.protocols.snmp.SnmpObjectId in project opennms by OpenNMS.
the class JoeSnmpStrategy method set.
@Override
public SnmpValue[] set(SnmpAgentConfig snmpAgentConfig, SnmpObjId[] oids, SnmpValue[] values) {
JoeSnmpAgentConfig agentConfig = new JoeSnmpAgentConfig(snmpAgentConfig);
SnmpSession session = null;
SnmpSyntax[] syntaxvalues = new SnmpSyntax[values.length];
for (int i = 0; i < values.length; i++) {
syntaxvalues[i] = new JoeSnmpValue(values[i].getType(), values[i].getBytes()).getSnmpSyntax();
}
values = null;
try {
SnmpPeer peer = createPeer(agentConfig);
SnmpParameters params = new SnmpParameters();
setParameters(agentConfig, params);
peer.setParameters(params);
configurePeer(peer, agentConfig);
session = new SnmpSession(peer);
SnmpObjectId[] jOids = convertOids(oids);
SnmpSyntax[] results = session.set(jOids, syntaxvalues);
values = convertSnmpSyntaxs(results);
} catch (SocketException e) {
LOG.error("Could not create JoeSNMP session using AgentConfig: {}", agentConfig);
} finally {
if (session != null) {
session.close();
}
}
return values;
}
Aggregations