Search in sources :

Example 11 with MonitoringException

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;
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) Validator(com.axway.ats.core.validation.Validator) MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) HashSet(java.util.HashSet)

Example 12 with MonitoringException

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;
}
Also used : MonitoringException(com.axway.ats.core.monitoring.MonitoringException)

Example 13 with MonitoringException

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;
}
Also used : MonitoringException(com.axway.ats.core.monitoring.MonitoringException) ArrayList(java.util.ArrayList)

Aggregations

MonitoringException (com.axway.ats.core.monitoring.MonitoringException)13 ReadingBean (com.axway.ats.common.performance.monitor.beans.ReadingBean)7 MonitorConfigurationException (com.axway.ats.core.monitoring.MonitorConfigurationException)6 HashSet (java.util.HashSet)6 ArrayList (java.util.ArrayList)5 Validator (com.axway.ats.core.validation.Validator)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)2 UserActionsMonitoringAgent (com.axway.ats.agent.core.monitoring.UserActionsMonitoringAgent)1 AtsSystemMonitoringAgent (com.axway.ats.agent.core.monitoring.agents.AtsSystemMonitoringAgent)1 URL (java.net.URL)1 List (java.util.List)1