Search in sources :

Example 1 with MemoryMonitor

use of org.apereo.cas.monitor.MemoryMonitor in project cas by apereo.

the class CasCoreMonitorConfiguration method healthCheckMonitor.

@ConditionalOnMissingBean(name = "healthCheckMonitor")
@Bean
public Monitor healthCheckMonitor() {
    final Map<String, Monitor> beans = applicationContext.getBeansOfType(Monitor.class, false, true);
    final Set<Monitor> monitors = beans.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toSet());
    final int freeMemThreshold = casProperties.getMonitor().getFreeMemThreshold();
    if (freeMemThreshold > 0) {
        monitors.add(new MemoryMonitor(freeMemThreshold));
    }
    final MonitorProperties.Warn warn = casProperties.getMonitor().getSt().getWarn();
    if (warn.getThreshold() > 0) {
        final SessionMonitor bean = new SessionMonitor(ticketRegistry, warn.getThreshold(), warn.getThreshold());
        monitors.add(bean);
    }
    return new HealthCheckMonitor(monitors);
}
Also used : MemoryMonitor(org.apereo.cas.monitor.MemoryMonitor) HealthCheckMonitor(org.apereo.cas.monitor.HealthCheckMonitor) SessionMonitor(org.apereo.cas.monitor.SessionMonitor) Monitor(org.apereo.cas.monitor.Monitor) MemoryMonitor(org.apereo.cas.monitor.MemoryMonitor) HealthCheckMonitor(org.apereo.cas.monitor.HealthCheckMonitor) Map(java.util.Map) SessionMonitor(org.apereo.cas.monitor.SessionMonitor) MonitorProperties(org.apereo.cas.configuration.model.core.monitor.MonitorProperties) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Map (java.util.Map)1 MonitorProperties (org.apereo.cas.configuration.model.core.monitor.MonitorProperties)1 HealthCheckMonitor (org.apereo.cas.monitor.HealthCheckMonitor)1 MemoryMonitor (org.apereo.cas.monitor.MemoryMonitor)1 Monitor (org.apereo.cas.monitor.Monitor)1 SessionMonitor (org.apereo.cas.monitor.SessionMonitor)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1