use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.
the class ReadingsRepository method getReadingXmlDefinition.
public final FullReadingBean getReadingXmlDefinition(String readingName, Map<String, String> parameters) throws UnsupportedReadingException {
FullReadingBean reading = xmlRepository.getReadingDefinition(readingName);
reading.setId(String.valueOf(getNewUniqueId()));
reading.setParameters(parameters);
return reading;
}
use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.
the class SystemMonitor method scheduleSystemMonitoring.
/**
* Schedule some system monitors.
* <br>No statistics collection will be triggered until the startMonitor method is called.
*
* @param monitoredHost the host to monitor
* @param systemReadingTypes what kind of data to collect. Use some of the following constants:
* <ul>
* <li>SystemMonitor.MONITOR_CPU.*
* <li>SystemMonitor.MONITOR_MEMORY.*
* <li>SystemMonitor.MONITOR_VIRTUAL_MEMORY.*
* <li>SystemMonitor.MONITOR_IO.*
* <li>SystemMonitor.MONITOR_NETWORK_INTERFACES.*
* <li>SystemMonitor.MONITOR_NETSTAT.*
* <li>SystemMonitor.MONITOR_TCP.*
* </ul>
*/
@PublicAtsApi
public void scheduleSystemMonitoring(@Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost, @Validate(name = "systemReadingTypes", type = ValidationType.NOT_NULL) String[] systemReadingTypes) {
// validate input parameters
monitoredHost = HostUtils.getAtsAgentIpAndPort(monitoredHost);
new Validator().validateMethodParameters("Could not schedule monitoring system statistics on '" + monitoredHost + "'", new Object[] { monitoredHost, systemReadingTypes });
Set<FullReadingBean> readingTypes = requestedReadingTypesPerHosts.get(monitoredHost);
if (readingTypes == null) {
readingTypes = new HashSet<FullReadingBean>();
}
readingTypes.addAll(ReadingTypes.expandSystemReadings(systemReadingTypes));
requestedReadingTypesPerHosts.put(monitoredHost, readingTypes);
monitoredHosts.add(monitoredHost);
}
use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.
the class ReadingsRepository method getReadingXmlDefinitions.
public final List<FullReadingBean> getReadingXmlDefinitions(Set<String> readingNames) throws UnsupportedReadingException {
List<FullReadingBean> readingBeans = new ArrayList<FullReadingBean>();
for (String readingName : readingNames) {
FullReadingBean reading = xmlRepository.getReadingDefinition(readingName);
reading.setId(String.valueOf(getNewUniqueId()));
readingBeans.add(reading);
}
return readingBeans;
}
use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.
the class AtsSystemMonitor method init.
@Override
public void init(FullReadingBean[] readings) throws Exception {
log.info("Initializing the ATS System Monitor");
try {
this.sigarWrapper = new SigarWrapper();
} catch (SigarException e) {
log.error("Error initializing the Sigar System", e);
throw new Exception("Error initializing the Sigar System", e);
}
List<FullReadingBean> staticReadings = new ArrayList<FullReadingBean>();
List<FullReadingBean> dynamicReadings = new ArrayList<FullReadingBean>();
for (FullReadingBean reading : readings) {
if (!reading.isDynamicReading()) {
staticReadings.add(reading);
} else {
// check if this process has parent
String parentProcessName = reading.getParameter(SystemMonitorDefinitions.PARAMETER_NAME__PROCESS_PARENT_NAME);
if (parentProcessName != null) {
final String parentProcessId = parentProcessName + "-" + reading.getName();
if (!parentProcessReadingInstances.containsKey(parentProcessId)) {
parentProcessReadingInstances.put(parentProcessId, new ParentProcessReadingBean(reading.getId(), reading.getMonitorName(), parentProcessName, reading.getName(), reading.getUnit()));
}
}
dynamicReadings.add(reading);
}
}
ReadingInstancesFactory.init(sigarWrapper, getPollInterval());
// create the actual static reading instances
staticReadingInstances = ReadingInstancesFactory.createStaticReadingInstances(sigarWrapper, staticReadings);
// remember the initial dynamic readings
initialDynamicReadings = new ArrayList<FullReadingBean>(dynamicReadings);
// calculations on the first poll
if (initialDynamicReadings.size() > 0) {
dynamicReadingInstances = ReadingInstancesFactory.createOrUpdateDynamicReadingInstances(sigarWrapper, parentProcessReadingInstances, initialDynamicReadings, dynamicReadingInstances);
}
}
use of com.axway.ats.common.performance.monitor.beans.FullReadingBean in project ats-framework by Axway.
the class MatchedProcess method createOrUpdateDynamicReadingInstances.
public static List<ReadingInstance> createOrUpdateDynamicReadingInstances(SigarWrapper sigarWrapper, Map<String, ParentProcessReadingBean> parentProcessReadingInstances, List<FullReadingBean> initialReadings, List<ReadingInstance> currentReadingInstances) throws UnsupportedReadingException, SigarException {
// update the list of matching processes now, this must be done as quickly as possible
// as it happens prior to each polling
currentReadingInstances = updateProcessesMatchingMap(sigarWrapper.getSigarInstance(), initialReadings, currentReadingInstances);
List<ReadingInstance> readingInstances = new ArrayList<ReadingInstance>(currentReadingInstances);
for (FullReadingBean 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(sigarWrapper, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_KERNEL)) {
List<ReadingInstance> readingsList = getProcessCpuUsageRunningKernel(sigarWrapper, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_CPU__USAGE_TOTAL)) {
List<ReadingInstance> readingsList = getProcessCpuUsageRunningTotal(sigarWrapper, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__VIRTUAL)) {
List<ReadingInstance> readingsList = getProcessVirtualMemory(sigarWrapper, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__RESIDENT)) {
List<ReadingInstance> readingsList = getProcessResidentMemory(sigarWrapper, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__SHARED) && !IS_WINDOWS) {
List<ReadingInstance> readingsList = getProcessSharedMemory(sigarWrapper, reading, parentProcess);
readingInstances.addAll(readingsList);
} else if (readingName.equalsIgnoreCase(SystemMonitorDefinitions.READING_PROCESS_MEMORY__PAGE_FAULTS)) {
List<ReadingInstance> readingsList = getProcessMemoryPageFaults(sigarWrapper, 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