org.opennms.web.alarm
Class AlarmFactory

java.lang.Object
  extended by org.opennms.web.alarm.AlarmFactory

public class AlarmFactory
extends Object

Encapsulates all querying functionality for alarms.

Author:
Tarus Balog , Lawrence Karnowski , OpenNMS

Method Summary
static void acknowledge(Alarm[] alarms, String user)
          Acknowledge a list of alarms with the given username and the current time.
static void acknowledge(Alarm[] alarms, String user, Date time)
          Acknowledge a list of alarms with the given username and the given time.
static void acknowledge(Filter[] filters, String user)
          Acknowledge with the given username and the current time all alarms that match the given filter criteria.
static void acknowledge(Filter[] filters, String user, Date time)
          Acknowledge with the given username and the given time all alarms that match the given filter criteria.
static void acknowledge(int[] alarmIds, String user)
          Acknowledge a list of alarms with the given username and the current time.
static void acknowledge(int[] alarmIds, String user, Date time)
          Acknowledge a list of alarms with the given username and the given time.
static void acknowledgeAll(String user)
          Acknowledge all unacknowledged alarms with the given username and the given time.
static void acknowledgeAll(String user, Date time)
          Acknowledge all unacknowledged alarms with the given username and the given time.
static void clearAlarms(int[] alarmIds, String user)
          Clear a list of alarms, using the given username and the current time
static void clearAlarms(int[] alarmIds, String user, Date time)
          Clear a list of alarms.
static void escalateAlarms(int[] alarmIds, String user)
          Escalate a list of alarms using the given username and the current time
static void escalateAlarms(int[] alarmIds, String user, Date time)
          Escalate a list of alarms.
static int getAlarmCount()
          Count all outstanding (unacknowledged) alarms.
static int getAlarmCount(AcknowledgeType ackType, Filter[] filters)
          Count the number of alarms for a given acknowledgement type.
static int[] getAlarmCountBySeverity(AcknowledgeType ackType, Filter[] filters)
          Count the number of alarms for a given acknowledgement type.
static int getAlarmCountForInterface(int nodeId, String ipAddress, AcknowledgeType ackType)
          Return the number of alarms for this node ID, IP address, and the given acknowledgement type.
static int getAlarmCountForInterface(String ipAddress, AcknowledgeType ackType)
          Return the number of alarms for this IP address and the given acknowledgement type.
static int getAlarmCountForNode(int nodeId, AcknowledgeType ackType)
          Return the number of alarms for this node and the given acknowledgement type.
static int getAlarmCountForService(int serviceId, AcknowledgeType ackType)
          Return the number of alarms for this node ID, IP address, service ID, and the given acknowledgement type.
static int getAlarmCountForService(int nodeId, String ipAddress, int serviceId, AcknowledgeType ackType)
          Return the number of alarms for this node ID, IP address, service ID, and the given acknowledgement type.
static Alarm[] getAlarms()
          Return all unacknowledged alarms sorted by time.
static Alarm[] getAlarms(AcknowledgeType ackType)
          Return all unacknowledged or acknowledged alarms sorted by time.
static Alarm getAlarms(int alarmId)
          Return a specific alarm.
static Alarm[] getAlarms(SortStyle sortStyle)
          Return all unacknowledged alarms sorted by the given sort style.
static Alarm[] getAlarms(SortStyle sortStyle, AcknowledgeType ackType)
          Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.
static Alarm[] getAlarms(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters)
          Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.
static Alarm[] getAlarms(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters, int limit, int offset)
          Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.
static Alarm[] getAlarms(SortStyle sortStyle, boolean includeAcknowledged)
          Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.
static Alarm[] getAlarmsForInterface(int nodeId, String ipAddress)
          Return all unacknowledged alarms sorted by event ID for the given interface.
static Alarm[] getAlarmsForInterface(int nodeId, String ipAddress, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given node and IP address.
static Alarm[] getAlarmsForInterface(String ipAddress)
          Return all unacknowledged alarms sorted by time for that have the given IP address, regardless of what node they belong to.
static Alarm[] getAlarmsForInterface(String ipAddress, boolean includeAcknowledged)
          Deprecated. Replaced by " #getEventsForInterface(String,SortStyle,AcknowledgeType) getEventsForInterface( String, SortStyle, AcknowledgeType )"
static Alarm[] getAlarmsForInterface(String ipAddress, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given IP address.
static Alarm[] getAlarmsForNode(int nodeId)
          Return all unacknowledged alarms sorted by alarm ID for the given node.
static Alarm[] getAlarmsForNode(int nodeId, SortStyle sortStyle, AcknowledgeType ackType)
          Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style for the given node.
static Alarm[] getAlarmsForNode(int nodeId, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given node.
static Alarm[] getAlarmsForPoller(String poller)
          Return all unacknowledged alarms sorted by time for that have the given distributed poller.
static Alarm[] getAlarmsForPoller(String poller, boolean includeAcknowledged)
          Return all alarms (optionally only unacknowledged alarms) sorted by time that have the given distributed poller.
static Alarm[] getAlarmsForService(int serviceId)
          Return all unacknowledged alarms sorted by time for the given service type, regardless of what node or interface they belong to.
static Alarm[] getAlarmsForService(int serviceId, boolean includeAcknowledged)
          Return all alarms (optionally only unacknowledged alarms) sorted by time for the given service type, regardless of what node or interface they belong to.
static Alarm[] getAlarmsForService(int serviceId, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given service ID.
static Alarm[] getAlarmsForService(int nodeId, String ipAddress, int serviceId)
          Return all unacknowledged alarms sorted by time for the given service.
static Alarm[] getAlarmsForService(int nodeId, String ipAddress, int serviceId, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given node, IP address, and service ID.
static Alarm[] getAlarmsForSeverity(int severity)
          Return all unacknowledged alarms sorted by time for the given severity.
static Alarm[] getAlarmsForSeverity(int severity, SortStyle sortStyle, AcknowledgeType ackType)
           
protected static Alarm[] rs2Alarms(ResultSet rs)
          Convenience method for translating a java.sql.ResultSet containing event information into an array of Alarm objects.
static void unacknowledge(Alarm[] alarms)
          Unacknowledge a list of alarms.
static void unacknowledge(Filter[] filters)
          Unacknowledge alarms that match the given filter criteria.
static void unacknowledge(int[] alarmIds)
          Unacknowledge a list of alarms.
static void unacknowledgeAll()
          Unacknowledge all acknowledged alarms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAlarmCount

public static int getAlarmCount()
                         throws SQLException
Count all outstanding (unacknowledged) alarms.

Throws:
SQLException

getAlarmCount

public static int getAlarmCount(AcknowledgeType ackType,
                                Filter[] filters)
                         throws SQLException
Count the number of alarms for a given acknowledgement type.

Throws:
SQLException

getAlarmCountBySeverity

public static int[] getAlarmCountBySeverity(AcknowledgeType ackType,
                                            Filter[] filters)
                                     throws SQLException
Count the number of alarms for a given acknowledgement type.

Returns:
An array of event counts. Each index of the array corresponds to the event severity for the counts (indeterminate is 1, critical is 7, etc).
Throws:
SQLException

getAlarms

public static Alarm getAlarms(int alarmId)
                       throws SQLException
Return a specific alarm.

Throws:
SQLException

getAlarms

public static Alarm[] getAlarms()
                         throws SQLException
Return all unacknowledged alarms sorted by time.

Throws:
SQLException

getAlarms

public static Alarm[] getAlarms(AcknowledgeType ackType)
                         throws SQLException
Return all unacknowledged or acknowledged alarms sorted by time.

Throws:
SQLException

getAlarms

public static Alarm[] getAlarms(SortStyle sortStyle)
                         throws SQLException
Return all unacknowledged alarms sorted by the given sort style.

Throws:
SQLException

getAlarms

public static Alarm[] getAlarms(SortStyle sortStyle,
                                boolean includeAcknowledged)
                         throws SQLException
Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.

Throws:
SQLException

getAlarms

public static Alarm[] getAlarms(SortStyle sortStyle,
                                AcknowledgeType ackType)
                         throws SQLException
Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.

Throws:
SQLException

getAlarms

public static Alarm[] getAlarms(SortStyle sortStyle,
                                AcknowledgeType ackType,
                                Filter[] filters)
                         throws SQLException
Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.

Throws:
SQLException

getAlarms

public static Alarm[] getAlarms(SortStyle sortStyle,
                                AcknowledgeType ackType,
                                Filter[] filters,
                                int limit,
                                int offset)
                         throws SQLException
Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style.

Note: This limit/offset code is Postgres specific! Per Shane , this is okay for now until we can come up with an Oracle alternative too.

Parameters:
limit - if -1 or zero, no limit or offset is used
offset - if -1, no limit or offset if used
Throws:
SQLException

getAlarmsForNode

public static Alarm[] getAlarmsForNode(int nodeId)
                                throws SQLException
Return all unacknowledged alarms sorted by alarm ID for the given node.

Throws:
SQLException

getAlarmsForNode

public static Alarm[] getAlarmsForNode(int nodeId,
                                       SortStyle sortStyle,
                                       AcknowledgeType ackType)
                                throws SQLException
Return all alarms (optionally only unacknowledged alarms) sorted by the given sort style for the given node.

Throws:
SQLException

getAlarmsForNode

public static Alarm[] getAlarmsForNode(int nodeId,
                                       SortStyle sortStyle,
                                       AcknowledgeType ackType,
                                       int throttle,
                                       int offset)
                                throws SQLException
Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given node.

Parameters:
throttle - a value less than one means no throttling
Throws:
SQLException

getAlarmCountForNode

public static int getAlarmCountForNode(int nodeId,
                                       AcknowledgeType ackType)
                                throws SQLException
Return the number of alarms for this node and the given acknowledgement type.

Throws:
SQLException

getAlarmsForInterface

public static Alarm[] getAlarmsForInterface(int nodeId,
                                            String ipAddress)
                                     throws SQLException
Return all unacknowledged alarms sorted by event ID for the given interface.

Throws:
SQLException

getAlarmsForInterface

public static Alarm[] getAlarmsForInterface(int nodeId,
                                            String ipAddress,
                                            SortStyle sortStyle,
                                            AcknowledgeType ackType,
                                            int throttle,
                                            int offset)
                                     throws SQLException
Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given node and IP address.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
SQLException

getAlarmsForInterface

public static Alarm[] getAlarmsForInterface(String ipAddress)
                                     throws SQLException
Return all unacknowledged alarms sorted by time for that have the given IP address, regardless of what node they belong to.

Throws:
SQLException

getAlarmsForInterface

public static Alarm[] getAlarmsForInterface(String ipAddress,
                                            boolean includeAcknowledged)
                                     throws SQLException
Deprecated. Replaced by " #getEventsForInterface(String,SortStyle,AcknowledgeType) getEventsForInterface( String, SortStyle, AcknowledgeType )"

Return all alarms (optionally only unacknowledged alarms) sorted by time that have the given IP address, regardless of what node they belong to.

Throws:
SQLException

getAlarmsForInterface

public static Alarm[] getAlarmsForInterface(String ipAddress,
                                            SortStyle sortStyle,
                                            AcknowledgeType ackType,
                                            int throttle,
                                            int offset)
                                     throws SQLException
Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given IP address.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
SQLException

getAlarmCountForInterface

public static int getAlarmCountForInterface(int nodeId,
                                            String ipAddress,
                                            AcknowledgeType ackType)
                                     throws SQLException
Return the number of alarms for this node ID, IP address, and the given acknowledgement type.

Throws:
SQLException

getAlarmCountForInterface

public static int getAlarmCountForInterface(String ipAddress,
                                            AcknowledgeType ackType)
                                     throws SQLException
Return the number of alarms for this IP address and the given acknowledgement type.

Throws:
SQLException

getAlarmsForService

public static Alarm[] getAlarmsForService(int nodeId,
                                          String ipAddress,
                                          int serviceId)
                                   throws SQLException
Return all unacknowledged alarms sorted by time for the given service.

Throws:
SQLException

getAlarmsForService

public static Alarm[] getAlarmsForService(int nodeId,
                                          String ipAddress,
                                          int serviceId,
                                          SortStyle sortStyle,
                                          AcknowledgeType ackType,
                                          int throttle,
                                          int offset)
                                   throws SQLException
Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given node, IP address, and service ID.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
SQLException

getAlarmsForService

public static Alarm[] getAlarmsForService(int serviceId)
                                   throws SQLException
Return all unacknowledged alarms sorted by time for the given service type, regardless of what node or interface they belong to.

Throws:
SQLException

getAlarmsForService

public static Alarm[] getAlarmsForService(int serviceId,
                                          boolean includeAcknowledged)
                                   throws SQLException
Return all alarms (optionally only unacknowledged alarms) sorted by time for the given service type, regardless of what node or interface they belong to.

Throws:
SQLException

getAlarmsForService

public static Alarm[] getAlarmsForService(int serviceId,
                                          SortStyle sortStyle,
                                          AcknowledgeType ackType,
                                          int throttle,
                                          int offset)
                                   throws SQLException
Return some maximum number of alarms or less (optionally only unacknowledged alarms) sorted by the given sort style for the given service ID.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
SQLException

getAlarmCountForService

public static int getAlarmCountForService(int nodeId,
                                          String ipAddress,
                                          int serviceId,
                                          AcknowledgeType ackType)
                                   throws SQLException
Return the number of alarms for this node ID, IP address, service ID, and the given acknowledgement type.

Throws:
SQLException

getAlarmCountForService

public static int getAlarmCountForService(int serviceId,
                                          AcknowledgeType ackType)
                                   throws SQLException
Return the number of alarms for this node ID, IP address, service ID, and the given acknowledgement type.

Throws:
SQLException

getAlarmsForSeverity

public static Alarm[] getAlarmsForSeverity(int severity)
                                    throws SQLException
Return all unacknowledged alarms sorted by time for the given severity.

Throws:
SQLException

getAlarmsForSeverity

public static Alarm[] getAlarmsForSeverity(int severity,
                                           SortStyle sortStyle,
                                           AcknowledgeType ackType)
                                    throws SQLException
Throws:
SQLException

getAlarmsForPoller

public static Alarm[] getAlarmsForPoller(String poller)
                                  throws SQLException
Return all unacknowledged alarms sorted by time for that have the given distributed poller.

Throws:
SQLException

getAlarmsForPoller

public static Alarm[] getAlarmsForPoller(String poller,
                                         boolean includeAcknowledged)
                                  throws SQLException
Return all alarms (optionally only unacknowledged alarms) sorted by time that have the given distributed poller.

Throws:
SQLException

acknowledge

public static void acknowledge(Alarm[] alarms,
                               String user)
                        throws SQLException
Acknowledge a list of alarms with the given username and the current time.

Throws:
SQLException

acknowledge

public static void acknowledge(Alarm[] alarms,
                               String user,
                               Date time)
                        throws SQLException
Acknowledge a list of alarms with the given username and the given time.

Throws:
SQLException

acknowledge

public static void acknowledge(int[] alarmIds,
                               String user)
                        throws SQLException
Acknowledge a list of alarms with the given username and the current time.

Throws:
SQLException

acknowledge

public static void acknowledge(int[] alarmIds,
                               String user,
                               Date time)
                        throws SQLException
Acknowledge a list of alarms with the given username and the given time.

Throws:
SQLException

acknowledge

public static void acknowledge(Filter[] filters,
                               String user)
                        throws SQLException
Acknowledge with the given username and the current time all alarms that match the given filter criteria.

Throws:
SQLException

acknowledge

public static void acknowledge(Filter[] filters,
                               String user,
                               Date time)
                        throws SQLException
Acknowledge with the given username and the given time all alarms that match the given filter criteria.

Throws:
SQLException

acknowledgeAll

public static void acknowledgeAll(String user)
                           throws SQLException
Acknowledge all unacknowledged alarms with the given username and the given time.

Throws:
SQLException

acknowledgeAll

public static void acknowledgeAll(String user,
                                  Date time)
                           throws SQLException
Acknowledge all unacknowledged alarms with the given username and the given time.

Throws:
SQLException

unacknowledge

public static void unacknowledge(Alarm[] alarms)
                          throws SQLException
Unacknowledge a list of alarms.

Throws:
SQLException

unacknowledge

public static void unacknowledge(int[] alarmIds)
                          throws SQLException
Unacknowledge a list of alarms.

Throws:
SQLException

unacknowledge

public static void unacknowledge(Filter[] filters)
                          throws SQLException
Unacknowledge alarms that match the given filter criteria.

Throws:
SQLException

unacknowledgeAll

public static void unacknowledgeAll()
                             throws SQLException
Unacknowledge all acknowledged alarms.

Throws:
SQLException

rs2Alarms

protected static Alarm[] rs2Alarms(ResultSet rs)
                            throws SQLException
Convenience method for translating a java.sql.ResultSet containing event information into an array of Alarm objects.

Throws:
SQLException

escalateAlarms

public static void escalateAlarms(int[] alarmIds,
                                  String user)
                           throws SQLException
Escalate a list of alarms using the given username and the current time

Throws:
SQLException

escalateAlarms

public static void escalateAlarms(int[] alarmIds,
                                  String user,
                                  Date time)
                           throws SQLException
Escalate a list of alarms. The username and time are currently discarded, but are required for future use.

Throws:
SQLException

clearAlarms

public static void clearAlarms(int[] alarmIds,
                               String user)
                        throws SQLException
Clear a list of alarms, using the given username and the current time

Throws:
SQLException

clearAlarms

public static void clearAlarms(int[] alarmIds,
                               String user,
                               Date time)
                        throws SQLException
Clear a list of alarms. The username and time are currently discarded, but are required for future use.

Throws:
SQLException


Copyright © 2009. All Rights Reserved.