Search in sources :

Example 1 with MonitorResults

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

the class UserActivityLoggerTask method parseReadingsAndMoveToTempRepository.

/**
     * We cannot send a reading for a timestamp before we get it from all agents
     *
     * @param monitoredAgent
     * @param newResults
     */
private void parseReadingsAndMoveToTempRepository(String monitoredAgent, List<MonitorResults> newMonitorResults) {
    // counter for user info
    int resultsRead = 0;
    for (MonitorResults newMonitorResult : newMonitorResults) {
        // update the collect times for this loader
        Integer currentCollectTimes = this.collectTimesPerLoader.get(monitoredAgent);
        if (currentCollectTimes == null) {
            // this is the first time
            this.collectTimesPerLoader.put(monitoredAgent, 0);
        } else {
            // increment
            this.collectTimesPerLoader.put(monitoredAgent, currentCollectTimes + 1);
        }
        // assign DB IDs to these readings if needed
        List<BasicReadingBean> newReadings = newMonitorResult.getReadings();
        updateDatabaseRepository(monitoredAgent, newReadings);
        // Map<reading ID, reading value>
        Map<String, Integer> readingsMap = new HashMap<String, Integer>();
        for (BasicReadingBean newReading : newReadings) {
            readingsMap.put(newReading.getId(), Integer.valueOf(newReading.getValue()));
            resultsRead++;
        }
        // remember the readings info for later commit
        this.readingsTempStorage.addReadings(newMonitorResult.getTimestamp(), readingsMap);
    }
    log.debug("Successfully read " + resultsRead + " user activity results from " + monitoredAgent);
}
Also used : BasicReadingBean(com.axway.ats.common.performance.monitor.beans.BasicReadingBean) HashMap(java.util.HashMap) MonitorResults(com.axway.ats.common.performance.monitor.beans.MonitorResults)

Example 2 with MonitorResults

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

the class SystemStatsLoggerTask method run.

/* (non-Javadoc)
     * @see java.lang.Runnable#run()
     */
public void run() {
    log.debug("Getting system monitoring results for " + monitoredHost);
    try {
        InternalSystemMonitoringOperations sysMonitoringActions = new InternalSystemMonitoringOperations(monitoredHost);
        List<MonitorResults> monitorResults = sysMonitoringActions.getCollectedResults();
        if (monitorResults.size() > 0) {
            // update the DB definitions if needed
            for (MonitorResults monitorResult : monitorResults) {
                updateDatabaseRepository(monitoredHost, monitorResult.getReadings());
            }
            //log the results to the database
            int resultsAddeed = logResults(monitorResults);
            log.debug("Successfully sent " + resultsAddeed + " system monitoring results to the logging database");
        } else {
            log.warn("No new system monitoring results to log");
        }
    } catch (Exception e) {
        log.error("Could not log system monitoring results for " + monitoredHost + ". Will skip to next iteration", e);
    }
}
Also used : InternalSystemMonitoringOperations(com.axway.ats.agent.components.monitoring.operations.clients.InternalSystemMonitoringOperations) MonitorResults(com.axway.ats.common.performance.monitor.beans.MonitorResults) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) MonitoringException(com.axway.ats.monitoring.model.exceptions.MonitoringException)

Example 3 with MonitorResults

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

the class UserActivityLoggerTask method run.

/* (non-Javadoc)
     * @see java.lang.Runnable#run()
     */
public void run() {
    // read the user activity from all monitored Agents
    Iterator<String> monitoredAgentsIterator = monitoredAgents.iterator();
    while (monitoredAgentsIterator.hasNext()) {
        String monitoredAgent = monitoredAgentsIterator.next();
        log.debug("Getting user activity at " + monitoredAgent);
        try {
            List<MonitorResults> newResults = new AgentMonitoringClient(monitoredAgent).getMonitoringResults();
            if (newResults.size() > 0) {
                parseReadingsAndMoveToTempRepository(monitoredAgent, newResults);
            } else {
                log.warn("No new user activity on " + monitoredAgent);
            }
        } catch (Exception e) {
            log.error("Could not read user activity results for " + monitoredAgent + ". Will skip to next iteration", e);
        }
    }
    // send the consolidated user activity to the logging database
    int resultsAddeed = this.readingsTempStorage.commitToDatabase();
    log.debug("Successfully sent " + resultsAddeed + " user activity results to the logging database");
}
Also used : AgentMonitoringClient(com.axway.ats.agent.webapp.client.AgentMonitoringClient) MonitorResults(com.axway.ats.common.performance.monitor.beans.MonitorResults) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) MonitoringException(com.axway.ats.monitoring.model.exceptions.MonitoringException)

Aggregations

MonitorResults (com.axway.ats.common.performance.monitor.beans.MonitorResults)3 DatabaseAccessException (com.axway.ats.log.autodb.exceptions.DatabaseAccessException)2 MonitoringException (com.axway.ats.monitoring.model.exceptions.MonitoringException)2 InternalSystemMonitoringOperations (com.axway.ats.agent.components.monitoring.operations.clients.InternalSystemMonitoringOperations)1 AgentMonitoringClient (com.axway.ats.agent.webapp.client.AgentMonitoringClient)1 BasicReadingBean (com.axway.ats.common.performance.monitor.beans.BasicReadingBean)1 HashMap (java.util.HashMap)1