Search in sources :

Example 1 with StatusVO

use of org.olat.restapi.system.vo.StatusVO in project OpenOLAT by OpenOLAT.

the class SystemTest method testMonitoringStatus.

@Test
public void testMonitoringStatus() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("status").build();
    StatusVO stats = conn.get(systemUri, StatusVO.class);
    Assert.assertNotNull(stats);
    Assert.assertTrue(stats.isWriteDb());
    Assert.assertTrue(stats.isWriteFile());
    Assert.assertTrue(stats.getConcurrentDispatchThreads() >= 0l);
    Assert.assertTrue(stats.getSecureAuthenticatedCount() >= 0l);
    conn.shutdown();
}
Also used : URI(java.net.URI) StatusVO(org.olat.restapi.system.vo.StatusVO) Test(org.junit.Test)

Example 2 with StatusVO

use of org.olat.restapi.system.vo.StatusVO 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();
}
Also used : PropertyManager(org.olat.properties.PropertyManager) SessionInfo(org.olat.core.util.SessionInfo) SessionStatsManager(org.olat.admin.sysinfo.manager.SessionStatsManager) IOException(java.io.IOException) UserSessionManager(org.olat.core.util.session.UserSessionManager) UserSession(org.olat.core.util.UserSession) File(java.io.File) Property(org.olat.properties.Property) StatusVO(org.olat.restapi.system.vo.StatusVO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with StatusVO

use of org.olat.restapi.system.vo.StatusVO 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();
}
Also used : PropertyManager(org.olat.properties.PropertyManager) SessionInfo(org.olat.core.util.SessionInfo) SessionStatsManager(org.olat.admin.sysinfo.manager.SessionStatsManager) IOException(java.io.IOException) UserSessionManager(org.olat.core.util.session.UserSessionManager) UserSession(org.olat.core.util.UserSession) File(java.io.File) Property(org.olat.properties.Property) StatusVO(org.olat.restapi.system.vo.StatusVO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with StatusVO

use of org.olat.restapi.system.vo.StatusVO in project openolat by klemens.

the class SystemTest method testMonitoringStatus.

@Test
public void testMonitoringStatus() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("status").build();
    StatusVO stats = conn.get(systemUri, StatusVO.class);
    Assert.assertNotNull(stats);
    Assert.assertTrue(stats.isWriteDb());
    Assert.assertTrue(stats.isWriteFile());
    Assert.assertTrue(stats.getConcurrentDispatchThreads() >= 0l);
    Assert.assertTrue(stats.getSecureAuthenticatedCount() >= 0l);
    conn.shutdown();
}
Also used : URI(java.net.URI) StatusVO(org.olat.restapi.system.vo.StatusVO) Test(org.junit.Test)

Aggregations

StatusVO (org.olat.restapi.system.vo.StatusVO)4 File (java.io.File)2 IOException (java.io.IOException)2 URI (java.net.URI)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Test (org.junit.Test)2 SessionStatsManager (org.olat.admin.sysinfo.manager.SessionStatsManager)2 SessionInfo (org.olat.core.util.SessionInfo)2 UserSession (org.olat.core.util.UserSession)2 UserSessionManager (org.olat.core.util.session.UserSessionManager)2 Property (org.olat.properties.Property)2 PropertyManager (org.olat.properties.PropertyManager)2