Package org.apache.camel.component.snmp
Class SnmpEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.support.ScheduledPollEndpoint
-
- org.apache.camel.support.DefaultPollingEndpoint
-
- org.apache.camel.component.snmp.SnmpEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="2.1.0", scheme="snmp", title="SNMP", syntax="snmp:host:port", category=MONITORING) public class SnmpEndpoint extends org.apache.camel.support.DefaultPollingEndpoint
Receive traps and poll SNMP (Simple Network Management Protocol) capable devices.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_COMMUNITY
static int
DEFAULT_SNMP_RETRIES
static int
DEFAULT_SNMP_TIMEOUT
static int
DEFAULT_SNMP_VERSION
-
Constructor Summary
Constructors Constructor Description SnmpEndpoint(String uri, SnmpComponent component)
creates a snmp endpoint
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.apache.camel.Consumer
createConsumer(org.apache.camel.Processor processor)
org.apache.camel.Exchange
createExchange(org.snmp4j.PDU pdu)
creates an exchange for the given messageorg.apache.camel.Producer
createProducer()
protected void
doInit()
String
getAddress()
String
getAuthenticationPassphrase()
String
getAuthenticationProtocol()
long
getDelay()
OIDList
getOids()
String
getPrivacyPassphrase()
String
getPrivacyProtocol()
String
getProtocol()
int
getRetries()
int
getSecurityLevel()
String
getSecurityName()
String
getSnmpCommunity()
String
getSnmpContextEngineId()
String
getSnmpContextName()
int
getSnmpVersion()
int
getTimeout()
SnmpActionType
getType()
void
initiate()
Deprecated.useBaseService.start()
insteadboolean
isTreeList()
void
setAddress(String address)
void
setAuthenticationPassphrase(String authenticationPassphrase)
The authentication passphrase.void
setAuthenticationProtocol(String authenticationProtocol)
Authentication protocol to use if security level is set to enable authentication The possible values are: MD5, SHA1void
setDelay(long updateEvery)
Sets update rate in secondsvoid
setOids(OIDList oids)
Defines which values you are interested in.void
setPrivacyPassphrase(String privacyPassphrase)
The privacy passphrase.void
setPrivacyProtocol(String privacyProtocol)
The privacy protocol ID to be associated with this user.void
setProtocol(String protocol)
Here you can select which protocol to use.void
setRetries(int retries)
Defines how often a retry is made before canceling the request.void
setSecurityLevel(int securityLevel)
Sets the security level for this target.void
setSecurityName(String securityName)
Sets the security name to be used with this target.void
setSnmpCommunity(String snmpCommunity)
Sets the community octet string for the snmp request.void
setSnmpContextEngineId(String snmpContextEngineId)
Sets the context engine ID field of the scoped PDU.void
setSnmpContextName(String snmpContextName)
Sets the context name field of this scoped PDU.void
setSnmpVersion(int snmpVersion)
Sets the snmp version for the request.void
setTimeout(int timeout)
Sets the timeout value for the request in millis.void
setTreeList(boolean treeList)
Sets the flag whether the scoped PDU will be displayed as the list if it has child elements in its treevoid
setType(SnmpActionType type)
Which operation to perform such as poll, trap, etc.String
toString()
-
Methods inherited from class org.apache.camel.support.ScheduledPollEndpoint
configureConsumer, configureProperties, configureScheduledPollConsumerProperties, doConfigureConsumer, doStart, doStop, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getDefaultDelay, getInitialDelay, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getTimeUnit, isGreedy, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setGreedy, setInitialDelay, setPollStrategy, setRepeatCount, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay
-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureExchange, configurePollingConsumer, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
DEFAULT_COMMUNITY
public static final String DEFAULT_COMMUNITY
- See Also:
- Constant Field Values
-
DEFAULT_SNMP_VERSION
public static final int DEFAULT_SNMP_VERSION
- See Also:
- Constant Field Values
-
DEFAULT_SNMP_RETRIES
public static final int DEFAULT_SNMP_RETRIES
- See Also:
- Constant Field Values
-
DEFAULT_SNMP_TIMEOUT
public static final int DEFAULT_SNMP_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SnmpEndpoint
public SnmpEndpoint(String uri, SnmpComponent component)
creates a snmp endpoint- Parameters:
uri
- the endpoint uricomponent
- the component
-
-
Method Detail
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
- Specified by:
createConsumer
in interfaceorg.apache.camel.Endpoint
- Overrides:
createConsumer
in classorg.apache.camel.support.DefaultPollingEndpoint
- Throws:
Exception
-
createExchange
public org.apache.camel.Exchange createExchange(org.snmp4j.PDU pdu)
creates an exchange for the given message- Parameters:
pdu
- the pdu- Returns:
- an exchange
-
initiate
@Deprecated public void initiate() throws Exception
Deprecated.useBaseService.start()
insteadcreates and configures the endpoint- Throws:
Exception
- if unable to setup connection
-
getDelay
public long getDelay()
- Overrides:
getDelay
in classorg.apache.camel.support.ScheduledPollEndpoint
-
setDelay
public void setDelay(long updateEvery)
Sets update rate in seconds- Overrides:
setDelay
in classorg.apache.camel.support.ScheduledPollEndpoint
- Parameters:
updateEvery
- the update rate in seconds
-
getType
public SnmpActionType getType()
-
setType
public void setType(SnmpActionType type)
Which operation to perform such as poll, trap, etc.
-
getOids
public OIDList getOids()
-
setOids
public void setOids(OIDList oids)
Defines which values you are interested in. Please have a look at the Wikipedia to get a better understanding. You may provide a single OID or a coma separated list of OIDs. Example: oids="1.3.6.1.2.1.1.3.0,1.3.6.1.2.1.25.3.2.1.5.1,1.3.6.1.2.1.25.3.5.1.1.1,1.3.6.1.2.1.43.5.1.1.11.1"
-
getAddress
public String getAddress()
-
setAddress
public void setAddress(String address)
-
getRetries
public int getRetries()
-
setRetries
public void setRetries(int retries)
Defines how often a retry is made before canceling the request.
-
getTimeout
public int getTimeout()
-
setTimeout
public void setTimeout(int timeout)
Sets the timeout value for the request in millis.
-
getSnmpVersion
public int getSnmpVersion()
-
setSnmpVersion
public void setSnmpVersion(int snmpVersion)
Sets the snmp version for the request. The value 0 means SNMPv1, 1 means SNMPv2c, and the value 3 means SNMPv3
-
getSnmpCommunity
public String getSnmpCommunity()
-
setSnmpCommunity
public void setSnmpCommunity(String snmpCommunity)
Sets the community octet string for the snmp request.
-
getProtocol
public String getProtocol()
-
setProtocol
public void setProtocol(String protocol)
Here you can select which protocol to use. You can use either udp or tcp.
-
doInit
protected void doInit() throws Exception
- Overrides:
doInit
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
getSecurityLevel
public int getSecurityLevel()
-
setSecurityLevel
public void setSecurityLevel(int securityLevel)
Sets the security level for this target. The supplied security level must be supported by the security model dependent information associated with the security name set for this target. The value 1 means: No authentication and no encryption. Anyone can create and read messages with this security level The value 2 means: Authentication and no encryption. Only the one with the right authentication key can create messages with this security level, but anyone can read the contents of the message. The value 3 means: Authentication and encryption. Only the one with the right authentication key can create messages with this security level, and only the one with the right encryption/decryption key can read the contents of the message.
-
getSecurityName
public String getSecurityName()
-
setSecurityName
public void setSecurityName(String securityName)
Sets the security name to be used with this target.
-
getAuthenticationProtocol
public String getAuthenticationProtocol()
-
setAuthenticationProtocol
public void setAuthenticationProtocol(String authenticationProtocol)
Authentication protocol to use if security level is set to enable authentication The possible values are: MD5, SHA1
-
getAuthenticationPassphrase
public String getAuthenticationPassphrase()
-
setAuthenticationPassphrase
public void setAuthenticationPassphrase(String authenticationPassphrase)
The authentication passphrase. If notnull
,authenticationProtocol
must also be notnull
. RFC3414 11.2 requires passphrases to have a minimum length of 8 bytes. If the length ofauthenticationPassphrase
is less than 8 bytes anIllegalArgumentException
is thrown.
-
getPrivacyProtocol
public String getPrivacyProtocol()
-
setPrivacyProtocol
public void setPrivacyProtocol(String privacyProtocol)
The privacy protocol ID to be associated with this user. If set tonull
, this user only supports unencrypted messages.
-
getPrivacyPassphrase
public String getPrivacyPassphrase()
-
setPrivacyPassphrase
public void setPrivacyPassphrase(String privacyPassphrase)
The privacy passphrase. If notnull
,privacyProtocol
must also be notnull
. RFC3414 11.2 requires passphrases to have a minimum length of 8 bytes. If the length ofauthenticationPassphrase
is less than 8 bytes anIllegalArgumentException
is thrown.
-
getSnmpContextName
public String getSnmpContextName()
-
setSnmpContextName
public void setSnmpContextName(String snmpContextName)
Sets the context name field of this scoped PDU.
-
getSnmpContextEngineId
public String getSnmpContextEngineId()
-
setSnmpContextEngineId
public void setSnmpContextEngineId(String snmpContextEngineId)
Sets the context engine ID field of the scoped PDU.
-
isTreeList
public boolean isTreeList()
-
setTreeList
public void setTreeList(boolean treeList)
Sets the flag whether the scoped PDU will be displayed as the list if it has child elements in its tree
-
toString
public String toString()
- Overrides:
toString
in classorg.apache.camel.support.DefaultEndpoint
-
-