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 StringASSET_BEGINThe string that starts the expansion for an asset field - used to lookup values of asset fields by their namesprotected static StringASSET_END_SUFFIXThe string that ends the expansion of a parmprotected static charATTRIB_DELIMThe values and the corresponding attributes of an element are added delimited by ATTRIB_DELIMprotected static StringHARDWARE_BEGINThe string that starts the expansion for a hardware field - used to lookup values of hardware attributes by their index|nameprotected static StringHARDWARE_END_SUFFIXThe string that ends the expansion of a hardwareprotected static charNAME_VAL_DELIMFor expansion of the '%parms[all]%' - the parm name and value are added as delimiter separated list of '= ' strings protected static StringNUM_PARMS_STRThe string that should be expanded to the number of parmsprotected static StringPARM_BEGINThe string that starts the expansion for a parm - used to lookup values of parameters by their namesprotected static intPARM_BEGIN_LENGTHThe length of PARM_BEGINprotected static StringPARM_END_SUFFIXThe string that ends the expansion of a parmprotected static StringPARM_NAME_NUMBERED_PREFIXThe string that starts a request for the name of a numbered parmprotected static intPARM_NAME_NUMBERED_PREFIX_LENGTHThe length of PARM_NAME_NUMBERED_PREFIXprotected static StringPARM_NUM_PREFIXThe string that starts a parm number - used to lookup values of parameters by their positionprotected static intPARM_NUM_PREFIX_LENGTHThe length of PARM_NUM_PREFIXprotected static PatternPARM_REGEXPattern used to match and parse 'parm' tokens.protected static StringPARMS_ALLThe string that should be expanded to a list of all parmsprotected static StringPARMS_NAMESThe string that should be expanded to a list of all parm namesprotected static StringPARMS_VALUESThe string that should be expanded to a list of all parm valuesprotected static charSPACE_DELIMprotected static StringTAG_DESCRThe event descr xml tagprotected static StringTAG_DPNAMEThe event dpname xml tagprotected static StringTAG_EVENT_DB_IDThe Event ID xmlprotected static StringTAG_FOREIGNIDThe foreignid for the event's nodeid xml tagprotected static StringTAG_FOREIGNSOURCEThe foreignsource for the event's nodeid xml tagprotected static StringTAG_HOSTThe event host xml tagprotected static StringTAG_IFALIASThe reverse DNS lookup of the interfaceprotected static StringTAG_IFINDEXThe event ifindex xml tagprotected static StringTAG_INTERFACEThe event interface xml tagprotected static StringTAG_INTERFACE_RESOLVEThe reverse DNS lookup of the interfaceprotected static StringTAG_LOGMSGThe event logmsg xml tagprotected static StringTAG_MOUSEOVERTEXTThe event mouseovertext xml tagprotected static StringTAG_NODEIDThe event nodeid xml tagprotected static StringTAG_NODELABELThe event nodelabel xml tagprotected static StringTAG_NODELOCATIONThe event nodelocation xml tagprotected static StringTAG_OPERINSTRThe event operinstruct xml tagprotected static StringTAG_PERCENT_SIGNSubstitute the actual percent signprotected static StringTAG_PRIMARY_INTERFACE_ADDRESSThe primary interfaceprotected static StringTAG_SERVICEThe event service xml tagprotected static StringTAG_SEVERITYThe event severity xml tagprotected static StringTAG_SHORT_TIMEThe event time xml tag, short formatprotected static StringTAG_SNMPThe SNMP xml tagprotected static StringTAG_SNMP_COMMUNITYThe event snmp community xml tagprotected static StringTAG_SNMP_GENERICThe event snmp generic xml tagprotected static StringTAG_SNMP_IDThe event snmp id xml tagprotected static StringTAG_SNMP_IDTEXTThe event snmp idtext xml tagprotected static StringTAG_SNMP_SPECIFICThe event snmp specific xml tagprotected static StringTAG_SNMP_TRAP_OIDThe event snmp trapoid xml tagprotected static StringTAG_SNMP_VERSIONThe event snmp version xml tagprotected static StringTAG_SNMPHOSTThe event snmp host xml tagprotected static StringTAG_SOURCEThe event source xml tagprotected static StringTAG_TIMEThe event time xml tagprotected static StringTAG_TTICKET_IDprotected static StringTAG_UEIThe 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 DatedecodeSnmpV2TcDateAndTime(BigInteger octetStringValue)static Stringescape(String inStr, char delimchar)This method is used to escape required values from strings that may contain those values.voidexpandMapValues(Map<String,String> map, Event event)expandMapValuesStringexpandParms(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 StringexpandParms(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 StringgetAllParamValues(Event event)Helper method.protected static StringgetAllParmNames(Event event)Helper method.protected static StringgetAllParmValues(Event event)Helper method.StringgetEventHost(Event event)getEventHoststatic EventUtilgetInstance()StringgetNamedParmValue(String parm, Event event)Helper method.protected static StringgetNumParmName(String parm, Event event)Helper method.protected static StringgetNumParmValue(String parm, Event event)Helper method.ExpandableParameterResolvergetResolver(String token)static voidsetInstance(EventUtil instance)Used only for unit testing.static StringsplitAndExtract(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:
getNamedParmValuein interfaceEventUtil- Parameters:
parm- aStringobject.event- aEventobject.- 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:
expandMapValuesin interfaceEventUtil- Parameters:
map- aMapobject.event- aEventobject.
-
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:
expandParmsin interfaceEventUtil- Parameters:
inp- the input string in which parm values are to be expandedevent- aEventobject.- 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:
expandParmsin interfaceEventUtil- Parameters:
input- the input string in which parm values are to be expandeddecode- the varbind decode for thisevent- aEventobject.- Returns:
- expanded value if the value had any parameter to expand, null otherwise
-
getEventHost
public String getEventHost(Event event)
getEventHost
- Specified by:
getEventHostin interfaceEventUtil- Parameters:
event- aEventobject.- Returns:
- a
Stringobject.
-
getResolver
public ExpandableParameterResolver getResolver(String token)
- Specified by:
getResolverin interfaceEventUtil
-
decodeSnmpV2TcDateAndTime
public Date decodeSnmpV2TcDateAndTime(BigInteger octetStringValue)
- Specified by:
decodeSnmpV2TcDateAndTimein interfaceEventUtil
-
-