Search in sources :

Example 6 with MonitorConfigurationException

use of com.axway.ats.core.monitoring.MonitorConfigurationException in project ats-framework by Axway.

the class ReadingsRepository method extractMonitor.

/**
 * Extracts all the data for a given monitor by iterating over it's filters
 *
 * @param monitorLevelElement the root element of the tree
 * @throws MonitorConfigurationException
 */
private void extractMonitor(Element monitorLevelElement) throws MonitorConfigurationException {
    String monitorClass = extractAttribute(monitorLevelElement, MONITOR_NODE__CLASS);
    if (monitorClass == null) {
        this.readingParseState.throwException("No monitor class specified");
    }
    if (this.alreadyLoadedMonitors.containsKey(monitorClass)) {
        // the jar, that had monitor with the same name as the current one
        String alreadyProcessedJarFilename = extractJarFilepath(this.alreadyLoadedMonitors.get(monitorClass));
        // the currently processed jar, which contains custom performance monitor
        String currentJarFilename = extractJarFilepath(this.readingParseState.configurationFileName);
        String errMsg = "Duplicated monitor class name. Monitor '" + monitorClass + "' is presented in both '" + alreadyProcessedJarFilename + "' and '" + currentJarFilename + "'";
        throw new MonitorConfigurationException(errMsg);
    }
    this.readingParseState.rememberMonitorClass(monitorClass);
    // iterate over all children, all of them being filters
    NodeList readingLevelElements = monitorLevelElement.getChildNodes();
    for (int i = 0; i < readingLevelElements.getLength(); i++) {
        Node readingLevelElement = readingLevelElements.item(i);
        if (readingLevelElement.getNodeType() == Node.ELEMENT_NODE && readingLevelElement.getNodeName().equals(READING_NODE)) {
            extractReading((Element) readingLevelElement, monitorClass);
        }
    }
    // remember that this monitor's readings were already loaded
    this.alreadyLoadedMonitors.put(this.readingParseState.monitorClass, this.readingParseState.configurationFileName);
    this.readingParseState.forgetMonitorClass();
}
Also used : MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node)

Example 7 with MonitorConfigurationException

use of com.axway.ats.core.monitoring.MonitorConfigurationException in project ats-framework by Axway.

the class SigarSystemInformation method refresh.

@Override
public void refresh() {
    if (this.sigar == null) {
        return;
    }
    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.core.monitoring.MonitorConfigurationException) SigarLoadAverage(org.hyperic.sigar.jmx.SigarLoadAverage) SigarException(org.hyperic.sigar.SigarException) MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) SystemInformationException(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)

Example 8 with MonitorConfigurationException

use of com.axway.ats.core.monitoring.MonitorConfigurationException in project ats-framework by Axway.

the class RestSystemMonitor method initializeMonitoringContext.

public void initializeMonitoringContext(@Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost) {
    // validate input parameters
    monitoredHost = HostUtils.getAtsAgentIpAndPort(monitoredHost);
    new Validator().validateMethodParameters("Could not schedule monitoring system statistics on '" + monitoredHost + "'", new Object[] { monitoredHost });
    try {
        log.debug("Initializing monitoring context...");
        systemMonitor.initializeMonitoringContext();
        log.info("Monitoring context initialized.");
    } catch (Exception e) {
        log.error("Could not initialize monitoring context.", e);
        throw new MonitorConfigurationException("Could not initialize monitoring context", e);
    }
}
Also used : MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) Validator(com.axway.ats.core.validation.Validator) MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) MonitoringException(com.axway.ats.core.monitoring.MonitoringException)

Example 9 with MonitorConfigurationException

use of com.axway.ats.core.monitoring.MonitorConfigurationException in project ats-framework by Axway.

the class AgentSystemMonitor method initializeMonitor.

private void initializeMonitor(String monitorClassName, List<ReadingBean> 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 ReadingBean[readings.size()]));
    } catch (Throwable e) {
        throw new MonitorConfigurationException("Error initializing " + monitorClassName + " monitor: " + e.getMessage(), e);
    }
    monitoringAgent.addMonitor(monitor);
}
Also used : ReadingBean(com.axway.ats.common.performance.monitor.beans.ReadingBean) MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) PerformanceMonitor(com.axway.ats.common.performance.monitor.PerformanceMonitor)

Example 10 with MonitorConfigurationException

use of com.axway.ats.core.monitoring.MonitorConfigurationException in project ats-framework by Axway.

the class MBeanWrapper method getObjectNames.

Set<ObjectName> getObjectNames(String regex, boolean oneEntry) {
    Set<ObjectName> names = new HashSet<ObjectName>();
    try {
        if (mBeanNames == null) {
            synchronized (lock) {
                if (mBeanNames == null) {
                    mBeanNames = Collections.synchronizedSet(connection.queryNames(null, null));
                }
            }
        }
        Iterator<ObjectName> it = mBeanNames.iterator();
        while (it.hasNext()) {
            ObjectName name = it.next();
            if (Pattern.matches(regex, name.getCanonicalName())) {
                names.add(name);
            }
        }
    } catch (Exception e) {
        final String errorMsg = "Error getting the names of MBeans on the monitored JVM application. Searched pattern is " + regex;
        log.error(errorMsg, e);
        throw new MonitorConfigurationException(errorMsg, e);
    }
    if (oneEntry && names.size() != 1) {
        final String errorMsg = "Error getting the names of MBeans on the monitored JVM application. Searched pattern is " + regex + ". We expected to find 1, but found " + names + " MBean names.";
        log.error(errorMsg);
        throw new MonitorConfigurationException(errorMsg);
    }
    return names;
}
Also used : MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) MonitorConfigurationException(com.axway.ats.core.monitoring.MonitorConfigurationException) ObjectName(javax.management.ObjectName) HashSet(java.util.HashSet)

Aggregations

MonitorConfigurationException (com.axway.ats.core.monitoring.MonitorConfigurationException)10 IOException (java.io.IOException)3 ObjectName (javax.management.ObjectName)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 SystemInformationException (com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)1 PerformanceMonitor (com.axway.ats.common.performance.monitor.PerformanceMonitor)1 ReadingBean (com.axway.ats.common.performance.monitor.beans.ReadingBean)1 MonitoringException (com.axway.ats.core.monitoring.MonitoringException)1 Validator (com.axway.ats.core.validation.Validator)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 SigarException (org.hyperic.sigar.SigarException)1 SigarLoadAverage (org.hyperic.sigar.jmx.SigarLoadAverage)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 SAXException (org.xml.sax.SAXException)1