/** {@inheritDoc} */ public SnmpAgentConfig getAgentConfig(final InetAddress agentAddress) { return getAgentConfig(agentAddress, null, VERSION_UNSPECIFIED); }
public SnmpAgentConfig getAgentConfig(final InetAddress agentAddress, String location) { return getAgentConfig(agentAddress, location, VERSION_UNSPECIFIED); }
public SnmpAgentConfig getAgentConfig(final InetAddress agentInetAddress, final int requestedSnmpVersion) { return getAgentConfig(agentInetAddress, null, requestedSnmpVersion); }
@Override public SnmpAgentConfig call() throws Exception { return SnmpPeerFactory.getInstance().getAgentConfig(addr, location); } });
@Override public Map<String, Object> getRuntimeAttributes(MonitoredService svc, Map<String, Object> parameters) { try { SnmpPeerFactory.init(); } catch (IOException e) { LOG.error("SnmpPeerFactory initialization failed.", e); } return ImmutableMap.of("agent", SnmpPeerFactory.getInstance().getAgentConfig(svc.getAddress(), svc.getNodeLocation())); }
/** * Returns true if the protocol defined by this plugin is supported. If the * protocol is not supported then a false value is returned to the caller. * * @param address * The address to check for support. * @return True if the protocol is supported by the address. */ public boolean isProtocolSupported(InetAddress address) { try { SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(address); return getValue(agentConfig, DEFAULT_OID, isHex()) != null; } catch (Throwable t) { throw new UndeclaredThrowableException(t); } }
/** * <p>getAgentConfig</p> * * @return a {@link org.opennms.netmgt.snmp.SnmpAgentConfig} object. */ @Override public SnmpAgentConfig getAgentConfig() { return SnmpPeerFactory.getInstance().getAgentConfig(getInetAddress(), getLocationName()); }
@Override public SnmpAgentConfig getAgentConfig() { return SnmpPeerFactory.getInstance().getAgentConfig(getAddress(), getLocationName()); }
public SnmpAgentConfig getSnmpAgentConfig() { return SnmpPeerFactory.getInstance().getAgentConfig(m_node.getSnmpPrimaryIpAddr(), m_node.getLocation()); }
@Override public SnmpAgentConfig getAgentConfig(final InetAddress address, String location) { final SnmpAgentConfigProxyMapper mapper = SnmpAgentConfigProxyMapper.getInstance(); final SnmpAgentAddress agentAddress = mapper.getAddress(address); final String addressString = str(address); if (agentAddress == null) { LOG.debug( "No agent address mapping found for {}! Try adding a @JUnitSnmpAgent(host=\"{}\", resource=\"...\" entry...", addressString, addressString); return super.getAgentConfig(address, location); } final SnmpAgentConfig config = new SnmpAgentConfig(agentAddress.getAddress()); config.setProxyFor(address); config.setPort(agentAddress.getPort()); LOG.debug("proxying {} -> {}", addressString, agentAddress); return config; }
@Override public SnmpAgentConfig getAgentConfig(final InetAddress address, String location) { final SnmpAgentConfigProxyMapper mapper = SnmpAgentConfigProxyMapper.getInstance(); final SnmpAgentAddress agentAddress = mapper.getAddress(address); final String addressString = str(address); if (agentAddress == null) { LOG.debug( "No agent address mapping found for {}! Try adding a @JUnitSnmpAgent(host=\"{}\", resource=\"...\" entry...", addressString, addressString); return super.getAgentConfig(address, location); } final SnmpAgentConfig config = new SnmpAgentConfig(agentAddress.getAddress()); config.setProxyFor(address); config.setPort(agentAddress.getPort()); LOG.debug("proxying {} -> {}", addressString, agentAddress); return config; }
/** * Verifies that the SNMP agent configuration is retrieved using * the location name that is associated with the interface/node. */ @Test public void canGetLocationAwareAgentConfig() { // Mock the peer factory SnmpPeerFactory snmpPeerFactory = mock(SnmpPeerFactory.class); SnmpPeerFactory.setInstance(snmpPeerFactory); // Mock the other arguments required to create a DefaultCollectionAgent Integer ifaceId = 1; IpInterfaceDao ifaceDao = mock(IpInterfaceDao.class); PlatformTransactionManager transMgr = mock(PlatformTransactionManager.class); OnmsIpInterface ipIface = mock(OnmsIpInterface.class, RETURNS_DEEP_STUBS); when(ifaceDao.load(ifaceId)).thenReturn(ipIface); when(ipIface.getNode().getLocation().getLocationName()).thenReturn("Ocracoke"); // Retrieve the agent configuration SnmpCollectionAgent agent = DefaultSnmpCollectionAgent.create(ifaceId, ifaceDao, transMgr); agent.getAgentConfig(); // Verify verify(snmpPeerFactory, times(1)).getAgentConfig(any(), eq("Ocracoke")); }
private SnmpAgentConfig getAgentConfig(InetAddress ipaddr) { // Retrieve this interface's SNMP peer object SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(ipaddr); if (agentConfig == null) { throw new IllegalStateException("SnmpAgentConfig object not available for interface " + ipaddr); } agentConfig.hashCode(); // Set timeout and retries on SNMP peer object agentConfig.setTimeout(ParameterMap.getKeyedInteger(m_parameters, "timeout", agentConfig.getTimeout())); agentConfig.setRetries(ParameterMap.getKeyedInteger(m_parameters, "retry", ParameterMap.getKeyedInteger(m_parameters, "retries", agentConfig.getRetries()))); agentConfig.setPort(ParameterMap.getKeyedInteger(m_parameters, "port", agentConfig.getPort())); return agentConfig; }
/** * Gets the SNMP agent configuration. * * @return the SNMP agent configuration */ public SnmpAgentConfig getAgentConfig() { SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(destinationAddress, version.intValue()); if (destinationPort > 0) { config.setPort(destinationPort); } if ((version.isV1() || version.isV2()) && community != null) { config.setReadCommunity(community); } return config; }
SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(ipaddr); if (agentConfig == null) { throw new IllegalStateException("SnmpAgentConfig object not available for interface " + ipaddr);
@Test public void testSnmpInterfacePoll() throws UnknownHostException { SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance() .getAgentConfig(InetAddressUtils.getInetAddress("192.168.2.2")); // Invoke poll directly interfacesResult = snmpInterfaceMonitor.poll(agentConfig, interfacesResult); // Check if Poll Status is UP assertEquals(1, interfacesResult.get(0).getStatus().getStatusCode()); // Check if Admin/Operational Status are retrieved properly assertEquals(1, interfacesResult.get(0).getAdminstatus()); assertEquals(2, interfacesResult.get(0).getOperstatus()); }
final SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(m_address, MonitoringLocationUtils.getLocationNameOrNullIfDefault(node)); try { m_locationAwareSnmpClient.walk(agentConfig, tracker)
InetAddress ipAddr = null; ipAddr = InetAddressUtils.addr(getIpaddress()); SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(ipAddr); if (hasPort) agentConfig.setPort(port); if (hasTimeout) agentConfig.setTimeout(timeout);
m_agentConfig = m_snmpPeerFactory.getAgentConfig(InetAddressUtils.addr(TEST_HOST_ADDRESS));
m_agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.getLocalHostAddress());