Esempio n. 1
0
  public List getEntries(int startIndex, int endIndex) {
    // User code starts here
    if (agentName.initTopo()) {
      ArrayList arrayList = new ArrayList();
      int noOfObj = getCount();
      String[] name = {""}; // No I18N

      for (int i = 0; i < noOfObj; i++) {
        if (name[0].trim().equals("")) // No I18N
        {
          getFirstMo(name);
        } else {
          getNextMo(name);
        }

        if ((i + 1 >= startIndex) && (i + 1 <= endIndex)) {
          Object[] indx = new Object[] {name[0]};
          arrayList.add(indx);
          if (i + 1 == endIndex) break;
        }
      }
      return arrayList;
    }

    // User code ends here
    return null;
  }
Esempio n. 2
0
 public int totalRows() {
   // User code starts here
   if (agentName.initTopo()) {
     return getCount();
   }
   return 0;
   // User code ends here
 }
Esempio n. 3
0
 public CompositeData getNextEntry(Object[] indexObjects) {
   // User code starts here
   if (!agentName.initTopo()) {
     return null;
   }
   String[] name = {(String) indexObjects[0]};
   return getNextMo(name);
   // User code ends here
 }
Esempio n. 4
0
  public CompositeData getCompData(Network net, String moName) {
    values = new Object[names.length];
    try {
      values[0] = moName;
      if (net.getDiscover()) {
        values[1] = "true"; // No I18N
      } else {
        values[1] = "false"; // No I18N
      }
      values[2] = new Integer(net.getDiscoveryStatus());
      String oid = agentName.getChildTableOID(net.getClassname(), this.className);
      values[3] = oid;
      values[4] = agentName.getChildTableName(oid);
      return new CompositeData(null, names, values);

    } catch (Exception e) {
      return null;
    }
  }
Esempio n. 5
0
  public CompositeData getFirstEntry() {
    // User code starts here
    if (!agentName.initTopo()) {
      return null;
    }

    String[] name = {""}; // No I18N
    return getFirstMo(name);
    // User code ends here
  }
  /**
   * Handles the JMX Set Request for alertExtraPropNames
   *
   * @param String
   * @throws AgentException on error
   */
  public synchronized void setAlertExtraPropNames(String value) throws AgentException {
    // Fill up the stub with required processing

    if (value == null) throw new AgentException("", CommonUtils.WRONGVALUE); // No I18N
    if (!(((value.length() >= 0) && (value.length() <= 255))))
      throw new AgentException("", CommonUtils.WRONGLENGTH); // No I18N
    // User code starts here
    /*

    alertExtraPropNames = value;
    */
    if ((value.length() < 0) || (value.length() > 255))
      throw new AgentException("", CommonUtils.BADVALUE); // No I18N
    /** checking if the syntax is correct for the extra property names, if not throwing exception */
    if (!agentRef.syntaxOK(value)) throw new AgentException("", CommonUtils.BADVALUE); // No I18N
    agentRef.alertExtraPropNames = value;
    alertExtraPropNames = agentRef.alertExtraPropNames;
    /** storing the extra property names in the database */
    agentRef.updateDefValue("alertExtraPropNames", value); // No I18N
    // User code ends here
  }
Esempio n. 7
0
  public int totalRows() {

    // User code starts here
    /*
    return -1;
    */
    if (agentName.initAlert()) {
      try {
        return agentName.alertAPI.getTotalAlertCount();
      } catch (Exception e) {
        return 0;
      }
    }

    return 0;
    // User code ends here
    // return -1;
  }
Esempio n. 8
0
  public CompositeData getNextEntry(Object[] indexObjects) {

    // User code starts here
    if (!agentName.initAlert()) return null;

    String previousKeys[] = {indexObjects[0].toString(), indexObjects[1].toString()};
    String keys[] = getNextAlert(previousKeys);

    if (keys == null) return null;

    String source = keys[0];

    // String ownerName = keys[1];

    String entity = keys[1];

    Alert alert1 = new Alert();

    alert1.setSource(source);

    //	alert1.setOwnerName(ownerName);

    alert1.setEntity(entity);

    Alert alert2 = new Alert();

    alert2.setModTime(System.currentTimeMillis());

    Vector alerts = null;

    try {
      alerts = agentName.alertAPI.getAlerts(alert1, alert2);

      if (alerts != null) return makeComData((Alert) alerts.elementAt(0));
    } catch (Exception e) {
      return null;
    }

    // User code ends here
    return null;
  }
Esempio n. 9
0
  public List getEntries(int startIndex, int endIndex) {

    // User code starts here
    /*
    return null;
    */
    if (!agentName.initAlert()) return null;

    ArrayList arrayList = new ArrayList();

    boolean firstAlert = true;

    String[] keys = null;

    int totalAlerts = totalRows();

    for (int i = 0; i < totalAlerts; i++) {
      if (firstAlert) {
        firstAlert = false;

        keys = getFirstAlert();
      } else keys = getNextAlert(keys);

      // Checking the range
      if ((i + 1 >= startIndex) && (i + 1 <= endIndex)) {
        Object[] index = new Object[] {keys[0], keys[1]};

        arrayList.add(index);
      }

      // checking if the upper limit is exceeded, if so break
      if (i + 1 == endIndex) break;
    }

    return arrayList;
    // User code ends here
    //	return null;
  }
Esempio n. 10
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;
    }
  }
Esempio n. 11
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