Package org.opennms.netmgt.eventd
Class AbstractEventUtil
- java.lang.Object
-
- org.opennms.netmgt.eventd.AbstractEventUtil
-
- All Implemented Interfaces:
EventUtil
- Direct Known Subclasses:
EventUtilDaoImpl
public abstract class AbstractEventUtil extends Object implements EventUtil
EventUtil is used primarily for the event parm expansion - has methods used by all the event components to send in the event and the element to expanded and have the 'expanded' value sent back- Author:
- Sowmya Kumaraswamy , Brain Weaver , OpenNMS
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ASSET_BEGIN
The string that starts the expansion for an asset field - used to lookup values of asset fields by their namesprotected static String
ASSET_END_SUFFIX
The string that ends the expansion of a parmprotected static char
ATTRIB_DELIM
The values and the corresponding attributes of an element are added delimited by ATTRIB_DELIMprotected static String
HARDWARE_BEGIN
The string that starts the expansion for a hardware field - used to lookup values of hardware attributes by their index|nameprotected static String
HARDWARE_END_SUFFIX
The string that ends the expansion of a hardwareprotected static char
NAME_VAL_DELIM
For expansion of the '%parms[all]%' - the parm name and value are added as delimiter separated list of '= ' strings protected static String
NUM_PARMS_STR
The string that should be expanded to the number of parmsprotected static String
PARM_BEGIN
The string that starts the expansion for a parm - used to lookup values of parameters by their namesprotected static int
PARM_BEGIN_LENGTH
The length of PARM_BEGINprotected static String
PARM_END_SUFFIX
The string that ends the expansion of a parmprotected static String
PARM_NAME_NUMBERED_PREFIX
The string that starts a request for the name of a numbered parmprotected static int
PARM_NAME_NUMBERED_PREFIX_LENGTH
The length of PARM_NAME_NUMBERED_PREFIXprotected static String
PARM_NUM_PREFIX
The string that starts a parm number - used to lookup values of parameters by their positionprotected static int
PARM_NUM_PREFIX_LENGTH
The length of PARM_NUM_PREFIXprotected static Pattern
PARM_REGEX
Pattern used to match and parse 'parm' tokens.protected static String
PARMS_ALL
The string that should be expanded to a list of all parmsprotected static String
PARMS_NAMES
The string that should be expanded to a list of all parm namesprotected static String
PARMS_VALUES
The string that should be expanded to a list of all parm valuesprotected static char
SPACE_DELIM
protected static String
TAG_DESCR
The event descr xml tagprotected static String
TAG_DPNAME
The event dpname xml tagprotected static String
TAG_EVENT_DB_ID
The Event ID xmlprotected static String
TAG_FOREIGNID
The foreignid for the event's nodeid xml tagprotected static String
TAG_FOREIGNSOURCE
The foreignsource for the event's nodeid xml tagprotected static String
TAG_HOST
The event host xml tagprotected static String
TAG_IFALIAS
The reverse DNS lookup of the interfaceprotected static String
TAG_IFINDEX
The event ifindex xml tagprotected static String
TAG_INTERFACE
The event interface xml tagprotected static String
TAG_INTERFACE_RESOLVE
The reverse DNS lookup of the interfaceprotected static String
TAG_LOGMSG
The event logmsg xml tagprotected static String
TAG_MOUSEOVERTEXT
The event mouseovertext xml tagprotected static String
TAG_NODEID
The event nodeid xml tagprotected static String
TAG_NODELABEL
The event nodelabel xml tagprotected static String
TAG_NODELOCATION
The event nodelocation xml tagprotected static String
TAG_OPERINSTR
The event operinstruct xml tagprotected static String
TAG_PERCENT_SIGN
Substitute the actual percent signprotected static String
TAG_PRIMARY_INTERFACE_ADDRESS
The primary interfaceprotected static String
TAG_SERVICE
The event service xml tagprotected static String
TAG_SEVERITY
The event severity xml tagprotected static String
TAG_SHORT_TIME
The event time xml tag, short formatprotected static String
TAG_SNMP
The SNMP xml tagprotected static String
TAG_SNMP_COMMUNITY
The event snmp community xml tagprotected static String
TAG_SNMP_GENERIC
The event snmp generic xml tagprotected static String
TAG_SNMP_ID
The event snmp id xml tagprotected static String
TAG_SNMP_IDTEXT
The event snmp idtext xml tagprotected static String
TAG_SNMP_SPECIFIC
The event snmp specific xml tagprotected static String
TAG_SNMP_TRAP_OID
The event snmp trapoid xml tagprotected static String
TAG_SNMP_VERSION
The event snmp version xml tagprotected static String
TAG_SNMPHOST
The event snmp host xml tagprotected static String
TAG_SOURCE
The event source xml tagprotected static String
TAG_TIME
The event time xml tagprotected static String
TAG_TTICKET_ID
protected static String
TAG_UEI
The UEI xml tag
-
Constructor Summary
Constructors Constructor Description AbstractEventUtil()
AbstractEventUtil(com.codahale.metrics.MetricRegistry registry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Date
decodeSnmpV2TcDateAndTime(BigInteger octetStringValue)
static String
escape(String inStr, char delimchar)
This method is used to escape required values from strings that may contain those values.void
expandMapValues(Map<String,String> map, Event event)
expandMapValuesString
expandParms(String inp, Event event)
Expand the value if it has parms in one of the following formats - %element% values are expanded to have the value of the element where 'element' is an element in the event DTD - %parm[values-all]% is expanded to a delimited list of all parmblock values - %parm[names-all]% is expanded to a list of all parm names - %parm[all]% is expanded to a full dump of all parmblocks - %parm[name]% is expanded to the value of the parameter named 'name' - %parm[]% is replaced by the value of the parameter named 'name', if present - %parm[# ]% is replaced by the value of the parameter number 'num', if present - %parm[##]% is replaced by the number of parameters String
expandParms(String input, Event event, Map<String,Map<String,String>> decode)
Expand the value if it has parms in one of the following formats - %element% values are expanded to have the value of the element where 'element' is an element in the event DTD - %parm[values-all]% is expanded to a delimited list of all parmblock values - %parm[names-all]% is expanded to a list of all parm names - %parm[all]% is expanded to a full dump of all parmblocks - %parm[name]% is expanded to the value of the parameter named 'name' - %parm[]% is replaced by the value of the parameter named 'name', if present - %parm[# ]% is replaced by the value of the parameter number 'num', if present - %parm[##]% is replaced by the number of parameters protected static String
getAllParamValues(Event event)
Helper method.protected static String
getAllParmNames(Event event)
Helper method.protected static String
getAllParmValues(Event event)
Helper method.String
getEventHost(Event event)
getEventHoststatic EventUtil
getInstance()
String
getNamedParmValue(String parm, Event event)
Helper method.protected static String
getNumParmName(String parm, Event event)
Helper method.protected static String
getNumParmValue(String parm, Event event)
Helper method.ExpandableParameterResolver
getResolver(String token)
static void
setInstance(EventUtil instance)
Used only for unit testing.static String
splitAndExtract(String src, String sep, int offset, boolean doRange, int rangeLen)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opennms.netmgt.eventd.EventUtil
getAssetFieldValue, getForeignId, getForeignSource, getHardwareFieldValue, getHostName, getIfAlias, getNodeLabel, getNodeLocation, getPrimaryInterface
-
-
-
-
Field Detail
-
TAG_EVENT_DB_ID
protected static final String TAG_EVENT_DB_ID
The Event ID xml- See Also:
- Constant Field Values
-
TAG_UEI
protected static final String TAG_UEI
The UEI xml tag- See Also:
- Constant Field Values
-
TAG_SOURCE
protected static final String TAG_SOURCE
The event source xml tag- See Also:
- Constant Field Values
-
TAG_DESCR
protected static final String TAG_DESCR
The event descr xml tag- See Also:
- Constant Field Values
-
TAG_LOGMSG
protected static final String TAG_LOGMSG
The event logmsg xml tag- See Also:
- Constant Field Values
-
TAG_TIME
protected static final String TAG_TIME
The event time xml tag- See Also:
- Constant Field Values
-
TAG_SHORT_TIME
protected static final String TAG_SHORT_TIME
The event time xml tag, short format- See Also:
- Constant Field Values
-
TAG_DPNAME
protected static final String TAG_DPNAME
The event dpname xml tag- See Also:
- Constant Field Values
-
TAG_NODEID
protected static final String TAG_NODEID
The event nodeid xml tag- See Also:
- Constant Field Values
-
TAG_NODELABEL
protected static final String TAG_NODELABEL
The event nodelabel xml tag- See Also:
- Constant Field Values
-
TAG_NODELOCATION
protected static final String TAG_NODELOCATION
The event nodelocation xml tag- See Also:
- Constant Field Values
-
TAG_HOST
protected static final String TAG_HOST
The event host xml tag- See Also:
- Constant Field Values
-
TAG_INTERFACE
protected static final String TAG_INTERFACE
The event interface xml tag- See Also:
- Constant Field Values
-
TAG_FOREIGNSOURCE
protected static final String TAG_FOREIGNSOURCE
The foreignsource for the event's nodeid xml tag- See Also:
- Constant Field Values
-
TAG_FOREIGNID
protected static final String TAG_FOREIGNID
The foreignid for the event's nodeid xml tag- See Also:
- Constant Field Values
-
TAG_IFINDEX
protected static final String TAG_IFINDEX
The event ifindex xml tag- See Also:
- Constant Field Values
-
TAG_INTERFACE_RESOLVE
protected static final String TAG_INTERFACE_RESOLVE
The reverse DNS lookup of the interface- See Also:
- Constant Field Values
-
TAG_PRIMARY_INTERFACE_ADDRESS
protected static final String TAG_PRIMARY_INTERFACE_ADDRESS
The primary interface- See Also:
- Constant Field Values
-
TAG_IFALIAS
protected static final String TAG_IFALIAS
The reverse DNS lookup of the interface- See Also:
- Constant Field Values
-
TAG_SNMP_ID
protected static final String TAG_SNMP_ID
The event snmp id xml tag- See Also:
- Constant Field Values
-
TAG_SNMP_TRAP_OID
protected static final String TAG_SNMP_TRAP_OID
The event snmp trapoid xml tag- See Also:
- Constant Field Values
-
TAG_SNMP
protected static final String TAG_SNMP
The SNMP xml tag- See Also:
- Constant Field Values
-
TAG_SNMP_IDTEXT
protected static final String TAG_SNMP_IDTEXT
The event snmp idtext xml tag- See Also:
- Constant Field Values
-
TAG_SNMP_VERSION
protected static final String TAG_SNMP_VERSION
The event snmp version xml tag- See Also:
- Constant Field Values
-
TAG_SNMP_SPECIFIC
protected static final String TAG_SNMP_SPECIFIC
The event snmp specific xml tag- See Also:
- Constant Field Values
-
TAG_SNMP_GENERIC
protected static final String TAG_SNMP_GENERIC
The event snmp generic xml tag- See Also:
- Constant Field Values
-
TAG_SNMP_COMMUNITY
protected static final String TAG_SNMP_COMMUNITY
The event snmp community xml tag- See Also:
- Constant Field Values
-
TAG_SNMPHOST
protected static final String TAG_SNMPHOST
The event snmp host xml tag- See Also:
- Constant Field Values
-
TAG_SERVICE
protected static final String TAG_SERVICE
The event service xml tag- See Also:
- Constant Field Values
-
TAG_SEVERITY
protected static final String TAG_SEVERITY
The event severity xml tag- See Also:
- Constant Field Values
-
TAG_OPERINSTR
protected static final String TAG_OPERINSTR
The event operinstruct xml tag- See Also:
- Constant Field Values
-
TAG_MOUSEOVERTEXT
protected static final String TAG_MOUSEOVERTEXT
The event mouseovertext xml tag- See Also:
- Constant Field Values
-
TAG_TTICKET_ID
protected static final String TAG_TTICKET_ID
- See Also:
- Constant Field Values
-
ASSET_BEGIN
protected static final String ASSET_BEGIN
The string that starts the expansion for an asset field - used to lookup values of asset fields by their names- See Also:
- Constant Field Values
-
ASSET_END_SUFFIX
protected static final String ASSET_END_SUFFIX
The string that ends the expansion of a parm- See Also:
- Constant Field Values
-
PARMS_NAMES
protected static final String PARMS_NAMES
The string that should be expanded to a list of all parm names- See Also:
- Constant Field Values
-
PARMS_VALUES
protected static final String PARMS_VALUES
The string that should be expanded to a list of all parm values- See Also:
- Constant Field Values
-
PARMS_ALL
protected static final String PARMS_ALL
The string that should be expanded to a list of all parms- See Also:
- Constant Field Values
-
PARM_BEGIN
protected static final String PARM_BEGIN
The string that starts the expansion for a parm - used to lookup values of parameters by their names- See Also:
- Constant Field Values
-
PARM_REGEX
protected static final Pattern PARM_REGEX
Pattern used to match and parse 'parm' tokens.
-
PARM_BEGIN_LENGTH
protected static final int PARM_BEGIN_LENGTH
The length of PARM_BEGIN- See Also:
- Constant Field Values
-
NUM_PARMS_STR
protected static final String NUM_PARMS_STR
The string that should be expanded to the number of parms- See Also:
- Constant Field Values
-
PARM_NUM_PREFIX
protected static final String PARM_NUM_PREFIX
The string that starts a parm number - used to lookup values of parameters by their position- See Also:
- Constant Field Values
-
PARM_NUM_PREFIX_LENGTH
protected static final int PARM_NUM_PREFIX_LENGTH
The length of PARM_NUM_PREFIX- See Also:
- Constant Field Values
-
PARM_NAME_NUMBERED_PREFIX
protected static final String PARM_NAME_NUMBERED_PREFIX
The string that starts a request for the name of a numbered parm- See Also:
- Constant Field Values
-
PARM_NAME_NUMBERED_PREFIX_LENGTH
protected static final int PARM_NAME_NUMBERED_PREFIX_LENGTH
The length of PARM_NAME_NUMBERED_PREFIX- See Also:
- Constant Field Values
-
PARM_END_SUFFIX
protected static final String PARM_END_SUFFIX
The string that ends the expansion of a parm- See Also:
- Constant Field Values
-
NAME_VAL_DELIM
protected static final char NAME_VAL_DELIM
For expansion of the '%parms[all]%' - the parm name and value are added as delimiter separated list of '= ' strings - See Also:
- Constant Field Values
-
SPACE_DELIM
protected static final char SPACE_DELIM
- See Also:
- Constant Field Values
-
ATTRIB_DELIM
protected static final char ATTRIB_DELIM
The values and the corresponding attributes of an element are added delimited by ATTRIB_DELIM- See Also:
- Constant Field Values
-
TAG_PERCENT_SIGN
protected static final String TAG_PERCENT_SIGN
Substitute the actual percent sign- See Also:
- Constant Field Values
-
HARDWARE_BEGIN
protected static final String HARDWARE_BEGIN
The string that starts the expansion for a hardware field - used to lookup values of hardware attributes by their index|name- See Also:
- Constant Field Values
-
HARDWARE_END_SUFFIX
protected static final String HARDWARE_END_SUFFIX
The string that ends the expansion of a hardware- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static EventUtil getInstance()
-
setInstance
public static void setInstance(EventUtil instance)
Used only for unit testing.- Parameters:
instance
-
-
escape
public static String escape(String inStr, char delimchar)
This method is used to escape required values from strings that may contain those values. If the passed string contains the passed value then the character is reformatted into its %dd format.
- Parameters:
inStr
- string that might contain the delimiterdelimchar
- delimiter to escape- Returns:
- The string with the delimiter escaped as in URLs
- See Also:
ATTRIB_DELIM
-
getAllParmValues
protected static String getAllParmValues(Event event)
Helper method.- Parameters:
event
-- Returns:
- All event parameter values as a String.
-
getAllParmNames
protected static String getAllParmNames(Event event)
Helper method.- Parameters:
event
-- Returns:
- The names of all the event parameters.
-
getAllParamValues
protected static String getAllParamValues(Event event)
Helper method.- Parameters:
event
-- Returns:
- All event parameter values as a String
-
getNumParmName
protected static String getNumParmName(String parm, Event event)
Helper method.- Parameters:
parm
-event
-- Returns:
- The name of a parameter based on its ordinal position in the event's list of parameters
-
splitAndExtract
public static String splitAndExtract(String src, String sep, int offset, boolean doRange, int rangeLen)
-
getNumParmValue
protected static String getNumParmValue(String parm, Event event)
Helper method.- Parameters:
parm
-event
-- Returns:
- The value of a parameter based on its ordinal position in the event's list of parameters
-
getNamedParmValue
public String getNamedParmValue(String parm, Event event)
Helper method.- Specified by:
getNamedParmValue
in interfaceEventUtil
- Parameters:
parm
- aString
object.event
- aEvent
object.- Returns:
- A parameter's value as a String using the parameter's name..
-
expandMapValues
public void expandMapValues(Map<String,String> map, Event event)
expandMapValues
- Specified by:
expandMapValues
in interfaceEventUtil
- Parameters:
map
- aMap
object.event
- aEvent
object.
-
expandParms
public String expandParms(String inp, Event event)
Expand the value if it has parms in one of the following formats - %element% values are expanded to have the value of the element where 'element' is an element in the event DTD - %parm[values-all]% is expanded to a delimited list of all parmblock values - %parm[names-all]% is expanded to a list of all parm names - %parm[all]% is expanded to a full dump of all parmblocks - %parm[name]% is expanded to the value of the parameter named 'name' - %parm[]% is replaced by the value of the parameter named 'name', if present - %parm[# ]% is replaced by the value of the parameter number 'num', if present - %parm[##]% is replaced by the number of parameters - Specified by:
expandParms
in interfaceEventUtil
- Parameters:
inp
- the input string in which parm values are to be expandedevent
- aEvent
object.- Returns:
- expanded value if the value had any parameter to expand, null otherwise
-
expandParms
public String expandParms(String input, Event event, Map<String,Map<String,String>> decode)
Expand the value if it has parms in one of the following formats - %element% values are expanded to have the value of the element where 'element' is an element in the event DTD - %parm[values-all]% is expanded to a delimited list of all parmblock values - %parm[names-all]% is expanded to a list of all parm names - %parm[all]% is expanded to a full dump of all parmblocks - %parm[name]% is expanded to the value of the parameter named 'name' - %parm[]% is replaced by the value of the parameter named 'name', if present - %parm[# ]% is replaced by the value of the parameter number 'num', if present - %parm[##]% is replaced by the number of parameters - Specified by:
expandParms
in interfaceEventUtil
- Parameters:
input
- the input string in which parm values are to be expandeddecode
- the varbind decode for thisevent
- aEvent
object.- Returns:
- expanded value if the value had any parameter to expand, null otherwise
-
getEventHost
public String getEventHost(Event event)
getEventHost
- Specified by:
getEventHost
in interfaceEventUtil
- Parameters:
event
- aEvent
object.- Returns:
- a
String
object.
-
getResolver
public ExpandableParameterResolver getResolver(String token)
- Specified by:
getResolver
in interfaceEventUtil
-
decodeSnmpV2TcDateAndTime
public Date decodeSnmpV2TcDateAndTime(BigInteger octetStringValue)
- Specified by:
decodeSnmpV2TcDateAndTime
in interfaceEventUtil
-
-