Search in sources :

Example 6 with FullReadingBean

use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.

the class ReadingsRepository method getReadingXmlDefinition.

public final FullReadingBean getReadingXmlDefinition(String readingName, Map<String, String> parameters) throws UnsupportedReadingException {
    FullReadingBean reading = xmlRepository.getReadingDefinition(readingName);
    reading.setId(String.valueOf(getNewUniqueId()));
    reading.setParameters(parameters);
    return reading;
}
Also used : FullReadingBean(com.axway.ats.common.performance.monitor.beans.FullReadingBean)

Example 7 with FullReadingBean

use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.

the class SystemMonitor method scheduleSystemMonitoring.

/**
     * Schedule some system monitors.
     * <br>No statistics collection will be triggered until the startMonitor method is called.
     *
     * @param monitoredHost the host to monitor
     * @param systemReadingTypes what kind of data to collect. Use some of the following constants:
     * <ul>
     * <li>SystemMonitor.MONITOR_CPU.*
     * <li>SystemMonitor.MONITOR_MEMORY.*
     * <li>SystemMonitor.MONITOR_VIRTUAL_MEMORY.*
     * <li>SystemMonitor.MONITOR_IO.*
     * <li>SystemMonitor.MONITOR_NETWORK_INTERFACES.*
     * <li>SystemMonitor.MONITOR_NETSTAT.*
     * <li>SystemMonitor.MONITOR_TCP.*
     * </ul>
     */
@PublicAtsApi
public void 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<FullReadingBean> readingTypes = requestedReadingTypesPerHosts.get(monitoredHost);
    if (readingTypes == null) {
        readingTypes = new HashSet<FullReadingBean>();
    }
    readingTypes.addAll(ReadingTypes.expandSystemReadings(systemReadingTypes));
    requestedReadingTypesPerHosts.put(monitoredHost, readingTypes);
    monitoredHosts.add(monitoredHost);
}
Also used : FullReadingBean(com.axway.ats.common.performance.monitor.beans.FullReadingBean) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 8 with FullReadingBean

use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.

the class ReadingsRepository method getReadingXmlDefinitions.

public final List<FullReadingBean> getReadingXmlDefinitions(Set<String> readingNames) throws UnsupportedReadingException {
    List<FullReadingBean> readingBeans = new ArrayList<FullReadingBean>();
    for (String readingName : readingNames) {
        FullReadingBean reading = xmlRepository.getReadingDefinition(readingName);
        reading.setId(String.valueOf(getNewUniqueId()));
        readingBeans.add(reading);
    }
    return readingBeans;
}
Also used : ArrayList(java.util.ArrayList) FullReadingBean(com.axway.ats.common.performance.monitor.beans.FullReadingBean)

Example 9 with FullReadingBean

use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.

the class AtsSystemMonitor method init.

@Override
public void init(FullReadingBean[] readings) throws Exception {
    log.info("Initializing the ATS System Monitor");
    try {
        this.sigarWrapper = new SigarWrapper();
    } catch (SigarException e) {
        log.error("Error initializing the Sigar System", e);
        throw new Exception("Error initializing the Sigar System", e);
    }
    List<FullReadingBean> staticReadings = new ArrayList<FullReadingBean>();
    List<FullReadingBean> dynamicReadings = new ArrayList<FullReadingBean>();
    for (FullReadingBean reading : readings) {
        if (!reading.isDynamicReading()) {
            staticReadings.add(reading);
        } else {
            // check if this process has parent
            String parentProcessName = reading.getParameter(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME);
            if (parentProcessName != null) {
                final String parentProcessId = parentProcessName + "-" + reading.getName();
                if (!parentProcessReadingInstances.containsKey(parentProcessId)) {
                    parentProcessReadingInstances.put(parentProcessId, new ParentProcessReadingBean(reading.getId(), reading.getMonitorName(), parentProcessName, reading.getName(), reading.getUnit()));
                }
            }
            dynamicReadings.add(reading);
        }
    }
    ReadingInstancesFactory.init(sigarWrapper, getPollInterval());
    // create the actual static reading instances
    staticReadingInstances = ReadingInstancesFactory.createStaticReadingInstances(sigarWrapper, staticReadings);
    // remember the initial dynamic readings
    initialDynamicReadings = new ArrayList<FullReadingBean>(dynamicReadings);
    // calculations on the first poll
    if (initialDynamicReadings.size() > 0) {
        dynamicReadingInstances = ReadingInstancesFactory.createOrUpdateDynamicReadingInstances(sigarWrapper, parentProcessReadingInstances, initialDynamicReadings, dynamicReadingInstances);
    }
}
Also used : SigarException(org.hyperic.sigar.SigarException) ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ArrayList(java.util.ArrayList) FullReadingBean(com.axway.ats.common.performance.monitor.beans.FullReadingBean) SigarException(org.hyperic.sigar.SigarException)

Example 10 with FullReadingBean

use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.

the class MatchedProcess method createOrUpdateDynamicReadingInstances.

public static List<ReadingInstance> createOrUpdateDynamicReadingInstances(SigarWrapper sigarWrapper, Map<String, ParentProcessReadingBean> parentProcessReadingInstances, List<FullReadingBean> initialReadings, List<ReadingInstance> currentReadingInstances) throws UnsupportedReadingException, SigarException {
    // update the list of matching processes now, this must be done as quickly as possible
    // as it happens prior to each polling
    currentReadingInstances = updateProcessesMatchingMap(sigarWrapper.getSigarInstance(), initialReadings, currentReadingInstances);
    List<ReadingInstance> readingInstances = new ArrayList<ReadingInstance>(currentReadingInstances);
    for (FullReadingBean reading : initialReadings) {
        // the list of matching processes is ready, now create the reading instances
        String readingName = reading.getName();
        ParentProcessReadingBean parentProcess = null;
        String parentProcessName = reading.getParameter(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME);
        if (parentProcessName != null) {
            parentProcess = parentProcessReadingInstances.get(parentProcessName + "-" + reading.getName());
        }
        /*
             * the process monitoring methods are adding a reading identifier to the parameters
             * like "reading=1", "reading=2" etc.
             * These values are not important, but they must be unique as they are later used by
             * the Test Explorer to map same processes monitored on different machines.
             * Of course we can use a more descriptive values like "reading=CPU percent reading", but this will take
             * some space on the database, and we know these values are never seen by the user.
             */
        if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_USER)) {
            List<ReadingInstance> readingsList = getProcessCpuUsageRunningUser(sigarWrapper, reading, parentProcess);
            readingInstances.addAll(readingsList);
        } else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_KERNEL)) {
            List<ReadingInstance> readingsList = getProcessCpuUsageRunningKernel(sigarWrapper, reading, parentProcess);
            readingInstances.addAll(readingsList);
        } else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_TOTAL)) {
            List<ReadingInstance> readingsList = getProcessCpuUsageRunningTotal(sigarWrapper, reading, parentProcess);
            readingInstances.addAll(readingsList);
        } else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__VIRTUAL)) {
            List<ReadingInstance> readingsList = getProcessVirtualMemory(sigarWrapper, reading, parentProcess);
            readingInstances.addAll(readingsList);
        } else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__RESIDENT)) {
            List<ReadingInstance> readingsList = getProcessResidentMemory(sigarWrapper, reading, parentProcess);
            readingInstances.addAll(readingsList);
        } else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__SHARED) && !IS_WINDOWS) {
            List<ReadingInstance> readingsList = getProcessSharedMemory(sigarWrapper, reading, parentProcess);
            readingInstances.addAll(readingsList);
        } else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__PAGE_FAULTS)) {
            List<ReadingInstance> readingsList = getProcessMemoryPageFaults(sigarWrapper, reading, parentProcess);
            readingInstances.addAll(readingsList);
        } else {
        // We do nothing here as for example we do not support Shared Memory on windows
        // throw new UnsupportedReadingException( readingName );
        }
    }
    return readingInstances;
}
Also used : ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FullReadingBean(com.axway.ats.common.performance.monitor.beans.FullReadingBean)

Aggregations

FullReadingBean (com.axway.ats.common.performance.monitor.beans.FullReadingBean)18 ArrayList (java.util.ArrayList)7 PublicAtsApi (com.axway.ats.common.PublicAtsApi)4 HashMap (java.util.HashMap)4 ParentProcessReadingBean (com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean)3 Validator (com.axway.ats.core.validation.Validator)3 MonitoringException (com.axway.ats.monitoring.model.exceptions.MonitoringException)3 HashSet (java.util.HashSet)3 UnsupportedReadingException (com.axway.ats.agent.components.monitoring.model.exceptions.UnsupportedReadingException)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 SigarException (org.hyperic.sigar.SigarException)2 AtsSystemMonitoringAgent (com.axway.ats.agent.components.monitoring.model.agents.AtsSystemMonitoringAgent)1 MonitorConfigurationException (com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException)1 InternalSystemMonitoringOperations (com.axway.ats.agent.components.monitoring.operations.clients.InternalSystemMonitoringOperations)1 AgentException (com.axway.ats.agent.core.exceptions.AgentException)1 Action (com.axway.ats.agent.core.model.Action)1 PerformanceMonitor (com.axway.ats.common.performance.monitor.PerformanceMonitor)1 BasicReadingBean (com.axway.ats.common.performance.monitor.beans.BasicReadingBean)1 DbAccessFactory (com.axway.ats.log.autodb.DbAccessFactory)1