use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class RestSystemMonitor method scheduleMonitoring.
public Set<ReadingBean> scheduleMonitoring(@Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost, @Validate(name = "readingType", type = ValidationType.STRING_NOT_EMPTY) String readingType, @Validate(name = "readingParameters", type = ValidationType.NOT_NULL) Map<String, String> readingParameters) {
// validate input parameters
monitoredHost = HostUtils.getAtsAgentIpAndPort(monitoredHost);
new Validator().validateMethodParameters("Could not schedule monitoring a statistic on '" + monitoredHost + "'", new Object[] { monitoredHost, readingType, readingParameters });
Set<ReadingBean> readingTypes = new HashSet<ReadingBean>();
Set<String> readingNames = new HashSet<String>();
readingNames.add(readingType);
ReadingBean reading = null;
try {
log.debug("Scheduling monitoring...");
reading = systemMonitor.scheduleMonitoring(readingType, readingParameters);
logSystemStatistics = true;
log.info("Monitoring scheduled.");
} catch (Exception e) {
log.error("Could not schedule monitoring.", e);
throw new MonitoringException("Could not schedule monitoring. Did you initialize the monitoring context?", e);
}
readingTypes.add(reading);
return readingTypes;
}
use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class RestSystemMonitor method startMonitoring.
public void startMonitoring(String monitoredHost, long startTimestamp, int pollInterval, long executorTimeOffset) {
if (isStarted) {
throw new MonitoringException("System monitoring is already started from this caller on this agent.");
}
if (logSystemStatistics) {
List<MonitoringException> errorsStartingMonitoringPhysicalHost = startMonitoringPhysicalHost(monitoredHost, pollInterval, executorTimeOffset);
if (errorsStartingMonitoringPhysicalHost.size() > 0) {
for (MonitoringException e : errorsStartingMonitoringPhysicalHost) {
log.error("The following error occured while starting the system monitoring process", e);
}
cancelAnyMonitoringActivity(ThreadsPerCaller.getCaller());
// clear the readings because an error occurred
this.readingTypes.clear();
throw new MonitoringException("There were error starting the system monitoring process");
}
}
if (logUserActivity) {
List<MonitoringException> errorsStartingMonitoringAgent = startMonitoringAgent(monitoredHost, startTimestamp, pollInterval);
if (errorsStartingMonitoringAgent.size() > 0) {
for (MonitoringException e : errorsStartingMonitoringAgent) {
log.error("The following error occured while starting the monitoring process on ATS Agent", e);
}
cancelAnyMonitoringActivity(ThreadsPerCaller.getCaller());
// clear the readings because an error occurred
this.readingTypes.clear();
throw new MonitoringException("There were errors starting the monitoring process on ATS Agent");
}
}
isStarted = true;
}
use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.
the class RestSystemMonitor method startMonitoringPhysicalHost.
private List<MonitoringException> startMonitoringPhysicalHost(String monitoredHost, int pollingInterval, long executorTimeOffset) {
List<MonitoringException> errors = new ArrayList<MonitoringException>();
// initialize the monitoring processes
log.debug("Initializing system monitoring on " + monitoredHost);
final String ERR_MSG = "Could not initialize monitoring " + monitoredHost + ". ";
if (this.readingTypes == null || this.readingTypes.size() == 0) {
errors.add(new MonitoringException(ERR_MSG + " as no monitor types are provided"));
}
try {
initializeSystemMonitoringProcess(monitoredHost, pollingInterval, executorTimeOffset);
} catch (MonitoringException e) {
errors.add(e);
}
log.info("Successfully initialized monitoring " + monitoredHost);
// run the monitoring processes
log.debug("Starting system monitoring on " + monitoredHost);
try {
startSystemMonitoringProcess(monitoredHost);
} catch (MonitoringException e) {
errors.add(e);
}
log.info("Successfully started monitoring " + monitoredHost + ".");
return errors;
}
Aggregations