Search in sources :

Example 1 with ParentProcessReadingBean

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

the class AtsSystemMonitor method doPoll.

public List<BasicReadingBean> doPoll(boolean isFirstTime) throws Exception {
    List<BasicReadingBean> redingsResult = new ArrayList<BasicReadingBean>();
    // clear the values from previous poll for all parent processes
    for (ParentProcessReadingBean parentProcessReading : parentProcessReadingInstances.values()) {
        parentProcessReading.resetValue();
    }
    // update the list of dynamic reading instances
    if (initialDynamicReadings.size() > 0) {
        dynamicReadingInstances = ReadingInstancesFactory.createOrUpdateDynamicReadingInstances(sigarWrapper, parentProcessReadingInstances, initialDynamicReadings, dynamicReadingInstances);
    }
    // refresh the Sigar's info
    this.sigarWrapper.refresh();
    // poll the static reading instances
    redingsResult.addAll(pollReadingInstances(staticReadingInstances));
    // poll the dynamic reading instances
    if (initialDynamicReadings.size() > 0) {
        redingsResult.addAll(pollReadingInstances(dynamicReadingInstances));
    }
    // add the parent process values
    redingsResult.addAll(pollParentProcessInstances(parentProcessReadingInstances.values()));
    return redingsResult;
}
Also used : ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) BasicReadingBean(com.axway.ats.common.performance.monitor.beans.BasicReadingBean) ArrayList(java.util.ArrayList)

Example 2 with ParentProcessReadingBean

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

the class AtsSystemMonitor method pollParentProcessInstances.

private List<BasicReadingBean> pollParentProcessInstances(Collection<ParentProcessReadingBean> parentProcessReadingInstances) {
    List<BasicReadingBean> redingsResult = new ArrayList<BasicReadingBean>();
    for (ParentProcessReadingBean readingInstance : parentProcessReadingInstances) {
        // get the collected value from all children
        float value = readingInstance.poll();
        BasicReadingBean newResult;
        if (readingInstance.isNewInstance()) {
            readingInstance.setNewInstanceFlag(false);
            // the Test Executor needs to be informed about this reading instance
            // we pass back a Full Reading Bean
            newResult = readingInstance.getNewCopy();
        } else {
            // the Test Executor is already aware we are collecting data about this reading instance
            newResult = new BasicReadingBean();
            newResult.setId(readingInstance.getId());
        }
        newResult.setValue(String.valueOf(value));
        redingsResult.add(newResult);
    }
    return redingsResult;
}
Also used : ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) BasicReadingBean(com.axway.ats.common.performance.monitor.beans.BasicReadingBean) ArrayList(java.util.ArrayList)

Example 3 with ParentProcessReadingBean

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

the class AtsSystemMonitor method pollParentProcessInstances.

private List<ReadingBean> pollParentProcessInstances(Collection<ParentProcessReadingBean> parentProcessReadingInstances) {
    List<ReadingBean> redingsResult = new ArrayList<ReadingBean>();
    for (ParentProcessReadingBean readingInstance : parentProcessReadingInstances) {
        // get the collected value from all children
        float value = readingInstance.poll();
        ReadingBean newResult = readingInstance.getNewCopy();
        newResult.setValue(String.valueOf(value));
        redingsResult.add(newResult);
    }
    return redingsResult;
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ArrayList(java.util.ArrayList)

Example 4 with ParentProcessReadingBean

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

the class AtsSystemMonitor method init.

@Override
public void init(ReadingBean[] readings) throws Exception {
    log.info("Initializing the ATS System Monitor");
    try {
        this.systemInfo = SystemInformationFactory.get();
    } catch (Exception e) {
        String errorMessage = "Error initializing the provider of system information. System monitoring will not work.";
        log.error(errorMessage, e);
        throw new SystemInformationException(errorMessage, e);
    }
    List<ReadingBean> staticReadings = new ArrayList<ReadingBean>();
    List<ReadingBean> dynamicReadings = new ArrayList<ReadingBean>();
    for (ReadingBean reading : readings) {
        if (!reading.isDynamicReading()) {
            staticReadings.add(reading);
        } else {
            // check if this process has a parent
            String parentProcessName = reading.getParameter(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME);
            if (parentProcessName != null) {
                final String parentProcessId = parentProcessName + "-" + reading.getName();
                if (!parentProcessReadingInstances.containsKey(parentProcessId)) {
                    ParentProcessReadingBean prentProcessBean = new ParentProcessReadingBean(reading.getId(), reading.getMonitorName(), parentProcessName, reading.getName(), reading.getUnit());
                    prentProcessBean.setParameters(reading.getParameters());
                    parentProcessReadingInstances.put(parentProcessId, prentProcessBean);
                }
            }
            dynamicReadings.add(reading);
        }
    }
    ReadingInstancesFactory.init(systemInfo, getPollInterval());
    // create the actual static reading instances
    staticReadingInstances = ReadingInstancesFactory.createStaticReadingInstances(systemInfo, staticReadings);
    // remember the initial dynamic readings
    initialDynamicReadings = new ArrayList<ReadingBean>(dynamicReadings);
    // calculations on the first poll
    if (initialDynamicReadings.size() > 0) {
        dynamicReadingInstances = ReadingInstancesFactory.createOrUpdateDynamicReadingInstances(systemInfo, parentProcessReadingInstances, initialDynamicReadings, dynamicReadingInstances);
    }
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ArrayList(java.util.ArrayList) SystemInformationException(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException) SystemInformationException(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)

Example 5 with ParentProcessReadingBean

use of com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean 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)

Aggregations

ParentProcessReadingBean (com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean)10 ArrayList (java.util.ArrayList)8 ReadingBean (com.axway.ats.common.performance.monitor.beans.ReadingBean)5 BasicReadingBean (com.axway.ats.common.performance.monitor.beans.BasicReadingBean)3 FullReadingBean (com.axway.ats.common.performance.monitor.beans.FullReadingBean)3 List (java.util.List)2 SystemInformationException (com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)1 DbAccessFactory (com.axway.ats.log.autodb.DbAccessFactory)1 DbAccessFactory (com.axway.ats.log.autodb.io.DbAccessFactory)1 Logger (org.apache.log4j.Logger)1 Logger (org.apache.logging.log4j.Logger)1 SigarException (org.hyperic.sigar.SigarException)1