use of com.infiniteautomation.mango.monitor.PollableMonitor in project ma-core-public by infiniteautomation.
the class ServerMonitoringService method doPoll.
@Override
protected void doPoll() {
ServerStatus status = lifecycle.getServerStatus();
threads.setValue(status.getThreads());
idleThreads.setValue(status.getIdleThreads());
queueSize.setValue(status.getQueueSize());
if (Common.backgroundProcessing != null) {
highPriorityActive.setValue(Common.backgroundProcessing.getHighPriorityServiceActiveCount());
highPriorityScheduled.setValue(Common.backgroundProcessing.getHighPriorityServiceScheduledTaskCount());
highPriorityWaiting.setValue(Common.backgroundProcessing.getHighPriorityServiceQueueSize());
mediumPriorityActive.setValue(Common.backgroundProcessing.getMediumPriorityServiceActiveCount());
mediumPriorityWaiting.setValue(Common.backgroundProcessing.getMediumPriorityServiceQueueSize());
lowPriorityActive.setValue(Common.backgroundProcessing.getLowPriorityServiceActiveCount());
lowPriorityWaiting.setValue(Common.backgroundProcessing.getLowPriorityServiceQueueSize());
}
dbActiveConnections.setValue(databaseProxy.getActiveConnections());
dbIdleConnections.setValue(databaseProxy.getIdleConnections());
// In MiB
javaMaxMemory.setValue((int) (runtime.maxMemory() / mib));
javaUsedMemory.setValue((int) (runtime.totalMemory() / mib) - (int) (runtime.freeMemory() / mib));
javaFreeMemory.setValue(javaMaxMemory.getValue() - javaUsedMemory.getValue());
// Uptime in HRS
long uptimeMs = runtimeBean.getUptime();
Double uptimeHrs = uptimeMs / 3600000.0D;
BigDecimal bd = new BigDecimal(uptimeHrs);
bd = bd.setScale(2, RoundingMode.HALF_UP);
uptime.setValue(bd.doubleValue());
// Collect Active User Sessions
ConfigurableApplicationContext context = (ConfigurableApplicationContext) Common.getRootWebContext();
if (context != null && context.isActive()) {
MangoSessionRegistry sessionRegistry = context.getBean(MangoSessionRegistry.class);
userSessions.setValue(sessionRegistry.getActiveSessionCount());
} else {
userSessions.setValue(0);
}
long ts = System.currentTimeMillis();
for (ValueMonitor<?> monitor : monitors) {
try {
if (monitor instanceof PollableMonitor) {
((PollableMonitor<?>) monitor).poll(ts);
}
} catch (Exception e) {
log.warn("Failed to poll monitor {}", monitor.getId(), e);
}
}
}
Aggregations