use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class MonitoringContext method init.
public void init() throws IOException {
if (!ReadingsRepository.getInstance().isConfigured()) {
log.info("Initializing the Monitoring library");
List<URL> configurationFileUrls = new ArrayList<>();
// 1. Load the configuration files
// find the default configuration
URL defaultConfigurationFileUrl = null;
if (this.getClass().getResource(DEFAULT_PERFORMANCE_CONFIGURATION) != null) {
URL fileURL = this.getClass().getResource(DEFAULT_PERFORMANCE_CONFIGURATION);
defaultConfigurationFileUrl = fileURL;
}
if (defaultConfigurationFileUrl != null) {
configurationFileUrls.add(defaultConfigurationFileUrl);
} else {
throw new MonitoringException("Unable to initialize the default monitoring service configuration: Unable to find the " + DEFAULT_PERFORMANCE_CONFIGURATION + " file.");
}
// find the custom configuration searched in the classpath
Enumeration<URL> customLinuxConfigurationURLs = this.getClass().getClassLoader().getResources(CUSTOM_PERFORMANCE_CONFIGURATION);
int counter = 0;
while (customLinuxConfigurationURLs.hasMoreElements()) {
counter++;
// .getPath()
configurationFileUrls.add(customLinuxConfigurationURLs.nextElement());
}
if (counter == 0) {
log.debug("No custom linux configuration detected. It is searched as a " + CUSTOM_PERFORMANCE_CONFIGURATION + " file in the classpath");
}
// 2. Parse the configuration files
ReadingsRepository.getInstance().loadConfigurations(configurationFileUrls);
log.info("Successfully initialized the Monitoring service");
}
}
use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class AgentSystemMonitor method initializeMonitoring.
public void initializeMonitoring(List<ReadingBean> readings, int pollInterval, long executorTimeOffset) {
monitoringAgent = new AtsSystemMonitoringAgent(pollInterval, executorTimeOffset);
if (pollInterval < 1) {
throw new MonitoringException("The interval for collecting statistical data must be at least 1 second. You have specified " + pollInterval + " seconds");
}
Map<String, List<ReadingBean>> readingsPerMonitor = new HashMap<String, List<ReadingBean>>();
// load all the monitors and initialize them
for (ReadingBean reading : readings) {
List<ReadingBean> readingsForThisMonitor = readingsPerMonitor.get(reading.getMonitorName());
if (readingsForThisMonitor == null) {
readingsForThisMonitor = new ArrayList<ReadingBean>();
readingsPerMonitor.put(reading.getMonitorName(), readingsForThisMonitor);
}
readingsForThisMonitor.add(reading);
}
for (String monitorClassName : readingsPerMonitor.keySet()) {
initializeMonitor(monitorClassName, readingsPerMonitor.get(monitorClassName), pollInterval);
}
}
use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class RestSystemMonitor method stopSystemMonitoringProcess.
private void stopSystemMonitoringProcess(String monitoredHost) throws MonitoringException {
log.debug("Stopping system monitoring on " + monitoredHost);
try {
systemMonitor.stopMonitoring();
log.debug("Successfully stopped system monitoring on " + monitoredHost);
} catch (Exception e) {
throw new MonitoringException("Could not stop the system monitoring process on " + monitoredHost, e);
}
}
use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class RestSystemMonitor method scheduleSystemMonitoring.
public Set<ReadingBean> scheduleSystemMonitoring(@Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost, @Validate(name = "systemReadingTypes", type = ValidationType.NOT_NULL) String[] systemReadingTypes) {
// validate input parameters
monitoredHost = HostUtils.getAtsAgentIpAndPort(monitoredHost);
new Validator().validateMethodParameters("Could not schedule monitoring system statistics on '" + monitoredHost + "'", new Object[] { monitoredHost, systemReadingTypes });
Set<ReadingBean> readingTypes = new HashSet<ReadingBean>();
try {
log.debug("Scheduling system monitoring...");
readingTypes.addAll(systemMonitor.scheduleSystemMonitoring(systemReadingTypes));
logSystemStatistics = true;
log.info("System monitoring scheduled.");
} catch (Exception e) {
log.error("Could not schedule system monitoring.", e);
throw new MonitoringException("Could not schedule system monitoring. Did you initialize the monitoring context?", e);
}
return readingTypes;
}
use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class RestSystemMonitor method scheduleJvmMonitoring.
public Set<ReadingBean> scheduleJvmMonitoring(@Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost, @Validate(name = "jvmPort", type = ValidationType.NUMBER_PORT_NUMBER) String jvmPort, @Validate(name = "alias", type = ValidationType.NOT_NULL) String alias, @Validate(name = "jvmReadingTypes", type = ValidationType.NOT_NULL) String[] jvmReadingTypes) {
// validate input parameters
monitoredHost = HostUtils.getAtsAgentIpAndPort(monitoredHost);
new Validator().validateMethodParameters("Could not schedule monitoring JVM statistics on '" + monitoredHost + "' at " + jvmPort + " port", new Object[] { monitoredHost, jvmPort, jvmReadingTypes });
Set<ReadingBean> readingTypes = new HashSet<ReadingBean>();
Map<String, String> readingParameters = new HashMap<String, String>();
readingParameters.put("JMX_PORT", jvmPort);
if (!StringUtils.isNullOrEmpty(alias)) {
readingParameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_ALIAS, alias);
}
for (String readingType : jvmReadingTypes) {
ReadingBean reading = null;
try {
log.debug("Scheduling JVM monitoring...");
reading = systemMonitor.scheduleJvmMonitoring(readingType, readingParameters);
logSystemStatistics = true;
log.info("JVM monitoring scheduled.");
} catch (Exception e) {
log.error("Could not schedule JVM monitoring.", e);
throw new MonitoringException("Could not schedule JVM monitoring. Did you initialize the monitoring context?", e);
}
readingTypes.add(reading);
}
return readingTypes;
}
Aggregations