Search in sources :

Example 6 with MonitoringException

use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.

the class RestSystemMonitor method startMonitoringAgent.

private List<MonitoringException> startMonitoringAgent(String monitoredAgent, long startTimestamp, int pollInterval) {
    List<MonitoringException> errors = new ArrayList<MonitoringException>();
    log.debug("Starting ATS Agent monitoring on " + monitoredAgent);
    UserActionsMonitoringAgent userActionsMonitoringAgent = UserActionsMonitoringAgent.getInstance(ThreadsPerCaller.getCaller());
    userActionsMonitoringAgent.setAgentAddress(monitoredAgent);
    userActionsMonitoringAgent.startMonitoring(startTimestamp, pollInterval);
    return errors;
}
Also used : MonitoringException(com.axway.ats.core.monitoring.MonitoringException) UserActionsMonitoringAgent(com.axway.ats.agent.core.monitoring.UserActionsMonitoringAgent) ArrayList(java.util.ArrayList)

Example 7 with MonitoringException

use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.

the class RestSystemMonitor method scheduleCustomJvmMonitoring.

public Set<ReadingBean> scheduleCustomJvmMonitoring(@Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost, @Validate(name = "jmxPort", type = ValidationType.NUMBER_PORT_NUMBER) String jmxPort, @Validate(name = "alias", type = ValidationType.NOT_NULL) String alias, @Validate(name = "mbeanName", type = ValidationType.NOT_NULL) String mbeanName, @Validate(name = "unit", type = ValidationType.NOT_NULL) String unit, @Validate(name = "mbeanAttributes", type = ValidationType.NOT_NULL) String... mbeanAttributes) {
    // validate input parameters
    monitoredHost = HostUtils.getAtsAgentIpAndPort(monitoredHost);
    Set<ReadingBean> readingTypes = new HashSet<ReadingBean>();
    Map<String, String> readingParameters = new LinkedHashMap<String, String>();
    readingParameters.put("JMX_PORT", jmxPort);
    readingParameters.put("MBEAN_NAME", mbeanName);
    if (!StringUtils.isNullOrEmpty(alias)) {
        readingParameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_ALIAS, alias);
    }
    // already existing map
    if (mbeanAttributes.length > 1) {
        for (String att : mbeanAttributes) {
            readingParameters.put(att, "");
        }
    }
    // the first element in the array is always the mbean name
    ReadingBean reading = new ReadingBean(ATS_JVM_MONITOR_CLASS_FULL_NAME, mbeanAttributes[0], unit);
    try {
        log.debug("Scheduling custom JVM monitoring...");
        int newReadingId = systemMonitor.scheduleCustomJvmMonitoring();
        reading.setDbId(newReadingId);
        logSystemStatistics = true;
        log.info("Custom JVM monitoring scheduled.");
    } catch (Exception e) {
        log.error("Could not schedule custom JVM monitoring.", e);
        throw new MonitoringException("Could not schedule custom JVM monitoring. Did you initialize the monitoring context?", e);
    }
    reading.setParameters(readingParameters);
    readingTypes.add(reading);
    return readingTypes;
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with MonitoringException

use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.

the class SystemMonitor method configureMonitoredHost.

private void configureMonitoredHost(String monitoredHost) {
    List<String> hosts = new ArrayList<>();
    hosts.add(monitoredHost);
    try {
        TestcaseStateListener.getInstance().onConfigureAtsAgents(hosts);
    } catch (Exception e) {
        throw new MonitoringException("Could not configure ATS monitoring host(s)/agent(s) at " + Arrays.toString(hosts.toArray(new String[hosts.size()])), e);
    }
}
Also used : MonitoringException(com.axway.ats.core.monitoring.MonitoringException) ArrayList(java.util.ArrayList) MonitoringException(com.axway.ats.core.monitoring.MonitoringException)

Example 9 with MonitoringException

use of com.axway.ats.core.monitoring.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<ReadingBean> expandProcessReadings(String parentProcess, String processPattern, String processAlias, String processUsername, String[] readingTypes) {
    Set<String> readingNames = new HashSet<String>();
    for (String readingType : readingTypes) {
        if (readingType.equals(SystemMonitorDefinitions.READING_PROCESS_CPU)) {
            // expand all CPU
            readingNames.addAll(SystemMonitorDefinitions.getAllProcessCpuReadings());
        } else if (readingType.equals(SystemMonitorDefinitions.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<ReadingBean> processReadingDefinitions = ReadingsRepository.getInstance().getReadingXmlDefinitions(readingNames);
    for (ReadingBean processReadingDefinition : processReadingDefinitions) {
        processReadingDefinition.setParameters(parameters);
    }
    // return a set of reading beans
    return new HashSet<ReadingBean>(processReadingDefinitions);
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) HashMap(java.util.HashMap) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) HashSet(java.util.HashSet)

Example 10 with MonitoringException

use of com.axway.ats.core.monitoring.MonitoringException in project ats-framework by Axway.

the class RestSystemMonitor method scheduleProcessMonitoring.

private Set<ReadingBean> scheduleProcessMonitoring(String monitoredHost, String parentProcess, String processPattern, String processAlias, String processUsername, String[] processReadingTypes) {
    Set<ReadingBean> readingTypes = new HashSet<ReadingBean>();
    try {
        log.debug("Scheduling process monitoring...");
        readingTypes.addAll(systemMonitor.scheduleProcessMonitoring(parentProcess, processPattern, processAlias, processUsername, processReadingTypes));
        logSystemStatistics = true;
        log.info("Process monitoring scheduled.");
        return readingTypes;
    } catch (Exception e) {
        log.error("Could not schedule process monioring.");
        throw new MonitoringException("Could not schedule process monioring. Did you initialize the monitoring context?", e);
    }
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) 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