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;
}
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");
}
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);
}
}
Aggregations