|
"WEBNMS_5 API Docs" | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface EventAPI
This API is for accessing and managing Event objects in the Event Database. This API interface also provides various utility methods built around the Event operations, that significantly enhances the usability of the API. Methods are provided to add Events, register external applications for Trap and Event notifications, purge the Events in the server etc.
This API is accessible either through RMI or directly from the same JVM where the server is running. When RMI is enabled, i.e. by runninng RMI registry before the NMS server is started, the EventAPI can be accessed remotely via RMI. It is published with RMI handle EventAPI in the server.
Code Snippet: Code within the same JVM as the NMS server can use theNmsUtil.getAPI(String)
method to get the EventAPI handle.
// Accessing EventAPI from the same JVM EventAPI eventAPI = (EventAPI) NmsUtil.getAPI ("EventAPI"); int count = eventAPI.getTotalEventCount();
The following code exhibits the method to get the EventAPI handle via RMI if executed in seperate JVM.import com.adventnet.nms.eventdb.EventAPI; import com.adventnet.nms.eventdb.InputEvent; import java.rmi.Naming; . . . try { EventAPI eventAPI; String hostName = "localhost"; String apiString = "//" + hostName + "/EventAPI"; // hostName specifies name of the host //This can be used when user wants to gets the handle through RMI lookup eventAPI = (EventAPI) Naming.lookup(apiString); InputEvent event = new InputEvent(); event.setSource("web-server.adventnet.com"); //setting the source Vector matchedEvents = eventAPI.getEvents(event); //fetches the events //matching the source "web-server.adventnet.com" if(matchedEvents.size() == 0) System.out.println("No Events with source web-server.adventnet.com present"); } catch{Exception e} { e.printStackTrace(); }
// Accessing EventAPI via RMIAccessAPI in the NMS RMI secure mode try { String hostName = "localhost"; // can be replaced with the host where the NMS server is running RMIAccessAPI rmiApi = (RMIAccessAPI) Naming.lookup ("//" + hostName + "/RMIAccessAPI"); EventAPI eventAPI = (EventAPI) rmiApi.getAPI ("username", "password", "EventAPI"); // delete all the Events from the server eventAPI.purgeEventDB(); } catch (Exception remoteException) { System.out.println ( "Error in getting the handle for TopoAPI"); }
Method Summary | |
---|---|
void |
addEvent(Event event)
To add an event into the system. |
void |
addEvent(InputEvent event)
Deprecated. as of WebNMS 5. Instead use addEvent(Event) |
boolean |
deregister(TrapObserver obs)
To deregister the User application that got registered as Trap observer. |
boolean |
deregisterForEvents(EventObserver obs)
To deregister the User application that got registered as Event observer. |
int |
getCleanEventInterval()
This method returns the Event delete interval value (in days). |
Event |
getEventByID(int id)
Returns the event whose id matches the argument. |
java.util.Properties |
getEventModuleParams()
Gets the Event Module parameters and their values in java.util.Properties object. |
int |
getEventQueueSize()
This method returns the number of events which are in the Event queue and are still to be processed. |
java.util.Vector |
getEvents(InputEvent event)
This method can be used to retrieve Events matching some specific criteria from Web NMS. |
java.util.Vector |
getEvents(InputEvent event1,
InputEvent event2)
This method is used to retrieve Events matching some specific criteria from Web NMS and which got generated between specified interval of time. |
java.util.Vector |
getEvents(InputEvent event,
long endTime)
This method is used to retrieve Events matching some specific criteria from Web NMS and which got generated between specified interval of time. |
int |
getEventWindowSize()
To get the Event Window size configured in WebNMS. |
java.util.Vector |
getObjectPropsWithProps(java.lang.String classname,
java.lang.String[] fetchProperties,
java.util.Properties criteria,
boolean returnAsProps)
Gets a Vector containing selective properties of objects matching the given criteria. |
java.util.Vector |
getObjects(java.lang.String classname,
java.util.Properties match)
Gets the Vector of objects matching the given properties. |
int |
getTotalEventCount()
Returns the total number of Events accessible through WebNMS system. |
int[] |
getTrapPort()
Returns the port numbers on which EventMgr is listening for traps. |
boolean |
is_inQ_SizeBeyondLimit()
Returns whether the Event module's event queue size has exceeded the size limit configured. |
void |
pauseFilterAction(java.lang.String[] runnableClassName)
This method can be used to pause the filter action thread at runtime which is running. |
void |
purgeEventDB()
Deletes all the events from the NMS system. |
boolean |
register(TrapObserver obs)
To register user applications for notification of traps. |
boolean |
registerForEvents(EventObserver obs)
To register for notifications of events. |
void |
resumeFilterAction(java.lang.String[] runnableClassName)
This method can be used to resume the filter action thread at runtime which has been paused. |
boolean |
setAutoCommit(boolean b)
This method sets the Event module Database connection's auto-commit mode. |
void |
setCleanEventInterval(int CLEAN_EVENT_INTERVAL)
This method dynamically sets the Event delete interval (value in days). |
void |
setEventModuleParams(java.util.Properties prop)
Sets the Event Module Parameters. |
Methods inherited from interface com.adventnet.nms.util.CommonAPI |
---|
getCompleteList, getObjectNamesWithProps, getPropertiesOfObject |
Method Detail |
---|
void addEvent(Event event) throws java.rmi.RemoteException, NmsStorageException, FaultException
Objects that extend com.adventnet.nms.eventdb.Event or it derived class can be added using this method.
When Event is added using this method, and if the size of the Event queue has exceeded the size limit configured, will throw NmsStorageException. Hence users are suggested to check the Event queue size before adding Events through the method EventAPI.is_inQ_SizeBeyondLimit() which will return 'true' if the event queue size has exceeded the size limit configured.
event
- The Event object which is filled with the relevant fields
for example entity,source,message,category time and severity
java.rmi.RemoteException
- if a problem occurs when accessing through RMI.
NmsStorageException
- When EventMgr's event queue size has exceeded the size limit configured for
MAX_EVENT_PROCESS_QUEUE command line option of EventMgr Process,when null is added or when user tries to add events
while server is shutting down.
FaultException
- if there is any other Runtime Exception while adding the eventis_inQ_SizeBeyondLimit()
,
Event
void addEvent(InputEvent event) throws java.rmi.RemoteException, NmsStorageException, FaultException
Hence users are suggested to check the Event queue size before adding events through the EventAPI.is_inQ_SizeBeyondLimit() which will return 'true' if the event queue size has exceeded the size limit configured.
event
- The InputEvent object which is filled with the relevant event fields like
entity, source, message, category, severity etc.
java.rmi.RemoteException
- if a problem occurs when accessing through RMI.
NmsStorageException
- if there is any exception while adding to the event in memory
or When EventMgr's event queue size has exceeded the size limit configured for
MAX_EVENT_PROCESS_QUEUE command line option of EventMgr Process,when null is added or when user tries to add events
while server is shutting down using the
FaultException
- if there is any Runtime exception while adding to the eventaddEvent(Event)
,
is_inQ_SizeBeyondLimit()
,
InputEvent
boolean register(TrapObserver obs) throws java.rmi.RemoteException
When a trap is received by NMS, it is first matched against Trap filters (which are user defined classes) if configured any. Trap filters can return either a modified trap PDU or an Event object or drop the trap by returning 'null'. If the an Event Object or SnmpPDU is returned from trap filter, the trap observers will be notified. If the trap is dropped, the trap observers are not notified. If the trap does not match with trap filters, the trap observers are notified of all the traps.
The Trap observer should implement the com.adventnet.nms.eventdb.TrapObserver interface and register with the EventAPI using this method call.
If the user application needs to be notified for all the traps received in some ports irrespective of whether NMS drops traps, or needs to be notified for ports other than where NMS is listening for traps can implement the com.adventnet.nms.trap.SocketLister interface and register using TrapAPI.registerForTraps(int [] portArray, SocketListener trapListener).
obs
- The TrapObserver interface implementor class which needs to be notified about traps.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.deregister(TrapObserver)
,
TrapAPI
,
TrapObserver
,
com.adventnet.nms.trap.SocketLister
boolean deregister(TrapObserver obs) throws java.rmi.RemoteException
obs
- The User application implementing com.adventnet.nms.eventdb.TrapObserver that needs to be
deregistered from trap notification.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.register(TrapObserver)
boolean registerForEvents(EventObserver obs) throws java.rmi.RemoteException
The listener for events should implement the com.adventnet.nms.eventdb.EventObserver interface and register that object as an Event observer with this method.
obs
- The User application implementing EventObserver interface that
has registered for Event notification.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.deregisterForEvents(EventObserver)
,
EventObserver
boolean deregisterForEvents(EventObserver obs) throws java.rmi.RemoteException
obs
- The User application implementing com.adventnet.nms.eventdb.EventObserver that needs to be
deregistered from Event notification.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.registerForEvents(EventObserver)
java.util.Vector getEvents(InputEvent event) throws java.rmi.RemoteException, FaultException
The values set for the String based properties in parameter InputEvent can take wildCard character * which stands for matching zero or more characters. The String based properties can also accept values that starts with character ! which stands for negation operation while matching. Values can also accept ,(comma) seperated values which can match any one of the values seperated by comma.
Example criteria for String based properties: 1. WebNMS* - matches values startswith WebNMS 2. *WebNMS - matches values endswith WebNMS 3. !WebNMS - matches values that does not start with WebNMS 4. Node,Interface,Snmp - matches any value that startwith any of the mentioned stringThe values set for numeric properties can only match the exact value given for the property in InputEvent object passed.
event
- InputEvent which wraps the matching criteria
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.
FaultException
- if there is any exception while getting the eventCommonAPI.getObjectNamesWithProps(Properties )
,
getEvents(InputEvent, long )
java.util.Vector getEvents(InputEvent event1, InputEvent event2) throws java.rmi.RemoteException, FaultException
All the Events matching the criteria specified in the first InputEvent object and got created between the 'time' interval set for the first InputEvent parameter and second InputEvent parameter will be returned. Assume the 'time' field specified for the first InputEvent is 'startTime' and the 'time' field set for the second InputEvent is 'endTime'. Then when this method is called, all the Events matching the criteria specified in the first InputEvent and generated between 'startTime' and 'endTime' will be returned.
The values set for the String based properties in parameter InputEvent can take wildCard character * which stands for matching zero or more characters. The String based properties can also accept values that starts with character ! which stands for negation operation while matching. Values can also accept ,(comma) seperated values which can match any one of the values seperated by comma.
Example criteria for String based properties: 1. WebNMS* - matches values startswith WebNMS 2. *WebNMS - matches values endswith WebNMS 3. !WebNMS - matches values that does not start with WebNMS 4. Node,Interface,Snmp - matches any value that startwith any of the mentioned stringThe values set for numeric properties can only match the exact value given for the property in InputEvent object passed.
event1
- The first InputEvent object whose properties are used for filtering events.
The time field corresponds to the startTime as described above.event2
- The second InputEvent object whose time field specifies the endTime.
java.rmi.RemoteException
- if problem occured when accessing method this through RMI.
FaultException
- if there is any exception while getting to the eventCommonAPI.getObjectNamesWithProps(Properties )
,
getEvents(InputEvent, long)
java.util.Vector getEvents(InputEvent event, long endTime) throws java.rmi.RemoteException, FaultException
All the Events matching the criteria specified in the first InputEvent object and got created between the 'time' interval set for the first InputEvent parameter and long value specified as second parameter will be returned. Assume the 'time' field specified for the first InputEvent is 'startTime' and the long value specified for second parameter is 'endTime'. Then when this method is called, all the Events matching the criteria specified in the first InputEvent and generated between 'startTime' and 'endTime' will be returned.
The values set for the String based properties in parameter InputEvent can take wildCard character * which stands for matching zero or more characters. The String based properties can also accept values that starts with character ! which stands for negation operation while matching. Values can also accept ,(comma) seperated values which can match any one of the values seperated by comma.
Example criteria for String based properties: 1. WebNMS* - matches values startswith WebNMS 2. *WebNMS - matches values endswith WebNMS 3. !WebNMS - matches values that does not start with WebNMS 4. Node,Interface,Snmp - matches any value that startwith any of the mentioned stringThe values set for numeric properties can only match the exact value given for the property in InputEvent object passed.
event
- The first InputEvent object whose properties are used for filtering events.
The time field corresponds to the startTime as described above.endTime
- The long value which specifies the endTime.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.
FaultException
- if there is any exception while getting to the eventsCommonAPI.getObjectNamesWithProps(Properties )
Event getEventByID(int id) throws java.rmi.RemoteException, FaultException
When the total number of events exceeds the value set for EVENT_WINDOW_SIZE param, then NMS can manage only the latest EVENT_WINDOW_SIZE events. Hence the parameter passed to the method should lie in the range of latest EVENT_WINDOW_SIZE events. If not this method call will return 'null'.
id
- The id of the event object.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.
FaultException
- if there is any exception while getting the eventjava.util.Vector getObjects(java.lang.String classname, java.util.Properties match) throws java.rmi.RemoteException, FaultException
classname
- Name of the class to which the objects belong tomatch
- The matching criteria in the form of Properties
java.rmi.RemoteException
- if error occurs in remote machine
FaultException
- if there is any exception while getting the Object for specific criteriaboolean setAutoCommit(boolean b) throws java.rmi.RemoteException, java.sql.SQLException
b
- Decides the auto-commit mode
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.
SQLException
- When problem occurs dealing with DBint getTotalEventCount() throws java.rmi.RemoteException
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.getEventWindowSize()
int getEventQueueSize() throws java.rmi.RemoteException
The maximum number of events that can be in the queue is configurable and is set as a parameter "MAX_EVENT_PROCESS_QUEUE" to EventMgr from NmsProcessesBE.conf file. At any point of time the number of events pending to be processed should not exceed MAX_EVENT_PROCESS_QUEUE limit.
Please note that through API, before adding events, the user should check for queue size with this method or if the queue size has exceeded the configured limit through EventAPI.is_inQ_SizeBeyondLimit(). The default value for Event queue size is 500.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.is_inQ_SizeBeyondLimit()
int[] getTrapPort() throws java.rmi.RemoteException
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.boolean is_inQ_SizeBeyondLimit() throws java.rmi.RemoteException
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.getEventQueueSize()
int getCleanEventInterval() throws java.rmi.RemoteException
The Event delete interval can be set dynamically using the setCleanEventInterval(int) method. This method will dynamically return the value set for Event delete interval.
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.void setCleanEventInterval(int CLEAN_EVENT_INTERVAL) throws java.rmi.RemoteException, FaultException
Events older than the value set for CLEAN_EVENT_INTERVAL days will be deleted by NMS. In order to control the total number of Events in the system, this method could be used to set the Event delete interval dynamically.
Invoking this method with zero or negative value will have no impact.
CLEAN_EVENT_INTERVAL
- the Event delete interval value (in days).
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.
FaultException
- if there is any exception while setting to the clean evenet intervalgetCleanEventInterval()
void purgeEventDB() throws java.rmi.RemoteException, NmsStorageException, UserTransactionException
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.
NmsStorageException
- if error occurs while deleting Events
UserTransactionException
- if there is any exception while making the transactionint getEventWindowSize() throws java.rmi.RemoteException, NmsStorageException
java.rmi.RemoteException
- if problem occured when accessing this method through RMI.
NmsStorageException
- when problem occured in getting EventWindowSizevoid setEventModuleParams(java.util.Properties prop) throws java.rmi.RemoteException, InvalidParameterException
Event Module Parameters | Possible Values |
SAVE_DIR | name of the directory |
PRINT_COMMAND | print command |
CLEAN_EVENT_INTERVAL | int > 0 (no of days) |
MAX_EVENT_PROCESS_QUEUE | int > 0 |
TRANSIENT_TRAP_PDU_IN_EVENT | true,false |
DROP_TRAP_WHILE_UNMANAGED | true,false |
GRACEFUL_SHUT_DOWN | true,false |
V3_AUTH | true,false |
NEED_INFORM_ACK | true,false |
AUTHORIZATION | true,false |
prop
- java.util.Properties object in which Event Module Parameters and their
values are stored
java.rmi.RemoteException
- if request fails in remote machine
InvalidParameterException
- if invalid value is given
for any of the Event Module Parameter.java.util.Properties getEventModuleParams() throws java.rmi.RemoteException
The following parameters and their values will be put in the java.util.Properties object and returned.
Event Module Parameters | Possible Values |
SAVE_DIR | name of the directory |
PRINT_COMMAND | print command |
CLEAN_EVENT_INTERVAL | int > 0 (no of days) |
MAX_EVENT_PROCESS_QUEUE | int > 0 |
TRANSIENT_TRAP_PDU_IN_EVENT | true,false |
DROP_TRAP_WHILE_UNMANAGED | true,false |
GRACEFUL_SHUT_DOWN | true,false |
V3_AUTH | true,false |
NEED_INFORM_ACK | true,false |
AUTHORIZATION | true,false |
EVENT_OBJECTS_IN_MEMORY | int >= 0 |
EVENT_WINDOW_SIZE | int > 0 |
java.rmi.RemoteException
- if request fails in remote machinejava.util.Vector getObjectPropsWithProps(java.lang.String classname, java.lang.String[] fetchProperties, java.util.Properties criteria, boolean returnAsProps) throws java.rmi.RemoteException, FaultException
For example, to fetch few properties say enity and source of all the events with severity 5 from the Event Database,
the following code snippet can be used.
Now the
Properties criteria = new Properties();
criteria.put("severity","5");
String fetchProperties = {"entity","source"};
Vector Events = eventAPI.getObjectPropsWithProps("Event",fetchProperties,criteria,true,false);
Events
will Properties object for all objects match the criteria.
The Properties will have 2 elements of entity and source for all the Events.
This will be fetched from the tables which are associated with the object hierarchy of Event. ie., it will
fetch data from the table Event or the extended object's tables.
This method returns only those objects whose classname property is the one passed to this method. If the given classname is incorrect, i.e., any of the property name given in the match criteria is not found in the properties of objects associated with the given classname, then this method will return null.
classname
- the classname for the objects that are selected.fetchProperties
- the properties that needs to be fetched.match
- the criteria based on which the objects to be selected from the database.returnAsProps
- if true, returns a Vector of Properties objects else List of properties in order specified in fetchProperties
java.rmi.RemoteException
- if a problem occurs when accessing through RMI.
FaultException
- if there is any exception while getting the Object for specific criteriavoid resumeFilterAction(java.lang.String[] runnableClassName) throws java.rmi.RemoteException
runnableClassName
- The classname with the package structure of the runnable class to be resumed.
java.rmi.RemoteException
- if a problem occurs when accessing through RMI.
For eg,
runnableClassName[0]="com.adventnet.nms.eventdb.SendEmailEventAction"
runnableClassName[1]="com.adventnet.nms.eventdb.SendTrapEventAction"
Note: The "FILTERACTION_FOR_EVENT_IN_THREAD" argument in EventMgr process must be set to true in NmsProcessBE.conf file to use this method.void pauseFilterAction(java.lang.String[] runnableClassName) throws java.rmi.RemoteException
runnableClassName
- The classname with the package structure of the runnable class to be resumed.
java.rmi.RemoteException
- if a problem occurs when accessing through RMI.
For eg,
runnableClassName[0]="com.adventnet.nms.eventdb.SendEmailEventAction"
runnableClassName[1]="com.adventnet.nms.eventdb.SendTrapEventAction"
Note: The "FILTERACTION_FOR_EVENT_IN_THREAD" argument in EventMgr process must be set to true in NmsProcessBE.conf file to use this method.
|
"WEBNMS_5 API Docs" | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |