Search in sources :

Example 1 with MonitoringException

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

Example 2 with MonitoringException

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);
    }
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) HashMap(java.util.HashMap) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) ArrayList(java.util.ArrayList) List(java.util.List) AtsSystemMonitoringAgent(com.axway.ats.agent.core.monitoring.agents.AtsSystemMonitoringAgent)

Example 3 with MonitoringException

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

Example 4 with MonitoringException

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;
}
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 5 with MonitoringException

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;
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) 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)

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