continue;
}
File pgData = new File(pgDataPath);
String configFilePath = getConfigFilePath(procInfo);
PostgresqlConfFile confFile = null;
if (!pgData.exists()) {
if (LOG.isDebugEnabled()) {
LOG.debug("PostgreSQL data directory ("
+ pgData
+ ") does not exist or is not readable. "
+ "Make sure the user the RHQ Agent is running as has read permissions on the directory and its parent directory.");
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("PostgreSQL data directory: " + pgData);
}
File postgresConfFile = (configFilePath != null) ? new File(configFilePath) : new File(pgData,
PostgresServerComponent.DEFAULT_CONFIG_FILE_NAME);
if (LOG.isDebugEnabled()) {
LOG.debug("PostgreSQL configuration file: " + postgresConfFile);
}
if (!postgresConfFile.exists()) {
LOG.warn("PostgreSQL configuration file (" + postgresConfFile + ") does not exist.");
} else {
try {
confFile = new PostgresqlConfFile(postgresConfFile);
} catch (IOException e) {
LOG.warn("Could not load PostgreSQL configuration file [" + postgresConfFile + "]: " + e);
}
}
}
Configuration pluginConfig = context.getDefaultPluginConfiguration();
pluginConfig.put(new PropertySimple(PGDATA_DIR_CONFIGURATION_PROPERTY, pgData));
pluginConfig.put(new PropertySimple(CONFIG_FILE_CONFIGURATION_PROPERTY, configFilePath));
if (confFile != null) {
String port = confFile.getPort();
if (port != null) {
// Override the default (5432) from the descriptor.
pluginConfig.put(new PropertySimple(PORT_CONFIGURATION_PROPERTY, port));
}
List<String> listenAddresses = confFile.getPropertyList("listen_addresses");
if (listenAddresses.size() > 0) {
String listenAddress = listenAddresses.get(0).trim();
if ("*".equals(listenAddress)) {
listenAddress = "127.0.0.1";
}