Search in sources :

Example 1 with SessionsStats

use of org.olat.admin.sysinfo.model.SessionsStats in project openolat by klemens.

the class SessionStatsManager method getSessionsStatsLast.

public SessionsStats getSessionsStatsLast(int numOfSeconds) {
    if (currentSample == null) {
        return new SessionsStats();
    }
    double polls = 0l;
    double clicks = 0l;
    double requests = 0l;
    long lastTime = 0l;
    long fromTimestamp = 0l;
    synchronized (this) {
        if (sessionStatsSamples.isEmpty()) {
            return new SessionsStats();
        }
        polls = currentSample.getAuthenticatedPollerCalls();
        clicks = currentSample.getAuthenticatedClick();
        requests = currentSample.getRequests();
        fromTimestamp = lastTime = System.currentTimeMillis();
        double toTimestamp = fromTimestamp - (numOfSeconds * 1000.0d);
        for (int i = sessionStatsSamples.size(); i-- > 0 && lastTime > toTimestamp; ) {
            SessionStatsSample lastSample = sessionStatsSamples.get(i);
            polls += lastSample.getAuthenticatedPollerCalls();
            clicks += lastSample.getAuthenticatedClick();
            requests += lastSample.getRequests();
            lastTime = lastSample.getTimestamp();
        }
    }
    double duration = (fromTimestamp - lastTime) / 1000;
    double pollPerSlot = (polls / duration) * numOfSeconds;
    double clickPerSlot = (clicks / duration) * numOfSeconds;
    double requestPerSlot = (requests / duration) * numOfSeconds;
    SessionsStats stats = new SessionsStats();
    stats.setAuthenticatedClickCalls(Math.round(clickPerSlot));
    stats.setAuthenticatedPollerCalls(Math.round(pollPerSlot));
    stats.setRequests(Math.round(requestPerSlot));
    return stats;
}
Also used : SessionsStats(org.olat.admin.sysinfo.model.SessionsStats) SessionStatsSample(org.olat.admin.sysinfo.model.SessionStatsSample)

Example 2 with SessionsStats

use of org.olat.admin.sysinfo.model.SessionsStats in project OpenOLAT by OpenOLAT.

the class SessionStatsManager method getSessionsStatsLast.

public SessionsStats getSessionsStatsLast(int numOfSeconds) {
    if (currentSample == null) {
        return new SessionsStats();
    }
    double polls = 0l;
    double clicks = 0l;
    double requests = 0l;
    long lastTime = 0l;
    long fromTimestamp = 0l;
    synchronized (this) {
        if (sessionStatsSamples.isEmpty()) {
            return new SessionsStats();
        }
        polls = currentSample.getAuthenticatedPollerCalls();
        clicks = currentSample.getAuthenticatedClick();
        requests = currentSample.getRequests();
        fromTimestamp = lastTime = System.currentTimeMillis();
        double toTimestamp = fromTimestamp - (numOfSeconds * 1000.0d);
        for (int i = sessionStatsSamples.size(); i-- > 0 && lastTime > toTimestamp; ) {
            SessionStatsSample lastSample = sessionStatsSamples.get(i);
            polls += lastSample.getAuthenticatedPollerCalls();
            clicks += lastSample.getAuthenticatedClick();
            requests += lastSample.getRequests();
            lastTime = lastSample.getTimestamp();
        }
    }
    double duration = (fromTimestamp - lastTime) / 1000;
    double pollPerSlot = (polls / duration) * numOfSeconds;
    double clickPerSlot = (clicks / duration) * numOfSeconds;
    double requestPerSlot = (requests / duration) * numOfSeconds;
    SessionsStats stats = new SessionsStats();
    stats.setAuthenticatedClickCalls(Math.round(clickPerSlot));
    stats.setAuthenticatedPollerCalls(Math.round(pollPerSlot));
    stats.setRequests(Math.round(requestPerSlot));
    return stats;
}
Also used : SessionsStats(org.olat.admin.sysinfo.model.SessionsStats) SessionStatsSample(org.olat.admin.sysinfo.model.SessionStatsSample)

Example 3 with SessionsStats

use of org.olat.admin.sysinfo.model.SessionsStats 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;
}
Also used : UserSessionManager(org.olat.core.util.session.UserSessionManager) SessionsStats(org.olat.admin.sysinfo.model.SessionsStats) SessionsVO(org.olat.restapi.system.vo.SessionsVO) UserSession(org.olat.core.util.UserSession) SessionInfo(org.olat.core.util.SessionInfo) SessionStatsManager(org.olat.admin.sysinfo.manager.SessionStatsManager)

Example 4 with SessionsStats

use of org.olat.admin.sysinfo.model.SessionsStats 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;
}
Also used : UserSessionManager(org.olat.core.util.session.UserSessionManager) SessionsStats(org.olat.admin.sysinfo.model.SessionsStats) SessionsVO(org.olat.restapi.system.vo.SessionsVO) UserSession(org.olat.core.util.UserSession) SessionInfo(org.olat.core.util.SessionInfo) SessionStatsManager(org.olat.admin.sysinfo.manager.SessionStatsManager)

Example 5 with SessionsStats

use of org.olat.admin.sysinfo.model.SessionsStats in project OpenOLAT by OpenOLAT.

the class SysinfoController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Formatter format = Formatter.getInstance(getLocale());
    // runtime informations
    FormLayoutContainer runtimeCont = FormLayoutContainer.createDefaultFormLayout("runtime", getTranslator());
    formLayout.add(runtimeCont);
    formLayout.add("runtime", runtimeCont);
    String startup = format.formatDateAndTime(new Date(WebappHelper.getTimeOfServerStartup()));
    uifactory.addStaticTextElement("runtime.startup", "runtime.startup", startup, runtimeCont);
    String time = format.formatDateAndTime(new Date()) + " (" + Calendar.getInstance().getTimeZone().getDisplayName(false, TimeZone.SHORT, ureq.getLocale()) + ")";
    uifactory.addStaticTextElement("runtime.time", "runtime.time", time, runtimeCont);
    // memory
    uifactory.addMemoryView("memoryHeap", "runtime.memory", MemoryType.HEAP, runtimeCont);
    uifactory.addMemoryView("memoryNonHeap", "runtime.memory.permGen", MemoryType.NON_HEAP, runtimeCont);
    // controllers
    int controllerCnt = DefaultController.getControllerCount();
    uifactory.addStaticTextElement("controllercount", "runtime.controllercount", Integer.toString(controllerCnt), runtimeCont);
    int numOfDispatchingThreads = sessionStatsManager.getConcurrentCounter();
    uifactory.addStaticTextElement("dispatchingthreads", "runtime.dispatchingthreads", Integer.toString(numOfDispatchingThreads), runtimeCont);
    // sessions and clicks
    String sessionAndClicksPage = velocity_root + "/session_clicks.html";
    FormLayoutContainer sessionAndClicksCont = FormLayoutContainer.createCustomFormLayout("session_clicks", getTranslator(), sessionAndClicksPage);
    runtimeCont.add(sessionAndClicksCont);
    sessionAndClicksCont.setLabel("sess.and.clicks", null);
    Calendar lastLoginMonthlyLimit = Calendar.getInstance();
    // users monthly
    lastLoginMonthlyLimit.add(Calendar.MONTH, -1);
    Long userLastMonth = securityManager.countUniqueUserLoginsSince(lastLoginMonthlyLimit.getTime());
    // -1 -5 = -6 for half a year
    lastLoginMonthlyLimit.add(Calendar.MONTH, -5);
    Long userLastSixMonths = securityManager.countUniqueUserLoginsSince(lastLoginMonthlyLimit.getTime());
    // -1 -11 = -12 for one year
    lastLoginMonthlyLimit.add(Calendar.MONTH, -11);
    Long userLastYear = securityManager.countUniqueUserLoginsSince(lastLoginMonthlyLimit.getTime());
    sessionAndClicksCont.contextPut("users1month", userLastMonth.toString());
    sessionAndClicksCont.contextPut("users6month", userLastSixMonths.toString());
    sessionAndClicksCont.contextPut("usersyear", userLastYear.toString());
    // users daily
    Calendar lastLoginDailyLimit = Calendar.getInstance();
    lastLoginDailyLimit.add(Calendar.DAY_OF_YEAR, -1);
    Long userLastDay = securityManager.countUniqueUserLoginsSince(lastLoginDailyLimit.getTime());
    // -1 - 6 = -7 for last week
    lastLoginDailyLimit.add(Calendar.DAY_OF_YEAR, -6);
    Long userLast6Days = securityManager.countUniqueUserLoginsSince(lastLoginDailyLimit.getTime());
    sessionAndClicksCont.contextPut("userslastday", userLastDay.toString());
    sessionAndClicksCont.contextPut("userslastweek", userLast6Days.toString());
    // last 5 minutes
    long activeSessions = sessionStatsManager.getActiveSessions(300);
    sessionAndClicksCont.contextPut("count5Minutes", String.valueOf(activeSessions));
    SessionsStats stats = sessionStatsManager.getSessionsStatsLast(300);
    sessionAndClicksCont.contextPut("click5Minutes", String.valueOf(stats.getAuthenticatedClickCalls()));
    sessionAndClicksCont.contextPut("poll5Minutes", String.valueOf(stats.getAuthenticatedPollerCalls()));
    sessionAndClicksCont.contextPut("request5Minutes", String.valueOf(stats.getRequests()));
    sessionAndClicksCont.contextPut("minutes", String.valueOf(5));
    // last minute
    activeSessions = sessionStatsManager.getActiveSessions(60);
    sessionAndClicksCont.contextPut("count1Minute", String.valueOf(activeSessions));
    stats = sessionStatsManager.getSessionsStatsLast(60);
    sessionAndClicksCont.contextPut("click1Minute", String.valueOf(stats.getAuthenticatedClickCalls()));
    sessionAndClicksCont.contextPut("poll1Minute", String.valueOf(stats.getAuthenticatedPollerCalls()));
    sessionAndClicksCont.contextPut("request1Minute", String.valueOf(stats.getRequests()));
    sessionAndClicksCont.contextPut("oneMinute", "1");
    // server informations
    FormLayoutContainer serverCont = FormLayoutContainer.createDefaultFormLayout("server", getTranslator());
    formLayout.add(serverCont);
    formLayout.add("server", serverCont);
    // version
    uifactory.addStaticTextElement("version", "sysinfo.version", Settings.getFullVersionInfo(), serverCont);
    uifactory.addStaticTextElement("version.hg", "sysinfo.version.hg", WebappHelper.getChangeSet(), serverCont);
    String buildDate = format.formatDateAndTime(Settings.getBuildDate());
    uifactory.addStaticTextElement("version.date", "sysinfo.version.date", buildDate, serverCont);
    // cluster
    boolean clusterMode = "Cluster".equals(Settings.getClusterMode());
    MultipleSelectionElement clusterEl = uifactory.addCheckboxesHorizontal("cluster", "sysinfo.cluster", serverCont, new String[] { "xx" }, new String[] { "" });
    clusterEl.setEnabled(false);
    clusterEl.select("xx", clusterMode);
    String nodeId = StringHelper.containsNonWhitespace(Settings.getNodeInfo()) ? Settings.getNodeInfo() : "N1";
    uifactory.addStaticTextElement("node", "sysinfo.node", nodeId, serverCont);
    File baseDir = new File(WebappHelper.getContextRoot());
    String baseDirPath = null;
    try {
        baseDirPath = baseDir.getCanonicalPath();
    } catch (IOException e1) {
        baseDirPath = baseDir.getAbsolutePath();
    }
    uifactory.addStaticTextElement("sysinfo.basedir", "sysinfo.basedir", baseDirPath, serverCont);
    uifactory.addStaticTextElement("sysinfo.olatdata", "sysinfo.olatdata", WebappHelper.getUserDataRoot(), serverCont);
}
Also used : Formatter(org.olat.core.util.Formatter) Calendar(java.util.Calendar) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) IOException(java.io.IOException) Date(java.util.Date) SessionsStats(org.olat.admin.sysinfo.model.SessionsStats) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) File(java.io.File)

Aggregations

SessionsStats (org.olat.admin.sysinfo.model.SessionsStats)6 File (java.io.File)2 IOException (java.io.IOException)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 SessionStatsManager (org.olat.admin.sysinfo.manager.SessionStatsManager)2 SessionStatsSample (org.olat.admin.sysinfo.model.SessionStatsSample)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Formatter (org.olat.core.util.Formatter)2 SessionInfo (org.olat.core.util.SessionInfo)2 UserSession (org.olat.core.util.UserSession)2 UserSessionManager (org.olat.core.util.session.UserSessionManager)2 SessionsVO (org.olat.restapi.system.vo.SessionsVO)2