use of com.axway.ats.common.performance.monitor.beans.ReadingBean in project ats-framework by Axway.
the class ReadingsRepository method getReadingXmlDefinitions.
public final List<ReadingBean> getReadingXmlDefinitions(Set<String> readingNames) throws UnsupportedReadingException {
List<ReadingBean> readingBeans = new ArrayList<ReadingBean>();
for (String readingName : readingNames) {
ReadingBean reading = xmlRepository.getReadingDefinition(readingName);
reading.setId(getNewUniqueId());
readingBeans.add(reading);
}
return readingBeans;
}
use of com.axway.ats.common.performance.monitor.beans.ReadingBean in project ats-framework by Axway.
the class AtsSystemMonitor method doPoll.
public List<ReadingBean> doPoll(boolean isFirstTime) throws Exception {
List<ReadingBean> redingsResult = new ArrayList<ReadingBean>();
// 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(systemInfo, parentProcessReadingInstances, initialDynamicReadings, dynamicReadingInstances);
}
this.systemInfo.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;
}
use of com.axway.ats.common.performance.monitor.beans.ReadingBean in project ats-framework by Axway.
the class ReadingTypes method expandProcessReadings.
/**
* @param processPattern the pattern to use in order to find the monitored process
* @param processAlias the alias this process will have into the database
* @param readingTypes the readings to collect
*
* @return a set of readings, if pass more than once the same reading it will be automatically mearged into one
*/
public static Set<ReadingBean> expandProcessReadings(String parentProcess, String processPattern, String processAlias, String processUsername, String[] readingTypes) {
Set<String> readingNames = new HashSet<String>();
for (String readingType : readingTypes) {
if (readingType.equals(SystemMonitorDefinitions.READING_PROCESS_CPU)) {
// expand all CPU
readingNames.addAll(SystemMonitorDefinitions.getAllProcessCpuReadings());
} else if (readingType.equals(SystemMonitorDefinitions.READING_PROCESS_MEMORY)) {
// expand all MEMORY
readingNames.addAll(SystemMonitorDefinitions.getAllProcessMemoryReadings());
} else if (SystemMonitorDefinitions.isProcessReading(readingType)) {
// add this a known process reading
readingNames.add(readingType);
} else {
// unknown process reading
throw new MonitoringException("Unknown process monitor type " + readingType);
}
}
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME, parentProcess);
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_RECOGNITION_PATTERN, processPattern);
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_ALIAS, processAlias);
parameters.put(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_USERNAME, processUsername);
List<ReadingBean> processReadingDefinitions = ReadingsRepository.getInstance().getReadingXmlDefinitions(readingNames);
for (ReadingBean processReadingDefinition : processReadingDefinitions) {
processReadingDefinition.setParameters(parameters);
}
// return a set of reading beans
return new HashSet<ReadingBean>(processReadingDefinitions);
}
use of com.axway.ats.common.performance.monitor.beans.ReadingBean in project ats-framework by Axway.
the class MonitoringServiceImpl method scheduleJvmMonitoring.
@POST
@Path("scheduleJvmMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleJvmMonitoring(@Context HttpServletRequest request, ScheduleJvmMonitoringPojo monitoringPojo) {
final String caller = getCaller(request, monitoringPojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, monitoringPojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
Set<ReadingBean> readings = restSystemMonitor.scheduleJvmMonitoring(agent, monitoringPojo.getJvmPort(), (monitoringPojo.getAlias() == null) ? "" : monitoringPojo.getAlias(), monitoringPojo.getJvmReadingTypes());
restSystemMonitor.setScheduledReadingTypes(readings);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
String statusMessage = "{\"status \": \"scheduled JVM monitoring with parameters '" + monitoringPojo.toString() + "'\"}";
return Response.ok(statusMessage).build();
}
use of com.axway.ats.common.performance.monitor.beans.ReadingBean in project ats-framework by Axway.
the class MonitoringServiceImpl method scheduleSystemMonitoring.
@POST
@Path("scheduleSystemMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleSystemMonitoring(@Context HttpServletRequest request, ScheduleSystemMonitoringPojo monitoringPojo) {
final String caller = getCaller(request, monitoringPojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, monitoringPojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
Set<ReadingBean> readings = restSystemMonitor.scheduleSystemMonitoring(agent, monitoringPojo.getReadings());
restSystemMonitor.setScheduledReadingTypes(readings);
return Response.ok("{\"status\":\"scheduled system monitoring for readings '" + Arrays.toString(monitoringPojo.getReadings()) + "'\"}").build();
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
}
Aggregations