public int getPort() { return m_config.getPort(); }
public int getPort() { return m_config.getPort(); }
public int getPort() { return m_config.getPort(); }
public int getPort() { return m_config.getPort(); }
public int getPort() { return m_config.getPort(); }
public int getPort() { return m_config.getPort(); }
@Override public SnmpWalker createWalker(final SnmpAgentConfig agentConfig, final String name, final CollectionTracker tracker) { LOG.debug("createWalker({}/{}, {}, {})", InetAddrUtils.str(agentConfig.getAddress()), agentConfig.getPort(), name, tracker.getClass().getName()); final SnmpAgentAddress aa = new SnmpAgentAddress(agentConfig.getAddress(), agentConfig.getPort()); final PropertyOidContainer oidContainer = getOidContainer(aa); return new MockSnmpWalker(aa, agentConfig.getVersion(), oidContainer, name, tracker, agentConfig.getMaxVarsPerPdu(), agentConfig.getRetries()); }
protected PropertyOidContainer getOidContainer(final SnmpAgentConfig agentConfig) { return getOidContainer(new SnmpAgentAddress(agentConfig.getAddress(), agentConfig.getPort())); }
public Map<String, String> toMap() { Map<String, String> map = new LinkedHashMap<>(); map.put("address", m_address == null ? null : InetAddrUtils.str(m_address)); map.put("proxyFor", m_proxyFor == null ? null : InetAddrUtils.str(m_proxyFor)); map.put("port", Integer.toString(getPort())); map.put("timeout", Integer.toString(getTimeout())); map.put("retries", Integer.toString(getRetries())); map.put("max-vars-per-pdu", Integer.toString(getMaxVarsPerPdu())); map.put("max-repetitions", Integer.toString(getMaxRepetitions())); map.put("max-request-size", Integer.toString(getMaxRequestSize())); map.put("version", Integer.toString(getVersion())); map.put("security-level", Integer.toString(getSecurityLevel())); map.put("security-name", getSecurityName()); map.put("auth-passphrase", getAuthPassPhrase()); map.put("auth-protocol", getAuthProtocol()); map.put("priv-passphrase", getPrivPassPhrase()); map.put("priv-protocol", getPrivProtocol()); map.put("context-name", getContextName()); map.put("engine-id", getEngineId()); map.put("context-engine-id", getContextEngineId()); map.put("enterprise-id", getEnterpriseId()); map.put("read-community", getReadCommunity()); map.put("write-community", getWriteCommunity()); return map; }
buff.append("Address: " + InetAddrUtils.str(m_address)); buff.append(", ProxyForAddress: " + InetAddrUtils.str(m_proxyFor)); buff.append(", Port: " + getPort()); buff.append(", Timeout: " + getTimeout()); buff.append(", Retries: " + getRetries());
public String toString() { StringBuffer buff = new StringBuffer("AgentConfig["); buff.append("Address: "+getAddress()); buff.append(", ProxyForAddress: "+getProxyFor()); buff.append(", Port: "+getPort()); buff.append(", Community: "+getReadCommunity()); buff.append(", Timeout: "+getTimeout()); buff.append(", Retries: "+getRetries()); buff.append(", MaxVarsPerPdu: "+getMaxVarsPerPdu()); buff.append(", MaxRepetitions: "+getMaxRepetitions()); buff.append(", Max request size: "+getMaxRequestSize()); buff.append(", Version: "+versionToString(getVersion())); if (getVersion() == VERSION3) { buff.append(", Security level: "+getSecurityLevel()); buff.append(", Security name: "+getSecurityName()); buff.append(", auth-passphrase: "+getAuthPassPhrase()); buff.append(", auth-protocol: "+getAuthProtocol()); buff.append(", priv-passprhase: "+getPrivPassPhrase()); buff.append(", priv-protocol: "+getPrivProtocol()); } buff.append("]"); return buff.toString(); }
/** * Create an SNMP V2 trap based on the content of the specified trap configuration, and send it to the appropriate destination. * * @param trapConfig The trap configuration mapping object * @throws SnmpTrapException if any. */ private void forwardV2Trap(SnmpTrapConfig trapConfig) throws SnmpTrapException { SnmpTrapBuilder trap = SnmpUtils.getV2TrapBuilder(); populateTrapBuilder(trap, trapConfig); try { SnmpAgentConfig config = getAgentConfig(trapConfig); trap.send(config.getAddress().getHostAddress(), config.getPort(), config.getReadCommunity()); } catch (Throwable e) { throw new SnmpTrapException("Failed to send trap "+e.getMessage(), e); } }
/** * Create an SNMP V2 inform based on the content of the specified trap configuration, and send it to the appropriate destination. * * @param trapConfig The trap configuration mapping object * @throws SnmpTrapException if any. */ private void forwardV2Inform(SnmpTrapConfig trapConfig) throws SnmpTrapException { SnmpV2TrapBuilder trap = SnmpUtils.getV2InformBuilder(); populateTrapBuilder(trap, trapConfig); try { SnmpAgentConfig config = getAgentConfig(trapConfig); trap.sendInform(config.getAddress().getHostName(), config.getPort(), config.getTimeout(), config.getRetries(), config.getReadCommunity()); } catch (Throwable e) { throw new SnmpTrapException("Failed to send trap "+e.getMessage(), e); } }
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; }
/** * Create an SNMP V3 trap based on the content of the specified trap configuration, and send it to the appropriate destination. * * @param trapConfig The trap configuration mapping object * @throws SnmpTrapException if any. */ private void forwardV3Trap(SnmpTrapConfig trapConfig) throws SnmpTrapException { SnmpV3TrapBuilder trap = SnmpUtils.getV3TrapBuilder(); populateTrapBuilder(trap, trapConfig); try { SnmpAgentConfig config = getAgentConfig(trapConfig); trap.send(config.getAddress().getHostAddress(), config.getPort(), config.getSecurityLevel(), config.getSecurityName(), config.getAuthPassPhrase(), config.getAuthProtocol(), config.getPrivPassPhrase(), config.getPrivProtocol()); } catch (Throwable e) { throw new SnmpTrapException("Failed to send trap "+e.getMessage(), e); } }
private SnmpAgentConfig configureAgent(MonitoredService svc, Map<String, Object> parameters) { // Retrieve this interface's SNMP peer object // final SnmpAgentConfig agentConfig = getAgentConfig(svc, parameters); LOG.debug("poll: setting SNMP peer attribute for interface {}", InetAddressUtils.str(svc.getAddress())); agentConfig.setTimeout(ParameterMap.getKeyedInteger(parameters, "timeout", agentConfig.getTimeout())); agentConfig.setRetries(ParameterMap.getKeyedInteger(parameters, "retry", ParameterMap.getKeyedInteger(parameters, "retries", agentConfig.getRetries()))); agentConfig.setPort(ParameterMap.getKeyedInteger(parameters, "port", agentConfig.getPort())); return agentConfig; }
/** * Create an SNMP V3 inform based on the content of the specified trap configuration, and send it to the appropriate destination. * * @param trapConfig The trap configuration mapping object * @throws SnmpTrapException if any. */ private void forwardV3Inform(SnmpTrapConfig trapConfig) throws SnmpTrapException { SnmpV3TrapBuilder trap = SnmpUtils.getV3InformBuilder(); populateTrapBuilder(trap, trapConfig); try { SnmpAgentConfig config = getAgentConfig(trapConfig); trap.sendInform(config.getAddress().getHostAddress(), config.getPort(), config.getTimeout(), config.getTimeout(), config.getSecurityLevel(), config.getSecurityName(), config.getAuthPassPhrase(), config.getAuthProtocol(), config.getPrivPassPhrase(), config.getPrivProtocol()); } catch (Throwable e) { throw new SnmpTrapException("Failed to send trap "+e.getMessage(), e); } }
/** * Create an SNMP V1 trap based on the content of the specified trap configuration, and send it to the appropriate destination. * * @param trapConfig The trap configuration mapping object * @throws SnmpTrapException if any. */ private void forwardV1Trap(SnmpTrapConfig trapConfig) throws SnmpTrapException { SnmpV1TrapBuilder trap = SnmpUtils.getV1TrapBuilder(); trap.setEnterprise(SnmpObjId.get(trapConfig.getEnterpriseId())); trap.setAgentAddress(trapConfig.getHostAddress()); if (trapConfig.hasGeneric()) { trap.setGeneric(trapConfig.getGeneric()); } if (trapConfig.hasSpecific()) { trap.setSpecific(trapConfig.getSpecific()); } trap.setTimeStamp(System.currentTimeMillis() / 1000); addParameters(trap, trapConfig); try { SnmpAgentConfig config = getAgentConfig(trapConfig); trap.send(config.getAddress().getHostAddress(), config.getPort(), config.getReadCommunity()); } catch (Throwable e) { throw new SnmpTrapException("Failed to send trap "+e.getMessage(), e); } }
@Override public int hashCode() { int hash = Objects.hash(getAddress(), getProxyFor(), getPort(), getTimeout(), getRetries(), getMaxVarsPerPdu(), getMaxRepetitions(), getMaxRequestSize(), getVersion(), getSecurityLevel(), getSecurityName(), getAuthPassPhrase(), getAuthProtocol(), getPrivPassPhrase(), getPrivProtocol(), getContextName(), getEngineId(), getContextEngineId(), getEnterpriseId(), getReadCommunity(), getWriteCommunity()); return hash; }
/** * <p>getAgentConfig</p> * * @return a {@link org.opennms.netmgt.snmp.SnmpAgentConfig} object. */ public SnmpAgentConfig getAgentConfig() { SnmpAgentConfig agentConfig = getCollectionAgent().getAgentConfig(); agentConfig.setPort(m_snmpCollection.getSnmpPort(agentConfig.getPort())); agentConfig.setRetries(m_snmpCollection.getSnmpRetries(agentConfig.getRetries())); agentConfig.setTimeout(m_snmpCollection.getSnmpTimeout(agentConfig.getTimeout())); agentConfig.setReadCommunity(m_snmpCollection.getSnmpReadCommunity(agentConfig.getReadCommunity())); agentConfig.setWriteCommunity(m_snmpCollection.getSnmpWriteCommunity(agentConfig.getWriteCommunity())); agentConfig.setProxyFor(m_snmpCollection.getSnmpProxyFor(agentConfig.getProxyFor())); agentConfig.setVersion(m_snmpCollection.getSnmpVersion(agentConfig.getVersion())); agentConfig.setMaxVarsPerPdu(m_snmpCollection.getSnmpMaxVarsPerPdu(agentConfig.getMaxVarsPerPdu())); agentConfig.setMaxRepetitions(m_snmpCollection.getSnmpMaxRepetitions(agentConfig.getMaxRepetitions())); agentConfig.setMaxRequestSize(m_snmpCollection.getSnmpMaxRequestSize(agentConfig.getMaxRequestSize())); agentConfig.setSecurityName(m_snmpCollection.getSnmpSecurityName(agentConfig.getSecurityName())); agentConfig.setAuthPassPhrase(m_snmpCollection.getSnmpAuthPassPhrase(agentConfig.getAuthPassPhrase())); agentConfig.setAuthProtocol(m_snmpCollection.getSnmpAuthProtocol(agentConfig.getAuthProtocol())); agentConfig.setPrivPassPhrase(m_snmpCollection.getSnmpPrivPassPhrase(agentConfig.getPrivPassPhrase())); agentConfig.setPrivProtocol(m_snmpCollection.getSnmpPrivProtocol(agentConfig.getPrivProtocol())); return agentConfig; }