Search in sources :

Example 1 with AgentMonitoringClient

use of com.axway.ats.agent.webapp.client.AgentMonitoringClient in project ats-framework by Axway.

the class SystemMonitor method startMonitoringAgent.

private List<MonitoringException> startMonitoringAgent() {
    List<MonitoringException> errors = new ArrayList<MonitoringException>();
    int numberAgents = 0;
    // iterate the monitored hosts
    Iterator<String> monitoredAgentsIterator = monitoredAgents.iterator();
    while (monitoredAgentsIterator.hasNext()) {
        numberAgents++;
        String monitoredAgent = monitoredAgentsIterator.next();
        log.debug("Starting ATS Agent monitoring on " + monitoredAgent);
        try {
            new AgentMonitoringClient(monitoredAgent).startMonitoring(startTimestamp, pollInterval);
        } catch (AgentException e) {
            errors.add(new MonitoringException("Could not start monitoring ATS Agent " + monitoredAgent, e));
        }
    }
    // Note that we use just 1 task for monitoring all agents
    if (numberAgents > 0 && errors.size() == 0) {
        log.debug("Starting the logging task for the agent monitoring");
        lastUserActivityLoggerTask = new UserActivityLoggerTask(monitoredAgents);
        ScheduledFuture<?> loggerTaskFuture = scheduler.scheduleAtFixedRate(lastUserActivityLoggerTask, loggingInterval, loggingInterval, TimeUnit.SECONDS);
        // put the task in the map
        loggerTasksPerHost.put(UserActivityLoggerTask.ATS_AGENT_HOSTS, loggerTaskFuture);
        log.info("User activity on " + Arrays.toString(monitoredAgents.toArray()) + " agent(s) will be monitored every " + loggingInterval + " seconds");
    }
    return errors;
}
Also used : AgentMonitoringClient(com.axway.ats.agent.webapp.client.AgentMonitoringClient) MonitoringException(com.axway.ats.monitoring.model.exceptions.MonitoringException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ArrayList(java.util.ArrayList) UserActivityLoggerTask(com.axway.ats.monitoring.model.UserActivityLoggerTask)

Example 2 with AgentMonitoringClient

use of com.axway.ats.agent.webapp.client.AgentMonitoringClient 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)

Example 3 with AgentMonitoringClient

use of com.axway.ats.agent.webapp.client.AgentMonitoringClient in project ats-framework by Axway.

the class SystemMonitor method stopMonitoringProcessOnAgent.

private void stopMonitoringProcessOnAgent(String monitoredAgent) throws MonitoringException {
    try {
        log.debug("Stopping system monitoring on " + monitoredAgent + " agent");
        new AgentMonitoringClient(monitoredAgent).stopMonitoring();
        log.debug("Successfully stopped monitoring " + monitoredAgent + " agent");
    } catch (AgentException e) {
        throw new MonitoringException("Could not stop monitoring " + monitoredAgent + " agent", e);
    }
}
Also used : AgentMonitoringClient(com.axway.ats.agent.webapp.client.AgentMonitoringClient) AgentException(com.axway.ats.agent.core.exceptions.AgentException) MonitoringException(com.axway.ats.monitoring.model.exceptions.MonitoringException)

Aggregations

AgentMonitoringClient (com.axway.ats.agent.webapp.client.AgentMonitoringClient)3 MonitoringException (com.axway.ats.monitoring.model.exceptions.MonitoringException)3 AgentException (com.axway.ats.agent.core.exceptions.AgentException)2 MonitorResults (com.axway.ats.common.performance.monitor.beans.MonitorResults)1 DatabaseAccessException (com.axway.ats.log.autodb.exceptions.DatabaseAccessException)1 UserActivityLoggerTask (com.axway.ats.monitoring.model.UserActivityLoggerTask)1 ArrayList (java.util.ArrayList)1