use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class ShowConfigCommand method doExecute.
@Override
protected Object doExecute() throws Exception {
final InetAddress agentAdress = InetAddress.getByName(m_host);
final SnmpAgentConfig agent = snmpAgentConfigFactory.getAgentConfig(agentAdress, m_location);
System.out.println("Address: " + InetAddrUtils.str(agent.getAddress()));
System.out.println("ProxyForAddress: " + InetAddrUtils.str(agent.getProxyFor()));
System.out.println("Port: " + agent.getPort());
System.out.println("Timeout: " + agent.getTimeout());
System.out.println("Retries: " + agent.getTimeout());
System.out.println("MaxVarsPerPdu: " + agent.getMaxVarsPerPdu());
System.out.println("MaxRepetitions: " + agent.getMaxRepetitions());
System.out.println("MaxRequestSize: " + agent.getMaxRequestSize());
System.out.println("Version: " + agent.getVersionAsString());
// the credentials in this context
if (agent.isVersion3()) {
System.out.println("SecurityLevel: " + agent.getSecurityLevel());
System.out.println("SecurityName: " + agent.getSecurityName());
System.out.println("AuthPassPhrase: " + agent.getAuthPassPhrase());
System.out.println("AuthProtocol: " + agent.getAuthProtocol());
System.out.println("PrivPassphrase: " + agent.getPrivPassPhrase());
System.out.println("PrivProtocol: " + agent.getPrivProtocol());
System.out.println("ContextName: " + agent.getContextName());
System.out.println("EngineId: " + agent.getEngineId());
System.out.println("ContextEngineId: " + agent.getContextEngineId());
System.out.println("EnterpriseId: " + agent.getEnterpriseId());
} else {
System.out.println("ReadCommunity: " + agent.getReadCommunity());
System.out.println("WriteCommunity: " + agent.getWriteCommunity());
}
System.out.println();
return null;
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class Snmp4JV2TrapBuilder method send.
@Override
public void send(String destAddr, int destPort, String community) throws Exception {
SnmpAgentConfig snmpAgentConfig = m_strategy.buildAgentConfig(destAddr, destPort, community, m_pdu);
Snmp4JAgentConfig agentConfig = new Snmp4JAgentConfig(snmpAgentConfig);
m_strategy.send(agentConfig, m_pdu, false);
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class MockSnmpStrategyTest method testSetMultipleBadAgent.
@Test
public void testSetMultipleBadAgent() throws Exception {
final SnmpAgentConfig sac = getAgentConfig();
sac.setAddress(InetAddressUtils.addr("1.2.3.4"));
final SnmpObjId[] oids = new SnmpObjId[] { SnmpObjId.get(".1.3.5.1.1.3.0"), SnmpObjId.get(".1.3.5.1.1.4.0") };
final SnmpValue[] values = new SnmpValue[] { m_strategy.getValueFactory().getInt32(4), m_strategy.getValueFactory().getGauge32(5) };
m_strategy.set(sac, oids, values);
final SnmpValue[] results = m_strategy.get(sac, oids);
assertNotNull(results);
assertEquals(2, results.length);
assertNull(results[0]);
assertNull(results[1]);
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class MockSnmpStrategyTest method testSetBadAgent.
@Test
public void testSetBadAgent() throws Exception {
final SnmpAgentConfig sac = getAgentConfig();
sac.setAddress(InetAddressUtils.addr("1.2.3.4"));
m_strategy.set(sac, SnmpObjId.get(".1.3.5.1.1.3.0"), m_strategy.getValueFactory().getInt32(4));
final SnmpValue result = m_strategy.get(sac, SnmpObjId.get(".1.3.5.1.1.3.0"));
assertNull(result);
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class MockSnmpStrategyTest method testTrackerTimeout.
@Test
public void testTrackerTimeout() throws Exception {
final CountingColumnTracker ct = new CountingColumnTracker(SnmpObjId.get(".1.3.5.1.1"));
final SnmpAgentConfig sac = getAgentConfig();
sac.setPort(12345);
try (final SnmpWalker walker = SnmpUtils.createWalker(sac, "test", ct)) {
assertNotNull(walker);
walker.start();
walker.waitFor();
}
assertEquals("it should match no columns (timeout)", Long.valueOf(0).longValue(), ct.getCount());
}
Aggregations