use of com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute in project cuba by cuba-platform.
the class ManagedBeanAttributeDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
data.clear();
Datasource mbeanDs = getDsContext().get("mbeanDs");
ManagedBeanInfo mbean = (ManagedBeanInfo) mbeanDs.getItem();
if (mbean != null) {
try {
jmxControlAPI.loadAttributes(mbean);
} catch (JmxControlException e) {
log.error("Error loading attributes", e);
}
if (mbean.getAttributes() != null) {
for (ManagedBeanAttribute attr : mbean.getAttributes()) {
data.put(attr.getId(), attr);
}
}
}
}
use of com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute in project cuba by cuba-platform.
the class StatisticsDatasource method loadCurrentValues.
protected void loadCurrentValues() {
refreshCount++;
for (PerformanceParameter parameter : getItems()) {
parameter.setRefreshCount(refreshCount);
}
try {
ManagedBeanAttribute uptimeAttr = findAttribute("java.lang:type=Runtime", "Uptime");
if (uptimeAttr != null) {
getParameter("Uptime").setCurrentLong((Long) uptimeAttr.getValue());
}
ManagedBeanAttribute startTimeAttr = findAttribute("java.lang:type=Runtime", "StartTime");
if (startTimeAttr != null) {
getParameter("Start Time").setCurrentLong((Long) startTimeAttr.getValue());
}
ManagedBeanAttribute heapUsage = findAttribute("java.lang:type=Memory", "HeapMemoryUsage");
if (heapUsage != null) {
CompositeData heapData = (CompositeData) heapUsage.getValue();
PerformanceParameter parameter = getParameter("Heap Memory Usage");
parameter.setCurrentLong((Long) heapData.get("used"));
String max = kilobyteFormatter.format(((Long) heapData.get("max")).doubleValue());
parameter.setDisplayName(parameter.getParameterName() + " (Max = " + max + ")");
}
setAverageParameter("Heap Memory Usage", "AvgHeapMemoryUsage", true);
ManagedBeanAttribute nonHeapUsage = findAttribute("java.lang:type=Memory", "NonHeapMemoryUsage");
if (nonHeapUsage != null) {
CompositeData nonHeapData = (CompositeData) nonHeapUsage.getValue();
PerformanceParameter parameter = getParameter("Non-Heap Memory Usage");
parameter.setCurrentLong((Long) nonHeapData.get("used"));
String max = kilobyteFormatter.format(((Long) nonHeapData.get("max")).doubleValue());
parameter.setDisplayName(parameter.getParameterName() + " (Max = " + max + ")");
}
setAverageParameter("Non-Heap Memory Usage", "AvgNonHeapMemoryUsage", true);
ManagedBeanAttribute attr = findAttribute("java.lang:type=OperatingSystem", "FreePhysicalMemorySize");
if (attr != null) {
PerformanceParameter param = getParameter("Free Physical Memory Size");
param.setCurrentLong((Long) attr.getValue());
attr = findAttribute("java.lang:type=OperatingSystem", "TotalPhysicalMemorySize");
if (attr != null) {
String max = kilobyteFormatter.format(((Long) attr.getValue()).doubleValue());
param.setDisplayName(param.getParameterName() + " (Total = " + max + ")");
}
}
attr = findAttribute("java.lang:type=OperatingSystem", "FreeSwapSpaceSize");
if (attr != null) {
PerformanceParameter param = getParameter("Free Swap Space Size");
param.setCurrentLong((Long) attr.getValue());
attr = findAttribute("java.lang:type=OperatingSystem", "TotalSwapSpaceSize");
if (attr != null) {
String max = kilobyteFormatter.format(((Long) attr.getValue()).doubleValue());
param.setDisplayName(param.getParameterName() + " (Total = " + max + ")");
}
}
setAverageParameter("Free Physical Memory Size", "AvgFreePhysicalMemorySize", true);
setAverageParameter("Free Swap Space Size", "AvgFreeSwapSpaceSize", true);
setParameters("java.lang:type=OperatingSystem", new String[] { "SystemCpuLoad", "ProcessCpuLoad" }, new String[] { "System CPU Load", "Process CPU Load" });
setAverageParameter("System CPU Load", "AvgSystemCpuLoad", true);
setAverageParameter("Process CPU Load", "AvgProcessCpuLoad", true);
attr = findAttribute(coreAppName + ".cuba:type=StatisticsCounter", "DbConnectionPoolNumActive");
if (attr != null) {
PerformanceParameter param = getParameter("Active Connections");
param.setCurrent(((Integer) attr.getValue()).doubleValue());
attr = findAttribute(coreAppName + ".cuba:type=StatisticsCounter", "DbConnectionPoolMaxTotal");
if (attr != null) {
String max = integerFormatter.format(((Integer) attr.getValue()).doubleValue());
param.setDisplayName(param.getParameterName() + " (Max = " + max + ")");
}
}
setParameters(coreAppName + ".cuba:type=StatisticsCounter", new String[] { "DbConnectionPoolNumIdle" }, new String[] { "Idle Connections" });
setAverageParameter("Active Connections", "AvgDbConnectionPoolNumActive", true);
setAverageParameter("Idle Connections", "AvgDbConnectionPoolNumIdle", true);
setParameters(coreAppName + ".cuba:type=StatisticsCounter", new String[] { "ActiveTransactionsCount" }, new String[] { "Active Transactions" });
setAverageParameter("Active Transactions", "AvgActiveTransactions", true);
setTxPerSecParameter();
setAverageParameter("Transactions per Second", "TransactionsPerSecond", true);
attr = findAttribute("java.lang:type=Threading", "ThreadCount");
if (attr != null) {
PerformanceParameter param = getParameter("Thread Count");
param.setCurrent(((Integer) attr.getValue()).doubleValue());
attr = findAttribute("java.lang:type=Threading", "PeakThreadCount");
if (attr != null) {
String max = integerFormatter.format(((Integer) attr.getValue()).doubleValue());
param.setDisplayName(param.getParameterName() + " (Peak = " + max + ")");
}
}
setAverageParameter("Thread Count", "AvgThreadCount", true);
setParameters(coreAppName + ".cuba:type=UserSessions", new String[] { "Count" }, new String[] { "User Sessions" });
setAverageParameter("User Sessions", "AvgUserSessions", true);
setWebRequestsPerSecParameter();
setAverageParameter("Web Requests per Second", "WebRequestsPerSecond", false);
setMiddlewareRequestsPerSecParameter();
setAverageParameter("Middleware Requests per Second", "MiddlewareRequestsPerSecond", true);
setCubaScheduledTasksPerSecParameter();
setAverageParameter("CUBA Scheduled Tasks per Second", "CubaScheduledTasksPerSecond", true);
setMiddlewareSpringScheduledTasksPerSecParameter();
setAverageParameter("Middleware Spring Scheduled Tasks per Second", "SpringScheduledTasksPerSecond", true);
setWebSpringScheduledTasksPerSecParameter();
setAverageParameter("Web Spring Scheduled Tasks per Second", "SpringScheduledTasksPerSecond", false);
} catch (InstanceNotFoundException | ReflectionException e) {
throw new JmxControlException(e);
}
}
Aggregations