@Test
  @Transactional
  @JUnitTemporaryDatabase
  public void testCountMatchingAlarmsBySeverity() {
    AlarmCriteria criteria = new AlarmCriteria();
    int[] matchingAlarms =
        m_alarmRepo.countMatchingAlarmsBySeverity(AlarmUtil.getOnmsCriteria(criteria));

    assertEquals(8, matchingAlarms.length);

    // Make sure that the count is correct per severity
    assertEquals(0, matchingAlarms[OnmsSeverity.CLEARED.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.CRITICAL.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.INDETERMINATE.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.MINOR.getId()]);
    assertEquals(1, matchingAlarms[OnmsSeverity.NORMAL.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.WARNING.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.MAJOR.getId()]);
  }
Exemplo n.º 2
0
  @Override
  public String getStyle(Object itemId, Object propertyId) {
    if (propertyId == null) {
      StringBuffer retval = new StringBuffer();
      Integer severity = (Integer) m_table.getContainerProperty(itemId, "severityId").getValue();
      Property prop = m_table.getContainerProperty(itemId, "acknowledged");
      Boolean acknowledged = false;
      if (prop != null) {
        acknowledged = (Boolean) prop.getValue();
      }

      if (OnmsSeverity.CLEARED.getId() == severity) {
      } else if (OnmsSeverity.CRITICAL.getId() == severity) {
        retval.append("alarm-critical");
      } else if (OnmsSeverity.INDETERMINATE.getId() == severity) {
        retval.append("alarm-indeterminate");
      } else if (OnmsSeverity.MAJOR.getId() == severity) {
        retval.append("alarm-major");
      } else if (OnmsSeverity.MINOR.getId() == severity) {
        retval.append("alarm-minor");
      } else if (OnmsSeverity.NORMAL.getId() == severity) {
        retval.append("alarm-normal");
      } else if (OnmsSeverity.WARNING.getId() == severity) {
        retval.append("alarm-warning");
      }

      if (!acknowledged) {
        retval.append("-noack");
      }

      return retval.toString();
    } else if ("severity".equals(propertyId)) {
      return "bright";
    }
    return null;
  }
Exemplo n.º 3
0
 /**
  * Gets the trap event.
  *
  * @param trap the trap object
  * @param ueibase the UEI base
  * @return the trap event
  */
 protected Event getTrapEvent(Notification trap, String ueibase) {
   // Build default severity
   String severity = OnmsSeverity.INDETERMINATE.toString();
   severity = severity.substring(0, 1).toUpperCase() + severity.substring(1).toLowerCase();
   // Set the event's UEI, event-label, logmsg, severity, and descr
   Event evt = new Event();
   evt.setUei(getTrapEventUEI(trap, ueibase));
   evt.setEventLabel(getTrapEventLabel(trap));
   evt.setLogmsg(getTrapEventLogmsg(trap));
   evt.setSeverity(severity);
   evt.setDescr(getTrapEventDescr(trap));
   List<Varbindsdecode> decode = getTrapVarbindsDecode(trap);
   if (!decode.isEmpty()) {
     evt.setVarbindsdecode(decode);
   }
   evt.setMask(new Mask());
   // The "ID" mask element (trap enterprise)
   addMaskElement(evt, "id", getTrapEnterprise(trap));
   // The "generic" mask element: hard-wired to enterprise-specific(6)
   addMaskElement(evt, "generic", "6");
   // The "specific" mask element (trap specific-type)
   addMaskElement(evt, "specific", getTrapSpecificType(trap));
   return evt;
 }