use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testCdpCacheTableCollection.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpCacheTableCollection() throws Exception {
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
class CdpCacheTableTrackerTester extends CdpCacheTableTracker {
int count = 0;
public int count() {
return count;
}
}
final CdpCacheTableTrackerTester cdpCacheTableTracker = new CdpCacheTableTrackerTester() {
public void processCdpCacheRow(final CdpCacheRow row) {
count++;
}
};
String trackerName = "cdpCacheTable";
try {
m_client.walk(config, cdpCacheTableTracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: Cdp Linkd collection interrupted, exiting", e);
return;
}
assertEquals(14, cdpCacheTableTracker.count());
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class ConfigureSnmpTest method testSnmpEventInfoClassWithSpecific.
/**
* Tests getting the correct SNMP Peer after a configureSNMP event and merge to the running config.
* @throws UnknownHostException
*/
public void testSnmpEventInfoClassWithSpecific() throws UnknownHostException {
final String addr = "192.168.0.5";
EventBuilder bldr = createConfigureSnmpEventBuilder(addr, null);
addCommunityStringToEvent(bldr, "abc");
SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());
SnmpPeerFactory.getInstance().define(info);
SnmpAgentConfig agent = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr));
assertEquals(InetAddressUtils.str(agent.getAddress()), addr);
assertEquals("abc", agent.getReadCommunity());
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class SnmpConfigRestService method getSnmpInfo.
/**
* <p>getSnmpInfo</p>
*
* @param ipAddr a {@link java.lang.String} object.
* @return a {@link org.opennms.web.snmpinfo.SnmpInfo} object.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Path("{ipAddr}")
public SnmpInfo getSnmpInfo(@PathParam("ipAddr") String ipAddr, @QueryParam("location") String location) {
final InetAddress addr = InetAddressUtils.addr(ipAddr);
if (addr == null) {
throw getException(Status.BAD_REQUEST, "Malformed IP Address: {}.", ipAddr);
}
final SnmpAgentConfig config = m_accessService.getAgentConfig(addr, location);
return new SnmpInfo(config);
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class SnmpPeerFactoryTest method testDefaultMaxRequestSize.
public void testDefaultMaxRequestSize() throws UnknownHostException {
SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.0.0.1"));
assertEquals(SnmpAgentConfig.DEFAULT_MAX_REQUEST_SIZE, agentConfig.getMaxRequestSize());
agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.0.0.2"));
assertEquals(484, agentConfig.getMaxRequestSize());
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class SnmpPeerFactoryTest method testConfigureDefaultMaxVarsPerPdu.
public void testConfigureDefaultMaxVarsPerPdu() throws UnknownHostException {
SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.0.0.150"));
assertEquals(55, agentConfig.getMaxVarsPerPdu());
}
Aggregations