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();
}
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);
}
}
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);
}
}
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);
}
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;
}
Aggregations