示例#1
0
  /**
   * We fill in the values for the alert in the composite data. Forming the composite data for each
   * alert and returning it
   */
  private CompositeData makeComData(Alert alert) {

    values = new Object[names.length];

    values[0] = alert.getSource();

    /*values[1] = alert.getOwnerName();
    if(values[1] == null)
    {
        values[1] = "NULL";//No I18N
    }*/

    values[1] = alert.getEntity();

    values[2] = new Integer(alert.getSeverity());

    values[3] = new Integer(alert.getPreviousSeverity());

    values[4] = new Long(alert.getCreateTime());

    values[5] = new Long(alert.getModTime());

    values[6] = alert.getCategory();

    values[7] = alert.getWho();
    if (values[7] == null) {
      values[7] = " "; // No I18N
    }

    values[8] = agentName.getPropValues(alert.getUserProperties(), agentName.alertUserPropNames);

    try {
      return new CompositeData(null, names, values);
    } catch (Exception e) {
      return null;
    }
  }
示例#2
0
  /**
   * Getting all the alerts in the NMS Alert table and using the alerts, forming the array of
   * CompositeData.Using the CompositeData forming the TabularData and returning the TabularData
   */
  TabularData getTable() {

    if (!agentName.initAlert()) return null;

    TabularData td = null;

    OpenMBeanParameterInfo[] parameterInfo = new OpenMBeanParameterInfo[names.length];

    String returnType = null;
    try {

      Class entryClassName = Class.forName(instrClassName);

      for (int i = 0; i < names.length; i++) {

        String methodName = "get" + names[i]; // No I18N

        Method method = entryClassName.getMethod(methodName, null);

        returnType = method.getReturnType().getName();

        parameterInfo[i] = new OpenMBeanParameterInfo(names[i], returnType, null, null, null);
      }
    } catch (Exception e) {
      agentName.agentErr.fail("Exception in getTable(): ", e); // No I18N
      return null;
    }

    try {

      int numalerts = agentName.alertAPI.getTotalAlertCount();

      CompositeData[] comps = new CompositeData[numalerts];

      int count = 0;

      Alert alert = null;

      String entity = ""; // No I18N

      String ownerName = ""; // No I18N

      while (true) {

        if (alert == null) {
          try {
            /**
             * getting the oldest/first alert in the database which has the least recent mod time
             */
            alert = agentName.alertAPI.getOldestModifiedAlert();
          } catch (Exception e) {
            agentName.agentErr.fail("exception ", e); // No I18N
          }
        } else {
          try {
            entity = alert.getEntity();

            ownerName = alert.getOwnerName();

            /** getting the next alert from the database using the modified time as criteria */
            if (ownerName != null)
              alert =
                  agentName.alertAPI.getNextAlertBasedOnModtime(
                      entity + "\t" + ownerName); // No I18N
            else alert = agentName.alertAPI.getNextAlertBasedOnModtime(entity);
          } catch (Exception e) {
            agentName.agentErr.fail("exception", e); // No I18N
          }
        }

        if (alert == null) break;

        comps[count++] = makeComData(alert);

        if (count == numalerts) break;
      } // end of while

      TabularParameterInfo tinfo =
          new TabularParameterInfo(null, null, null, null, null, parameterInfo, indexNames);

      td = new TabularData(tinfo, comps);
    } catch (Exception e) {
      agentName.agentErr.fail(" Exception in getTable(): ", e); // No I18N
    }

    return td;
  } // end of getTable