public class SNMPDispatcher extends Object implements NotificationDispatcher
SNMPDispatcher class is used to dispatch Notification via SNMP.| Modifier and Type | Class and Description |
|---|---|
protected static class |
SNMPDispatcher.InvalidSnmpConfigurationException
Exception thrown when Notification configuration doesn't contain required properties.
|
protected static class |
SNMPDispatcher.SnmpVersion
Supported versions of SNMP
|
protected static class |
SNMPDispatcher.TrapSecurity
Possible SNMP security levels
|
| Modifier and Type | Field and Description |
|---|---|
static String |
BODY_OID_PROPERTY |
static String |
COMMUNITY_PROPERTY |
static String |
PORT_PROPERTY |
static String |
SECURITY_AUTH_PASSPHRASE_PROPERTY |
static String |
SECURITY_LEVEL_PROPERTY |
static String |
SECURITY_PRIV_PASSPHRASE_PROPERTY |
static String |
SECURITY_USERNAME_PROPERTY |
static String |
SNMP_VERSION_PROPERTY |
static String |
SUBJECT_OID_PROPERTY |
static String |
TRAP_OID_PROPERTY |
| Constructor and Description |
|---|
SNMPDispatcher() |
SNMPDispatcher(Integer port)
Creates SNMP server with specified port.
|
SNMPDispatcher(org.snmp4j.Snmp snmp) |
| Modifier and Type | Method and Description |
|---|---|
protected org.snmp4j.Target |
createTrapTarget(Notification notification,
SNMPDispatcher.SnmpVersion snmpVersion)
Creates snmp target with security model corresponding to snmp version.
|
void |
dispatch(Notification notification)
Dispatches the specified notification.
|
protected static String |
getDispatchProperty(Map<String,String> dispatchProperties,
String key)
Get dispatch property with specific key from dispatch properties.
|
Integer |
getPort() |
protected SNMPDispatcher.TrapSecurity |
getSecurityLevel(Map<String,String> dispatchProperties)
Returns
SNMPDispatcher.TrapSecurity instance corresponding to dispatch property ambari.dispatch.snmp.security.level from dispatch properties. |
protected Set<String> |
getSetOfDefaultNeededPropertyNames() |
protected SNMPDispatcher.SnmpVersion |
getSnmpVersion(Map<String,String> dispatchProperties)
Returns
SNMPDispatcher.SnmpVersion instance corresponding to dispatch property ambari.dispatch.snmp.version from dispatch properties. |
protected org.snmp4j.transport.UdpTransportMapping |
getTransportMapping() |
String |
getType()
Gets the type of dispatcher.
|
boolean |
isDigestSupported()
Gets whether the dispatcher supports sending a digest or summary in a
single
Notification. |
boolean |
isNotificationContentGenerationRequired()
Gets whether Ambari should attempt to generate the content of the
Notification before giving it to the dispatcher. |
protected org.snmp4j.PDU |
prepareTrap(Notification notification,
SNMPDispatcher.SnmpVersion snmpVersion)
Creates protocol data unit (PDU) with corresponding SNMP version for alert notification.
|
protected void |
sendTraps(Notification notification,
SNMPDispatcher.SnmpVersion snmpVersion)
Creates trap based on alerts notification and sends it to hosts specified in recipients list.
|
TargetConfigurationResult |
validateTargetConfig(Map<String,Object> properties)
Validates alert target configuration.
|
public static final String BODY_OID_PROPERTY
public static final String SUBJECT_OID_PROPERTY
public static final String TRAP_OID_PROPERTY
public static final String PORT_PROPERTY
public static final String SNMP_VERSION_PROPERTY
public static final String COMMUNITY_PROPERTY
public static final String SECURITY_USERNAME_PROPERTY
public static final String SECURITY_AUTH_PASSPHRASE_PROPERTY
public static final String SECURITY_PRIV_PASSPHRASE_PROPERTY
public static final String SECURITY_LEVEL_PROPERTY
public SNMPDispatcher(org.snmp4j.Snmp snmp)
public SNMPDispatcher()
throws IOException
IOExceptionpublic SNMPDispatcher(Integer port) throws IOException
port - portIOExceptionpublic String getType()
getType in interface NotificationDispatchernull).public boolean isNotificationContentGenerationRequired()
Notification before giving it to the dispatcher. Some dispatchers
may choose to format data in a way which is not easily represented in the
{alert-templates.xml}.
If false then the Notification will only contain the
recipients and a map of properties for the dispatcher to use.isNotificationContentGenerationRequired in interface NotificationDispatchertrue if Ambari should generate the Notification
content, false otherwise.public void dispatch(Notification notification)
dispatch in interface NotificationDispatchernotification - the notificationt to dispatch (not null).public TargetConfigurationResult validateTargetConfig(Map<String,Object> properties)
validateTargetConfig in interface NotificationDispatcherproperties - alert target propertiesprotected Set<String> getSetOfDefaultNeededPropertyNames()
protected org.snmp4j.PDU prepareTrap(Notification notification, SNMPDispatcher.SnmpVersion snmpVersion) throws SNMPDispatcher.InvalidSnmpConfigurationException
notification - alert notification to dispatchsnmpVersion - SNMP versionSNMPDispatcher.InvalidSnmpConfigurationException - if notification's dispatch properties don't contain any of required properties.protected void sendTraps(Notification notification, SNMPDispatcher.SnmpVersion snmpVersion) throws SNMPDispatcher.InvalidSnmpConfigurationException, IOException
notification - alert notification to dispatchsnmpVersion - SNMP versionSNMPDispatcher.InvalidSnmpConfigurationException - if notification's dispatch properties don't contain any of required properties or recipient list is empty.IOException - if the SNMP trap could not be sentprotected org.snmp4j.Target createTrapTarget(Notification notification, SNMPDispatcher.SnmpVersion snmpVersion) throws SNMPDispatcher.InvalidSnmpConfigurationException
notification - alerts notificationsnmpVersion - SNMP versionSNMPDispatcher.InvalidSnmpConfigurationException - if notification's dispatch properties don't contain any of required propertiespublic boolean isDigestSupported()
Notification. Some providers may not allow the
Notification to contain information on more than a single event.isDigestSupported in interface NotificationDispatchertrue if digest is supported, false otherwise.protected static String getDispatchProperty(Map<String,String> dispatchProperties, String key) throws SNMPDispatcher.InvalidSnmpConfigurationException
dispatchProperties - dispatch propertieskey - property keySNMPDispatcher.InvalidSnmpConfigurationException - if property with such key does not existprotected SNMPDispatcher.SnmpVersion getSnmpVersion(Map<String,String> dispatchProperties) throws SNMPDispatcher.InvalidSnmpConfigurationException
SNMPDispatcher.SnmpVersion instance corresponding to dispatch property ambari.dispatch.snmp.version from dispatch properties.dispatchProperties - dispatch propertiesSNMPDispatcher.InvalidSnmpConfigurationException - if dispatch properties doesn't contain required propertyprotected SNMPDispatcher.TrapSecurity getSecurityLevel(Map<String,String> dispatchProperties) throws SNMPDispatcher.InvalidSnmpConfigurationException
SNMPDispatcher.TrapSecurity instance corresponding to dispatch property ambari.dispatch.snmp.security.level from dispatch properties.dispatchProperties - dispatch propertiesSNMPDispatcher.InvalidSnmpConfigurationException - if dispatch properties doesn't contain required propertypublic Integer getPort()
protected org.snmp4j.transport.UdpTransportMapping getTransportMapping()
Copyright © 2022 Apache Software Foundation. All rights reserved.