Search in sources :

Example 1 with MonitorConfigurationException

use of com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException in project ats-framework by Axway.

the class MBeanWrapper method getMBeanAttribute.

/**
     * Gets the value of a specific attribute of a named MBean
     * 
     * @param objectName the object name
     * @param attributeName the attribute name
     * @return the attribute value
     */
Object getMBeanAttribute(ObjectName objectName, String attributeName) {
    try {
        for (MBeanAttributeInfo attInfo : connection.getMBeanInfo(objectName).getAttributes()) {
            String attName = attInfo.getName();
            if (attName.equals(attributeName)) {
                return connection.getAttribute(objectName, attributeName);
            }
        }
    } catch (Exception e) {
        final String errorMsg = "Error getting the value of the '" + attributeName + "' attribute of MBean with name '" + objectName + "'";
        log.error(errorMsg, e);
        throw new MonitorConfigurationException(errorMsg, e);
    }
    final String errorMsg = "Error getting the value of the '" + attributeName + "' attribute of MBean with name '" + objectName + "': The attribute is not found!";
    log.error(errorMsg);
    throw new MonitorConfigurationException(errorMsg);
}
Also used : MonitorConfigurationException(com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MonitorConfigurationException(com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException)

Example 2 with MonitorConfigurationException

use of com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException in project ats-framework by Axway.

the class SigarWrapper method refresh.

/**
     * called on each poll
     *
     * @throws SigarException
     * @throws MonitorConfigurationException
     */
void refresh() throws SigarException, MonitorConfigurationException {
    try {
        this.swap = this.sigar.getSwap();
        this.memory = this.sigar.getMem();
        this.cpu = this.sigar.getCpu();
        this.cpuPerc = this.sigar.getCpuPerc();
        if (!OperatingSystemType.getCurrentOsType().equals(OperatingSystemType.AIX)) {
            this.netstat = this.sigar.getNetStat();
            this.tcp = this.sigar.getTcp();
        }
        this.loadAvrg = new SigarLoadAverage(this.sigar);
    } catch (Exception e) {
        final String errorMsg = "Error retrieving data from the Sigar monitoring system";
        log.error(errorMsg, e);
        throw new MonitorConfigurationException(errorMsg, e);
    }
}
Also used : MonitorConfigurationException(com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException) SigarLoadAverage(org.hyperic.sigar.jmx.SigarLoadAverage) SigarException(org.hyperic.sigar.SigarException) MonitorConfigurationException(com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException)

Example 3 with MonitorConfigurationException

use of com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException in project ats-framework by Axway.

the class InternalSystemMonitoringOperations method initializeMonitor.

private void initializeMonitor(String monitorClassName, List<FullReadingBean> readings, int pollInterval) throws MonitorConfigurationException {
    // try to make an instance of the monitor class
    Object monitorInstance;
    try {
        monitorInstance = Class.forName(monitorClassName).newInstance();
    } catch (InstantiationException e) {
        throw new MonitorConfigurationException("InstantiationException while constructing '" + monitorClassName + "' monitor. Exception error message: " + e.getMessage());
    } catch (IllegalAccessException e) {
        throw new MonitorConfigurationException("IllegalAccessException while constructing '" + monitorClassName + "' monitor. Exception error message: " + e.getMessage());
    } catch (ClassNotFoundException e) {
        throw new MonitorConfigurationException("ClassNotFoundException while constructing '" + monitorClassName + "' monitor. Exception error message: " + e.getMessage());
    }
    // check if it implements the needed interface
    if (!(monitorInstance instanceof PerformanceMonitor)) {
        throw new MonitorConfigurationException(monitorClassName + " is not a valid monitor class");
    }
    PerformanceMonitor monitor = (PerformanceMonitor) monitorInstance;
    try {
        // initialize the monitor
        monitor.setPollInterval(pollInterval);
        monitor.init(readings.toArray(new FullReadingBean[readings.size()]));
    } catch (Throwable e) {
        throw new MonitorConfigurationException("Error initializing " + monitorClassName + " monitor: " + e.getMessage(), e);
    }
    monitoringAgent.addMonitor(monitor);
}
Also used : MonitorConfigurationException(com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException) PerformanceMonitor(com.axway.ats.common.performance.monitor.PerformanceMonitor) FullReadingBean(com.axway.ats.common.performance.monitor.beans.FullReadingBean)

Example 4 with MonitorConfigurationException

use of com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException in project ats-framework by Axway.

the class MBeanWrapper method getObjectName.

/**
     * Gets the names of MBeans controlled by the MBean server
     * 
     * @param name MBean name
     * @return MBean object name
     */
ObjectName getObjectName(String name) {
    Set<ObjectName> mBeanNames;
    try {
        mBeanNames = connection.queryNames(new ObjectName(name), null);
    } catch (Exception e) {
        final String errorMsg = "Error getting the names of MBeans on the monitored JVM application. Searched patter is " + name;
        log.error(errorMsg, e);
        throw new MonitorConfigurationException(errorMsg, e);
    }
    if (mBeanNames.size() != 1) {
        final String errorMsg = "Error getting the names of MBeans on the monitored JVM application. Searched patter is " + name + ". We expected to find 1, but found " + mBeanNames + " MBean names.";
        log.error(errorMsg);
        throw new MonitorConfigurationException(errorMsg);
    }
    Iterator<ObjectName> it = mBeanNames.iterator();
    return it.next();
}
Also used : MonitorConfigurationException(com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException) MonitorConfigurationException(com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException) ObjectName(javax.management.ObjectName)

Aggregations

MonitorConfigurationException (com.axway.ats.agent.components.monitoring.model.exceptions.MonitorConfigurationException)4 PerformanceMonitor (com.axway.ats.common.performance.monitor.PerformanceMonitor)1 FullReadingBean (com.axway.ats.common.performance.monitor.beans.FullReadingBean)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 ObjectName (javax.management.ObjectName)1 SigarException (org.hyperic.sigar.SigarException)1 SigarLoadAverage (org.hyperic.sigar.jmx.SigarLoadAverage)1