use of com.axway.ats.monitoring.model.exceptions.MonitoringException in project ats-framework by Axway.
the class SystemMonitor method stopMonitoringPhysicalHosts.
private boolean stopMonitoringPhysicalHosts(boolean getRemainingData) {
boolean successfulOperation = true;
// cancel the logging tasks
Iterator<String> loggerTasksIterator = monitoredHosts.iterator();
while (loggerTasksIterator.hasNext()) {
String monitoredHost = loggerTasksIterator.next();
log.debug("Stopping the logging task for the system monitoring on " + monitoredHost);
ScheduledFuture<?> loggerTaskFuture = loggerTasksPerHost.get(monitoredHost);
if (loggerTaskFuture != null) {
if (loggerTaskFuture.isCancelled()) {
throw new MonitoringException("Logging task for the system monitoring process on " + monitoredHost + " has been cancelled");
}
loggerTaskFuture.cancel(false);
try {
// log any remaining results by explicitly calling the task to get the results
if (getRemainingData) {
log.debug("Get any remaining monitoring results for " + monitoredHost);
AbstractLoggerTask loggerTask = new SystemStatsLoggerTask(monitoredHost);
loggerTask.run();
}
} catch (Exception e) {
successfulOperation = false;
log.error("Error getting final monitoring results for " + monitoredHost, e);
}
}
}
// stop the monitoring process
Iterator<String> monitoredHostsIterator = monitoredHosts.iterator();
while (monitoredHostsIterator.hasNext()) {
String monitoredHost = monitoredHostsIterator.next();
try {
stopSystemMonitoringProcess(monitoredHost);
} catch (MonitoringException e) {
successfulOperation = false;
log.error("Could not stop monitoring " + monitoredHost, e);
}
}
return successfulOperation;
}
use of com.axway.ats.monitoring.model.exceptions.MonitoringException in project ats-framework by Axway.
the class SystemMonitor method stopSystemMonitoringProcess.
private void stopSystemMonitoringProcess(String monitoredHost) throws MonitoringException {
log.debug("Stopping system monitoring on " + monitoredHost);
try {
InternalSystemMonitoringOperations sysMonitoringActions = new InternalSystemMonitoringOperations(monitoredHost);
sysMonitoringActions.stopMonitoring();
log.debug("Successfully stopped system monitoring on " + monitoredHost);
} catch (AgentException e) {
throw new MonitoringException("Could not stop the system monitoring process on " + monitoredHost, e);
}
}
use of com.axway.ats.monitoring.model.exceptions.MonitoringException in project ats-framework by Axway.
the class MonitoringContext method init.
public void init() {
if (!ReadingsRepository.getInstance().isConfigured()) {
log.info("Initializing the Monitoring library");
List<String> configurationFiles = new ArrayList<String>();
// 1. Load the configuration files
// find the default configuration
String defaultConfigurationFile = null;
if (this.getClass().getResource(DEFAULT_PERFORMANCE_CONFIGURATION) != null) {
defaultConfigurationFile = this.getClass().getResource(DEFAULT_PERFORMANCE_CONFIGURATION).getFile();
}
if (defaultConfigurationFile != null) {
configurationFiles.add(defaultConfigurationFile);
} else {
throw new MonitoringException("Unable to initialize the default monitoring service configuration: Unable to find the " + DEFAULT_PERFORMANCE_CONFIGURATION + " file. Do you have the Core Library in your classpath?");
}
// find the custom configuration searched in the classpath
URL customLinuxConfigurationURL = this.getClass().getResource("/" + CUSTOM_PERFORMANCE_CONFIGURATION);
if (customLinuxConfigurationURL != null) {
configurationFiles.add(customLinuxConfigurationURL.getPath());
} else {
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().loadConfigurarions(configurationFiles);
log.info("Successfully initialized the Monitoring service");
}
}
use of com.axway.ats.monitoring.model.exceptions.MonitoringException in project ats-framework by Axway.
the class ReadingTypes method expandProcessReadings.
/**
* @param processPattern the pattern to use in order to find the monitored process
* @param processAlias the alias this process will have into the database
* @param readingTypes the readings to collect
*
* @return a set of readings, if pass more than once the same reading it will be automatically mearged into one
*/
public static Set<FullReadingBean> expandProcessReadings(String parentProcess, String processPattern, String processAlias, String processUsername, String[] readingTypes) {
Set<String> readingNames = new HashSet<String>();
for (String readingType : readingTypes) {
if (readingType.equals(READING_PROCESS_CPU)) {
// expand all CPU
readingNames.addAll(SystemMonitorDefinitions.getAllProcessCpuReadings());
} else if (readingType.equals(READING_PROCESS_MEMORY)) {
// expand all MEMORY
readingNames.addAll(SystemMonitorDefinitions.getAllProcessMemoryReadings());
} else if (SystemMonitorDefinitions.isProcessReading(readingType)) {
// add this a known process reading
readingNames.add(readingType);
} else {
// unknown process reading
throw new MonitoringException("Unknown process monitor type " + readingType);
}
}
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME, parentProcess);
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_RECOGNITION_PATTERN, processPattern);
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_ALIAS, processAlias);
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_USERNAME, processUsername);
List<FullReadingBean> processReadingDefinitions = ReadingsRepository.getInstance().getReadingXmlDefinitions(readingNames);
for (FullReadingBean processReadingDefinition : processReadingDefinitions) {
processReadingDefinition.setParameters(parameters);
}
// return a set of reading beans
return new HashSet<FullReadingBean>(processReadingDefinitions);
}
use of com.axway.ats.monitoring.model.exceptions.MonitoringException in project ats-framework by Axway.
the class SystemMonitor method initializeSystemMonitoringProcess.
private void initializeSystemMonitoringProcess(String monitoredHost, Set<FullReadingBean> readings) throws MonitoringException {
log.debug("Initializing the system monitoring process on " + monitoredHost);
try {
InternalSystemMonitoringOperations sysMonitoringActions = new InternalSystemMonitoringOperations(monitoredHost);
sysMonitoringActions.initializeMonitoring(new ArrayList<FullReadingBean>(readings), startTimestamp, pollInterval);
} catch (AgentException e) {
throw new MonitoringException("Could not start the system monitoring process on " + monitoredHost + ". For more details check loader logs on that machine", e);
}
}
Aggregations