Class SnmpTrapSink
- java.lang.Object
-
- org.opennms.netmgt.alarmd.northbounder.snmptrap.SnmpTrapSink
-
- All Implemented Interfaces:
java.io.Serializable
,Destination
public class SnmpTrapSink extends java.lang.Object implements Destination
Configuration for the various SNMP Trap hosts to receive alarms via Traps.- Author:
- Alejandro Galue
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
LOG
The Constant LOG.static java.lang.String
MAPPINGS_DIRECTORY_NAME
The Constant MAPPINGS_DIRECTORY_NAME.
-
Constructor Summary
Constructors Constructor Description SnmpTrapSink()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(NorthboundAlarm alarm)
Verifies if the sink accepts a given northbound alarm.void
addImportMapping(SnmpTrapMappingGroup mappingGroup)
Adds the import mapping.void
addMappingGroup(SnmpTrapMappingGroup mappingGroup)
Adds the mapping group.void
cleanMappingGroups()
Clean mapping groups.SnmpTrapConfig
createTrapConfig(NorthboundAlarm alarm)
Creates the SNMP trap configuration object.java.lang.String
getCommunity()
Gets the community.SnmpTrapMappingGroup
getImportMapping(java.lang.String mappingName)
Gets the import mapping.java.util.List<java.lang.String>
getImportMappings()
Gets the import mappings.java.lang.String
getIpAddress()
Gets the IP address.java.io.File
getMappingGroupFile(java.lang.String mappingFileName)
Gets the mapping group file.java.lang.String
getMappingGroupFileName(java.lang.String mappingName)
Gets the mapping group file name.java.util.List<SnmpTrapMappingGroup>
getMappings()
Gets the mappings.java.lang.String
getName()
Gets the destination name.java.lang.Integer
getPort()
Gets the port.java.lang.String
getV1AgentIpAddress()
Gets the v1 agent IP address.SnmpVersion
getVersion()
Gets the version.boolean
isFirstOccurrenceOnly()
Checks if is first occurrence only.boolean
removeImportMapping(java.lang.String mappingName)
Removes the import mapping.void
setCommunity(java.lang.String community)
Sets the community.void
setImportMappings(java.util.List<java.lang.String> importMappings)
Sets the import mappings.void
setIpAddress(java.lang.String ipAddress)
Sets the IP address.void
setMappings(java.util.List<SnmpTrapMappingGroup> mappings)
Sets the mappings.void
setName(java.lang.String name)
Sets the name.void
setPort(int port)
Sets the port.void
setV1AgentIpAddress(java.lang.String v1AgentIpAddress)
Sets the v1 agent IP address.void
setVersion(SnmpVersion version)
Sets the version.
-
-
-
Field Detail
-
LOG
public static final org.slf4j.Logger LOG
The Constant LOG.
-
MAPPINGS_DIRECTORY_NAME
public static final java.lang.String MAPPINGS_DIRECTORY_NAME
The Constant MAPPINGS_DIRECTORY_NAME.- See Also:
- Constant Field Values
-
-
Method Detail
-
isFirstOccurrenceOnly
public boolean isFirstOccurrenceOnly()
Description copied from interface:Destination
Checks if is first occurrence only.- Specified by:
isFirstOccurrenceOnly
in interfaceDestination
- Returns:
- true, if is first occurrence only
-
getName
public java.lang.String getName()
Description copied from interface:Destination
Gets the destination name.- Specified by:
getName
in interfaceDestination
- Returns:
- the destination name
-
getIpAddress
public java.lang.String getIpAddress()
Gets the IP address.- Returns:
- the IP address
-
getPort
public java.lang.Integer getPort()
Gets the port.- Returns:
- the port
-
getV1AgentIpAddress
public java.lang.String getV1AgentIpAddress()
Gets the v1 agent IP address.- Returns:
- the v1 agent IP address
-
getVersion
public SnmpVersion getVersion()
Gets the version.- Returns:
- the version
-
getCommunity
public java.lang.String getCommunity()
Gets the community.- Returns:
- the community
-
getMappings
public java.util.List<SnmpTrapMappingGroup> getMappings()
Gets the mappings.- Returns:
- the mappings
-
getImportMappings
public java.util.List<java.lang.String> getImportMappings()
Gets the import mappings.- Returns:
- the import mappings
-
setName
public void setName(java.lang.String name)
Sets the name.- Parameters:
name
- the new name
-
setIpAddress
public void setIpAddress(java.lang.String ipAddress)
Sets the IP address.- Parameters:
ipAddress
- the new IP address
-
setPort
public void setPort(int port)
Sets the port.- Parameters:
port
- the new port
-
setV1AgentIpAddress
public void setV1AgentIpAddress(java.lang.String v1AgentIpAddress)
Sets the v1 agent IP address.- Parameters:
v1AgentIpAddress
- the new v1 agent IP address
-
setVersion
public void setVersion(SnmpVersion version)
Sets the version.- Parameters:
version
- the new version
-
setCommunity
public void setCommunity(java.lang.String community)
Sets the community.- Parameters:
community
- the new community
-
setMappings
public void setMappings(java.util.List<SnmpTrapMappingGroup> mappings)
Sets the mappings.- Parameters:
mappings
- the new mappings
-
setImportMappings
public void setImportMappings(java.util.List<java.lang.String> importMappings)
Sets the import mappings.- Parameters:
importMappings
- the new import mappings
-
addMappingGroup
public void addMappingGroup(SnmpTrapMappingGroup mappingGroup)
Adds the mapping group.If there is a mapping group with the same name, the existing one will be overridden.
- Parameters:
mappingGroup
- the mapping group
-
getMappingGroupFileName
public java.lang.String getMappingGroupFileName(java.lang.String mappingName)
Gets the mapping group file name.- Parameters:
mappingName
- the mapping name- Returns:
- the full path for the mapping group file name
-
getMappingGroupFile
public java.io.File getMappingGroupFile(java.lang.String mappingFileName)
Gets the mapping group file.- Parameters:
mappingFileName
- the mapping file name- Returns:
- the mapping group file
-
getImportMapping
public SnmpTrapMappingGroup getImportMapping(java.lang.String mappingName) throws java.lang.Exception
Gets the import mapping.- Parameters:
mappingName
- the mapping name- Returns:
- the import mapping
- Throws:
java.lang.Exception
- the exception
-
addImportMapping
public void addImportMapping(SnmpTrapMappingGroup mappingGroup) throws java.lang.Exception
Adds the import mapping.- Parameters:
mappingGroup
- the mapping groupfileName
- the file name- Throws:
java.lang.Exception
-
removeImportMapping
public boolean removeImportMapping(java.lang.String mappingName)
Removes the import mapping.- Parameters:
mappingName
- the mapping name- Returns:
- true, if successful
-
accepts
public boolean accepts(NorthboundAlarm alarm)
Verifies if the sink accepts a given northbound alarm.- Parameters:
alarm
- the northbound alarm- Returns:
- true, if the alarm is accepted
-
createTrapConfig
public SnmpTrapConfig createTrapConfig(NorthboundAlarm alarm) throws SnmpTrapException
Creates the SNMP trap configuration object.- Parameters:
alarm
- the northbound alarm- Returns:
- the SNMP trap configuration
- Throws:
SnmpTrapException
- the SNMP trap exception
-
cleanMappingGroups
public void cleanMappingGroups()
Clean mapping groups.This is intended to be used when saving the configuration on a file.
All the groups that currently exist on the mappings list and also on the import-mappings list will be removed from the mapping list to avoid duplicates.
-
-