Search in sources :

Example 21 with ReadingBean

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;
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ArrayList(java.util.ArrayList)

Example 22 with ReadingBean

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;
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ParentProcessReadingBean(com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean) ArrayList(java.util.ArrayList)

Example 23 with ReadingBean

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);
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) HashMap(java.util.HashMap) MonitoringException(com.axway.ats.core.monitoring.MonitoringException) HashSet(java.util.HashSet)

Example 24 with ReadingBean

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();
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ErrorPojo(com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo) SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 25 with ReadingBean

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();
    }
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) ErrorPojo(com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo) SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

ReadingBean (com.axway.ats.common.performance.monitor.beans.ReadingBean)30 ArrayList (java.util.ArrayList)10 ParentProcessReadingBean (com.axway.ats.common.performance.monitor.beans.ParentProcessReadingBean)8 MonitoringException (com.axway.ats.core.monitoring.MonitoringException)7 HashSet (java.util.HashSet)7 SessionData (com.axway.ats.agent.webapp.restservice.model.SessionData)6 ErrorPojo (com.axway.ats.agent.webapp.restservice.model.pojo.ErrorPojo)6 MonitorConfigurationException (com.axway.ats.core.monitoring.MonitorConfigurationException)6 Consumes (javax.ws.rs.Consumes)6 POST (javax.ws.rs.POST)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 HashMap (java.util.HashMap)5 UnsupportedReadingException (com.axway.ats.core.monitoring.UnsupportedReadingException)3 Validator (com.axway.ats.core.validation.Validator)3 SystemInformationException (com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 AtsSystemMonitoringAgent (com.axway.ats.agent.core.monitoring.agents.AtsSystemMonitoringAgent)1 PerformanceMonitor (com.axway.ats.common.performance.monitor.PerformanceMonitor)1