use of com.axway.ats.common.performance.monitor.beans.ReadingBean in project ats-framework by Axway.
the class MonitoringServiceImpl method scheduleCustomJvmMonitoring.
@POST
@Path("scheduleCustomJvmMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleCustomJvmMonitoring(@Context HttpServletRequest request, ScheduleCustomJvmMonitoringPojo 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.scheduleCustomJvmMonitoring(agent, monitoringPojo.getJmxPort(), monitoringPojo.getAlias(), monitoringPojo.getMbeanName(), monitoringPojo.getUnit(), monitoringPojo.getMbeanAttributes());
restSystemMonitor.setScheduledReadingTypes(readings);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
String statusMessage = "{\"status \": \"scheduled custom 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 scheduleProcessMonitoring.
@POST
@Path("scheduleProcessMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleProcessMonitoring(@Context HttpServletRequest request, ScheduleProcessMonitoringPojo 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.scheduleProcessMonitoring(agent, monitoringPojo.getProcessPattern(), monitoringPojo.getProcessAlias(), monitoringPojo.getProcessUsername(), monitoringPojo.getProcessReadingTypes());
restSystemMonitor.setScheduledReadingTypes(readings);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
String statusMessage = "{\"status \": \"scheduled process 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 scheduleChildProcessMonitoring.
@POST
@Path("scheduleChildProcessMonitoring")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response scheduleChildProcessMonitoring(@Context HttpServletRequest request, ScheduleProcessMonitoringPojo 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.scheduleChildProcessMonitoring(agent, monitoringPojo.getParentProcess(), monitoringPojo.getProcessPattern(), monitoringPojo.getProcessAlias(), monitoringPojo.getProcessUsername(), monitoringPojo.getProcessReadingTypes());
restSystemMonitor.setScheduledReadingTypes(readings);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
String statusMessage = "{\"status \": \"scheduled child process 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 DatabaseReadingsRepository method updateDatabaseRepository.
/**
* Populate these reading to the DB, so they have their own DB IDs
*
* @param monitoredHost
* @param readings
* @param readingIdToDbIdMap
* @throws DatabaseAccessException
*/
public void updateDatabaseRepository(String monitoredHost, List<ReadingBean> readings) throws DatabaseAccessException {
Logger log = LogManager.getLogger(DatabaseReadingsRepository.class);
String caller = ThreadsPerCaller.getCaller();
if (dbAccess == null) {
dbAccess = new DbAccessFactory().getNewDbWriteAccessObjectViaPassiveDbAppender(caller);
}
String dbConnectionHash = obtainDbConnectionHash(caller);
Map<String, Integer> knownReadingBeansForCurrentDbConn = knownReadingBeans.get(dbConnectionHash);
if (knownReadingBeansForCurrentDbConn == null) {
knownReadingBeansForCurrentDbConn = new HashMap<String, Integer>();
knownReadingBeans.put(dbConnectionHash, knownReadingBeansForCurrentDbConn);
}
for (ReadingBean reading : readings) {
// check if the current reading already was flagged as known
int dbId = getDbIdForReading(reading, knownReadingBeansForCurrentDbConn);
reading.setDbId(dbId);
if (reading.getDbId() == -1) {
StringBuilder newReadingParameters = new StringBuilder();
Map<String, String> readingParameters = reading.getParameters();
if (readingParameters != null && readingParameters.size() > 0) {
if (readingParameters.containsKey(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_ALIAS)) {
newReadingParameters.append("'");
newReadingParameters.append(readingParameters.get(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_ALIAS));
newReadingParameters.append("'_user pattern is '");
newReadingParameters.append(readingParameters.get(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_RECOGNITION_PATTERN));
newReadingParameters.append("'_reading=");
newReadingParameters.append(readingParameters.get(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_READING_ID));
newReadingParameters.append("_started by command '");
newReadingParameters.append(readingParameters.get(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_START_COMMAND));
newReadingParameters.append("'");
} else {
newReadingParameters.append(readingParameters.get(SystemMonitorDefinitions.PARAMETER_NAME__CUSTOM_MESSAGE));
}
}
int newReadingDatabaseId;
if (reading instanceof ParentProcessReadingBean) {
String thisProcessName = "[process] " + ((ParentProcessReadingBean) reading).getTheNameOfThisParentProcess();
String thisReadingName = thisProcessName + " - " + reading.getName();
newReadingDatabaseId = dbAccess.populateSystemStatisticDefinition(thisReadingName, reading.getParameter(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME), thisProcessName, reading.getUnit(), newReadingParameters.toString());
log.debug("DB id " + newReadingDatabaseId + " for parent process reading: " + thisReadingName);
} else {
String parentName = reading.getParameter(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME);
if (parentName != null) {
parentName = "[process] " + parentName;
}
newReadingDatabaseId = dbAccess.populateSystemStatisticDefinition(reading.getName(), parentName, "", reading.getUnit(), newReadingParameters.toString());
log.debug("DB id " + newReadingDatabaseId + " for reading: " + reading.getName());
}
// remember the DB ID of this reading
reading.setDbId(newReadingDatabaseId);
knownReadingBeansForCurrentDbConn.put(reading.getDescription(), reading.getDbId());
}
}
}
use of com.axway.ats.common.performance.monitor.beans.ReadingBean in project ats-framework by Axway.
the class MatchedProcess method createOrUpdateDynamicReadingInstances.
public static List<ReadingInstance> createOrUpdateDynamicReadingInstances(ISystemInformation systemInfo, Map<String, ParentProcessReadingBean> parentProcessReadingInstances, List<ReadingBean> initialReadings, List<ReadingInstance> currentReadingInstances) throws UnsupportedReadingException, SystemInformationException {
// update the list of matching processes now, this must be done as quickly as possible
// as it happens prior to each polling
currentReadingInstances = updateProcessesMatchingMap(systemInfo, initialReadings, currentReadingInstances);
List<ReadingInstance> readingInstances = new ArrayList<ReadingInstance>(currentReadingInstances);
for (ReadingBean reading : initialReadings) {
// the list of matching processes is ready, now create the reading instances
String readingName = reading.getName();
ParentProcessReadingBean parentProcess = null;
String parentProcessName = reading.getParameter(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME);
if (parentProcessName != null) {
parentProcess = parentProcessReadingInstances.get(parentProcessName + "-" + reading.getName());
}
/*
* the process monitoring methods are adding a reading identifier to the parameters
* like "reading=1", "reading=2" etc.
* These values are not important, but they must be unique as they are later used by
* the Test Explorer to map same processes monitored on different machines.
* Of course we can use a more descriptive values like "reading=CPU percent reading", but this will take
* some space on the database, and we know these values are never seen by the user.
*/
if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_USER)) {
List<ReadingInstance> readingsList = getProcessCpuUsageRunningUser(systemInfo, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_KERNEL)) {
List<ReadingInstance> readingsList = getProcessCpuUsageRunningKernel(systemInfo, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_TOTAL)) {
List<ReadingInstance> readingsList = getProcessCpuUsageRunningTotal(systemInfo, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__VIRTUAL)) {
List<ReadingInstance> readingsList = getProcessVirtualMemory(systemInfo, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__RESIDENT)) {
List<ReadingInstance> readingsList = getProcessResidentMemory(systemInfo, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__SHARED) && !IS_WINDOWS) {
List<ReadingInstance> readingsList = getProcessSharedMemory(systemInfo, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__PAGE_FAULTS)) {
List<ReadingInstance> readingsList = getProcessMemoryPageFaults(systemInfo, reading, parentProcess);
readingInstances.addAll(readingsList);
} else {
// We do nothing here as for example we do not support Shared Memory on windows
// throw new UnsupportedReadingException( readingName );
}
}
return readingInstances;
}
Aggregations