use of org.olat.admin.sysinfo.manager.SessionStatsManager in project OpenOLAT by OpenOLAT.
the class StatusWebservice method getSystemSummaryVO.
/**
* Return the statistics about runtime: uptime, classes loaded, memory
* summary, threads count...
*
* @response.representation.200.qname {http://www.example.com}runtimeVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The version of the instance
* @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_RUNTIMEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param request The HTTP request
* @return The informations about runtime, uptime, classes loaded, memory summary...
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getSystemSummaryVO() {
StatusVO stats = new StatusVO();
// File
try {
long startFile = System.nanoTime();
File infoFile = setInfoFiles("ping");
WorkThreadInformations.unset();
stats.setWriteFileInMilliseconds(CodeHelper.nanoToMilliTime(startFile));
stats.setWriteFile(infoFile.exists());
infoFile.delete();
} catch (Exception e) {
stats.setWriteFile(false);
stats.setWriteFileInMilliseconds(-1l);
log.error("", e);
}
// Datebase
try {
stats.setWriteDb(true);
PropertyManager propertyManager = CoreSpringFactory.getImpl(PropertyManager.class);
List<Property> props = propertyManager.findProperties((Identity) null, (BusinessGroup) null, PING_RESOURCE, PING_REF, PING_REF);
if (props != null && props.size() > 0) {
for (Property prop : props) {
propertyManager.deleteProperty(prop);
}
DBFactory.getInstance().commit();
}
long startDB = System.nanoTime();
Property prop = propertyManager.createPropertyInstance(null, null, PING_RESOURCE, PING_REF, PING_REF, 0f, 0l, "-", "-");
DBFactory.getInstance().commit();
stats.setWriteDbInMilliseconds(CodeHelper.nanoToMilliTime(startDB));
propertyManager.deleteProperty(prop);
DBFactory.getInstance().commit();
} catch (Exception e) {
stats.setWriteDb(false);
stats.setWriteDbInMilliseconds(-1l);
log.error("", e);
}
// Secure authenticated user
UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
Set<UserSession> userSessions = sessionManager.getAuthenticatedUserSessions();
int secureAuthenticatedCount = 0;
for (UserSession usess : userSessions) {
SessionInfo sessInfo = usess.getSessionInfo();
if (sessInfo.isWebDAV() || sessInfo.isREST()) {
//
} else if (sessInfo.isSecure()) {
secureAuthenticatedCount++;
}
}
stats.setSecureAuthenticatedCount(secureAuthenticatedCount);
// Concurrent dispatch threads
SessionStatsManager sessionStatsManager = CoreSpringFactory.getImpl(SessionStatsManager.class);
stats.setConcurrentDispatchThreads(sessionStatsManager.getConcurrentCounter());
return Response.ok(stats).build();
}
use of org.olat.admin.sysinfo.manager.SessionStatsManager in project openolat by klemens.
the class OpenOLATStatisticsWebService method getSessionsVO.
protected SessionsVO getSessionsVO() {
SessionsVO vo = new SessionsVO();
SessionStatsManager sessionStatsManager = CoreSpringFactory.getImpl(SessionStatsManager.class);
UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
vo.setCount(sessionManager.getUserSessionsCnt());
Set<UserSession> userSessions = sessionManager.getAuthenticatedUserSessions();
int webdavcount = 0;
int secureWebdavCount = 0;
int authenticatedcount = 0;
int secureAuthenticatedCount = 0;
int restCount = 0;
int secureRestCount = 0;
for (UserSession usess : userSessions) {
SessionInfo sessInfo = usess.getSessionInfo();
if (sessInfo.isWebDAV()) {
webdavcount++;
if (sessInfo.isSecure()) {
secureWebdavCount++;
}
} else if (sessInfo.isREST()) {
restCount++;
if (sessInfo.isSecure()) {
secureRestCount++;
}
} else {
authenticatedcount++;
if (sessInfo.isSecure()) {
secureAuthenticatedCount++;
}
}
}
vo.setAuthenticatedCount(authenticatedcount);
vo.setSecureAuthenticatedCount(secureAuthenticatedCount);
vo.setWebdavCount(webdavcount);
vo.setSecureWebdavCount(secureWebdavCount);
vo.setRestCount(restCount);
vo.setSecureRestCount(secureRestCount);
// Instant messaging
vo.setInstantMessagingCount(-1);
SessionsStats statsLastMinute = sessionStatsManager.getSessionsStatsLast(60);
SessionsStats statsLast5Minutes = sessionStatsManager.getSessionsStatsLast(300);
vo.setAuthenticatedClickCountLastMinute(statsLastMinute.getAuthenticatedClickCalls());
vo.setAuthenticatedClickCountLastFiveMinutes(statsLast5Minutes.getAuthenticatedPollerCalls());
vo.setAuthenticatedPollCountLastMinute(statsLastMinute.getAuthenticatedPollerCalls());
vo.setAuthenticatedPollCountLastFiveMinutes(statsLast5Minutes.getAuthenticatedPollerCalls());
vo.setRequestLastMinute(statsLastMinute.getRequests());
vo.setRequestLastFiveMinutes(statsLast5Minutes.getRequests());
vo.setConcurrentDispatchThreads(sessionStatsManager.getConcurrentCounter());
return vo;
}
use of org.olat.admin.sysinfo.manager.SessionStatsManager in project openolat by klemens.
the class StatusWebservice method getSystemSummaryVO.
/**
* Return the statistics about runtime: uptime, classes loaded, memory
* summary, threads count...
*
* @response.representation.200.qname {http://www.example.com}runtimeVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The version of the instance
* @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_RUNTIMEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param request The HTTP request
* @return The informations about runtime, uptime, classes loaded, memory summary...
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getSystemSummaryVO() {
StatusVO stats = new StatusVO();
// File
try {
long startFile = System.nanoTime();
File infoFile = setInfoFiles("ping");
WorkThreadInformations.unset();
stats.setWriteFileInMilliseconds(CodeHelper.nanoToMilliTime(startFile));
stats.setWriteFile(infoFile.exists());
infoFile.delete();
} catch (Exception e) {
stats.setWriteFile(false);
stats.setWriteFileInMilliseconds(-1l);
log.error("", e);
}
// Datebase
try {
stats.setWriteDb(true);
PropertyManager propertyManager = CoreSpringFactory.getImpl(PropertyManager.class);
List<Property> props = propertyManager.findProperties((Identity) null, (BusinessGroup) null, PING_RESOURCE, PING_REF, PING_REF);
if (props != null && props.size() > 0) {
for (Property prop : props) {
propertyManager.deleteProperty(prop);
}
DBFactory.getInstance().commit();
}
long startDB = System.nanoTime();
Property prop = propertyManager.createPropertyInstance(null, null, PING_RESOURCE, PING_REF, PING_REF, 0f, 0l, "-", "-");
DBFactory.getInstance().commit();
stats.setWriteDbInMilliseconds(CodeHelper.nanoToMilliTime(startDB));
propertyManager.deleteProperty(prop);
DBFactory.getInstance().commit();
} catch (Exception e) {
stats.setWriteDb(false);
stats.setWriteDbInMilliseconds(-1l);
log.error("", e);
}
// Secure authenticated user
UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
Set<UserSession> userSessions = sessionManager.getAuthenticatedUserSessions();
int secureAuthenticatedCount = 0;
for (UserSession usess : userSessions) {
SessionInfo sessInfo = usess.getSessionInfo();
if (sessInfo.isWebDAV() || sessInfo.isREST()) {
//
} else if (sessInfo.isSecure()) {
secureAuthenticatedCount++;
}
}
stats.setSecureAuthenticatedCount(secureAuthenticatedCount);
// Concurrent dispatch threads
SessionStatsManager sessionStatsManager = CoreSpringFactory.getImpl(SessionStatsManager.class);
stats.setConcurrentDispatchThreads(sessionStatsManager.getConcurrentCounter());
return Response.ok(stats).build();
}
use of org.olat.admin.sysinfo.manager.SessionStatsManager in project openolat by klemens.
the class OpenOLATServlet method init.
/**
* @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
*/
@Override
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
requestBasedLogLevelManager = RequestBasedLogLevelManager.getInstance();
if (requestBasedLogLevelManager == null) {
log.info("init: RequestBasedLogLevelManager is not configured on this system.");
} else {
log.info("init: RequestBasedLogLevelManager is configured and will be used.");
}
if (UserBasedLogLevelManager.getInstance() == null) {
log.info("init: UserBasedLogLevelManager is not configured on this system.");
} else {
log.info("init: UserBasedLogLevelManager is configured and will be used.");
}
// the servlet.init method gets called after the spring stuff and all the stuff in web.xml is done
log.info("Framework has started, sending event to listeners of FrameworkStartupEventChannel");
FrameworkStartupEventChannel.fireEvent();
log.info("FrameworkStartupEvent processed by alle listeners. Webapp has started.");
sessionStatsManager = CoreSpringFactory.getImpl(SessionStatsManager.class);
DispatcherModule dispatcherModule = CoreSpringFactory.getImpl(DispatcherModule.class);
dispatchers = new HashMap<>(dispatcherModule.getDispatchers());
dispatchers.put(DispatcherModule.PATH_MAPPED, new MapperDispatcher());
dispatchers.put(DispatcherModule.PATH_GLOBAL_MAPPED, GlobalMapperRegistry.getInstance());
webDAVDispatcher = CoreSpringFactory.getImpl(WebDAVDispatcher.class);
dispatchers.put(DispatcherModule.WEBDAV_PATH, webDAVDispatcher);
Settings settings = CoreSpringFactory.getImpl(Settings.class);
if (StringHelper.containsNonWhitespace(settings.getLegacyContext())) {
legacyContext = settings.getLegacyContext();
// same pattern as dispatcher: /olat/
if (!legacyContext.startsWith("/")) {
legacyContext = "/" + legacyContext;
}
if (!legacyContext.endsWith("/")) {
legacyContext += "/";
}
}
// preload extensions
ExtManager.getInstance().getExtensions();
AbstractSpringModule.printStats();
preWarm();
}
use of org.olat.admin.sysinfo.manager.SessionStatsManager in project OpenOLAT by OpenOLAT.
the class OpenOLATStatisticsWebService method getSessionsVO.
protected SessionsVO getSessionsVO() {
SessionsVO vo = new SessionsVO();
SessionStatsManager sessionStatsManager = CoreSpringFactory.getImpl(SessionStatsManager.class);
UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
vo.setCount(sessionManager.getUserSessionsCnt());
Set<UserSession> userSessions = sessionManager.getAuthenticatedUserSessions();
int webdavcount = 0;
int secureWebdavCount = 0;
int authenticatedcount = 0;
int secureAuthenticatedCount = 0;
int restCount = 0;
int secureRestCount = 0;
for (UserSession usess : userSessions) {
SessionInfo sessInfo = usess.getSessionInfo();
if (sessInfo.isWebDAV()) {
webdavcount++;
if (sessInfo.isSecure()) {
secureWebdavCount++;
}
} else if (sessInfo.isREST()) {
restCount++;
if (sessInfo.isSecure()) {
secureRestCount++;
}
} else {
authenticatedcount++;
if (sessInfo.isSecure()) {
secureAuthenticatedCount++;
}
}
}
vo.setAuthenticatedCount(authenticatedcount);
vo.setSecureAuthenticatedCount(secureAuthenticatedCount);
vo.setWebdavCount(webdavcount);
vo.setSecureWebdavCount(secureWebdavCount);
vo.setRestCount(restCount);
vo.setSecureRestCount(secureRestCount);
// Instant messaging
vo.setInstantMessagingCount(-1);
SessionsStats statsLastMinute = sessionStatsManager.getSessionsStatsLast(60);
SessionsStats statsLast5Minutes = sessionStatsManager.getSessionsStatsLast(300);
vo.setAuthenticatedClickCountLastMinute(statsLastMinute.getAuthenticatedClickCalls());
vo.setAuthenticatedClickCountLastFiveMinutes(statsLast5Minutes.getAuthenticatedPollerCalls());
vo.setAuthenticatedPollCountLastMinute(statsLastMinute.getAuthenticatedPollerCalls());
vo.setAuthenticatedPollCountLastFiveMinutes(statsLast5Minutes.getAuthenticatedPollerCalls());
vo.setRequestLastMinute(statsLastMinute.getRequests());
vo.setRequestLastFiveMinutes(statsLast5Minutes.getRequests());
vo.setConcurrentDispatchThreads(sessionStatsManager.getConcurrentCounter());
return vo;
}
Aggregations