Class SnmpTrapSink
- java.lang.Object
-
- org.opennms.netmgt.alarmd.northbounder.snmptrap.SnmpTrapSink
-
- All Implemented Interfaces:
Serializable
,Destination
public class SnmpTrapSink extends 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 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.String
getCommunity()
Gets the community.SnmpTrapMappingGroup
getImportMapping(String mappingName)
Gets the import mapping.List<String>
getImportMappings()
Gets the import mappings.String
getIpAddress()
Gets the IP address.File
getMappingGroupFile(String mappingFileName)
Gets the mapping group file.String
getMappingGroupFileName(String mappingName)
Gets the mapping group file name.List<SnmpTrapMappingGroup>
getMappings()
Gets the mappings.String
getName()
Gets the destination name.Integer
getPort()
Gets the port.String
getV1AgentIpAddress()
Gets the v1 agent IP address.SnmpVersion
getVersion()
Gets the version.boolean
isFirstOccurrenceOnly()
Checks if is first occurrence only.boolean
removeImportMapping(String mappingName)
Removes the import mapping.void
setCommunity(String community)
Sets the community.void
setImportMappings(List<String> importMappings)
Sets the import mappings.void
setIpAddress(String ipAddress)
Sets the IP address.void
setMappings(List<SnmpTrapMappingGroup> mappings)
Sets the mappings.void
setName(String name)
Sets the name.void
setPort(int port)
Sets the port.void
setV1AgentIpAddress(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 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 String getName()
Description copied from interface:Destination
Gets the destination name.- Specified by:
getName
in interfaceDestination
- Returns:
- the destination name
-
getIpAddress
public String getIpAddress()
Gets the IP address.- Returns:
- the IP address
-
getPort
public Integer getPort()
Gets the port.- Returns:
- the port
-
getV1AgentIpAddress
public 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 String getCommunity()
Gets the community.- Returns:
- the community
-
getMappings
public List<SnmpTrapMappingGroup> getMappings()
Gets the mappings.- Returns:
- the mappings
-
getImportMappings
public List<String> getImportMappings()
Gets the import mappings.- Returns:
- the import mappings
-
setName
public void setName(String name)
Sets the name.- Parameters:
name
- the new name
-
setIpAddress
public void setIpAddress(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(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(String community)
Sets the community.- Parameters:
community
- the new community
-
setMappings
public void setMappings(List<SnmpTrapMappingGroup> mappings)
Sets the mappings.- Parameters:
mappings
- the new mappings
-
setImportMappings
public void setImportMappings(List<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 String getMappingGroupFileName(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 File getMappingGroupFile(String mappingFileName)
Gets the mapping group file.- Parameters:
mappingFileName
- the mapping file name- Returns:
- the mapping group file
-
getImportMapping
public SnmpTrapMappingGroup getImportMapping(String mappingName) throws Exception
Gets the import mapping.- Parameters:
mappingName
- the mapping name- Returns:
- the import mapping
- Throws:
Exception
- the exception
-
addImportMapping
public void addImportMapping(SnmpTrapMappingGroup mappingGroup) throws Exception
Adds the import mapping.- Parameters:
mappingGroup
- the mapping groupfileName
- the file name- Throws:
Exception
-
removeImportMapping
public boolean removeImportMapping(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.
-
-