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.LoggerLOGThe Constant LOG.static StringMAPPINGS_DIRECTORY_NAMEThe Constant MAPPINGS_DIRECTORY_NAME.
-
Constructor Summary
Constructors Constructor Description SnmpTrapSink()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccepts(NorthboundAlarm alarm)Verifies if the sink accepts a given northbound alarm.voidaddImportMapping(SnmpTrapMappingGroup mappingGroup)Adds the import mapping.voidaddMappingGroup(SnmpTrapMappingGroup mappingGroup)Adds the mapping group.voidcleanMappingGroups()Clean mapping groups.SnmpTrapConfigcreateTrapConfig(NorthboundAlarm alarm)Creates the SNMP trap configuration object.StringgetCommunity()Gets the community.SnmpTrapMappingGroupgetImportMapping(String mappingName)Gets the import mapping.List<String>getImportMappings()Gets the import mappings.StringgetIpAddress()Gets the IP address.FilegetMappingGroupFile(String mappingFileName)Gets the mapping group file.StringgetMappingGroupFileName(String mappingName)Gets the mapping group file name.List<SnmpTrapMappingGroup>getMappings()Gets the mappings.StringgetName()Gets the destination name.IntegergetPort()Gets the port.StringgetV1AgentIpAddress()Gets the v1 agent IP address.SnmpVersiongetVersion()Gets the version.booleanisFirstOccurrenceOnly()Checks if is first occurrence only.booleanremoveImportMapping(String mappingName)Removes the import mapping.voidsetCommunity(String community)Sets the community.voidsetImportMappings(List<String> importMappings)Sets the import mappings.voidsetIpAddress(String ipAddress)Sets the IP address.voidsetMappings(List<SnmpTrapMappingGroup> mappings)Sets the mappings.voidsetName(String name)Sets the name.voidsetPort(int port)Sets the port.voidsetV1AgentIpAddress(String v1AgentIpAddress)Sets the v1 agent IP address.voidsetVersion(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:DestinationChecks if is first occurrence only.- Specified by:
isFirstOccurrenceOnlyin interfaceDestination- Returns:
- true, if is first occurrence only
-
getName
public String getName()
Description copied from interface:DestinationGets the destination name.- Specified by:
getNamein 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.
-
-