use of org.olat.admin.sysinfo.model.SessionsStats in project openolat by klemens.
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);
}
Aggregations