示例#1
1
 private List getSegmentServices(Statement stmt, String instance) throws SQLException {
   List rtn = new ArrayList();
   ResultSet rs = null;
   try {
     // Discover tables
     rs = stmt.executeQuery(SEGMENT_QUERY);
     int segment_col = rs.findColumn("SEGMENT_NAME");
     int ts_col = rs.findColumn("TABLESPACE_NAME");
     while (rs.next()) {
       String segment = rs.getString(segment_col);
       String tablespace = rs.getString(ts_col);
       ServiceResource service = new ServiceResource();
       service.setType(this, SEGMENT);
       service.setServiceName(segment);
       service.setDescription("Segment in the " + instance + " database instance");
       ConfigResponse productConfig = new ConfigResponse();
       ConfigResponse metricConfig = new ConfigResponse();
       productConfig.setValue(OracleMeasurementPlugin.PROP_SEGMENT, segment);
       productConfig.setValue(OracleMeasurementPlugin.PROP_TABLESPACE, tablespace);
       service.setProductConfig(productConfig);
       service.setMeasurementConfig(metricConfig);
       service.setControlConfig();
       rtn.add(service);
     }
   } finally {
     DBUtil.closeResultSet(log, rs);
   }
   return rtn;
 }
示例#2
0
 private List getTablespaceServices(Statement stmt, String instance) throws SQLException {
   List rtn = new ArrayList();
   ResultSet rs = null;
   try {
     // Discover tablespaces
     rs = stmt.executeQuery(TABLESPACE_QUERY);
     int ts_col = rs.findColumn("TABLESPACE_NAME");
     while (rs.next()) {
       String tablespace = rs.getString(ts_col);
       ServiceResource service = new ServiceResource();
       service.setType(this, TABLESPACE);
       service.setServiceName(tablespace);
       service.setDescription("Tablespace on the " + instance + " database instance");
       ConfigResponse productConfig = new ConfigResponse();
       ConfigResponse metricConfig = new ConfigResponse();
       productConfig.setValue(OracleMeasurementPlugin.PROP_TABLESPACE, tablespace);
       service.setProductConfig(productConfig);
       service.setMeasurementConfig(metricConfig);
       ConfigResponse svcProps = new ConfigResponse();
       // 9i and 10g only
       if (!getTypeInfo().getVersion().equals(VERSION_8i)) {
         svcProps.setValue("block_size", rs.getString("BLOCK_SIZE"));
         svcProps.setValue("allocation_type", rs.getString("ALLOCATION_TYPE"));
         svcProps.setValue("space_management", rs.getString("SEGMENT_SPACE_MANAGEMENT"));
       }
       svcProps.setValue("contents", rs.getString("CONTENTS"));
       svcProps.setValue("logging", rs.getString("LOGGING"));
       service.setCustomProperties(svcProps);
       rtn.add(service);
     }
   } finally {
     DBUtil.closeResultSet(log, rs);
   }
   return rtn;
 }
示例#3
0
 private void setCustomProps(Statement stmt) throws SQLException {
   ResultSet rs = null;
   try {
     // Query for server inventory properties
     ConfigResponse props = new ConfigResponse();
     rs = stmt.executeQuery(VERSION_QUERY);
     if (rs != null && rs.next()) {
       String version = rs.getString(1);
       props.setValue("version", version);
     }
     setCustomProperties(props);
   } finally {
     DBUtil.closeResultSet(log, rs);
   }
 }
示例#4
0
  private List getUserServices(Statement stmt, String instance) throws SQLException {
    // Discover the user instances, for user instances to be
    // discovered, the user must be connected to the database.
    List rtn = new ArrayList();
    ResultSet rs = null;
    try {
      // Set server description
      setDescription("Oracle " + instance + " database instance");

      // Discover user instances
      ArrayList users = new ArrayList();
      rs = stmt.executeQuery(USER_QUERY);
      while (rs.next()) {
        String username = rs.getString(1);
        users.add(username);
      }
      rs.close();
      for (int i = 0; i < users.size(); i++) {
        String username = (String) users.get(i);
        ServiceResource service = new ServiceResource();
        service.setType(this, USER_INSTANCE);
        service.setServiceName(username);
        service.setDescription("User of the " + instance + " database instance");
        ConfigResponse productConfig = new ConfigResponse();
        ConfigResponse metricConfig = new ConfigResponse();
        productConfig.setValue(OracleMeasurementPlugin.PROP_USERNAME, username);
        service.setProductConfig(productConfig);
        service.setMeasurementConfig(metricConfig);
        // Query for service inventory properties
        rs = stmt.executeQuery(DBA_USER_QUERY + "'" + username + "'");
        if (rs != null && rs.next()) {
          ConfigResponse svcProps = new ConfigResponse();
          svcProps.setValue("status", rs.getString("ACCOUNT_STATUS"));
          svcProps.setValue("default_tablespace", rs.getString("DEFAULT_TABLESPACE"));
          svcProps.setValue("temp_tablespace", rs.getString("TEMPORARY_TABLESPACE"));
          service.setCustomProperties(svcProps);
        }
        rtn.add(service);
      }
    } finally {
      DBUtil.closeResultSet(log, rs);
    }
    return rtn;
  }