Search in sources :

Example 1 with MonitoringInfosVO

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

the class SystemTest method testMonitoringInfos.

@Test
public void testMonitoringInfos() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("configuration").build();
    MonitoringInfosVO databaseInfos = conn.get(systemUri, MonitoringInfosVO.class);
    assertNotNull(databaseInfos);
    assertNotNull(databaseInfos.getDependencies());
    assertNotNull(databaseInfos.getProbes());
    assertNotNull(databaseInfos.getType());
    conn.shutdown();
}
Also used : MonitoringInfosVO(org.olat.restapi.system.vo.MonitoringInfosVO) URI(java.net.URI) Test(org.junit.Test)

Example 2 with MonitoringInfosVO

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

the class SystemTest method testMonitoringInfos.

@Test
public void testMonitoringInfos() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("configuration").build();
    MonitoringInfosVO databaseInfos = conn.get(systemUri, MonitoringInfosVO.class);
    assertNotNull(databaseInfos);
    assertNotNull(databaseInfos.getDependencies());
    assertNotNull(databaseInfos.getProbes());
    assertNotNull(databaseInfos.getType());
    conn.shutdown();
}
Also used : MonitoringInfosVO(org.olat.restapi.system.vo.MonitoringInfosVO) URI(java.net.URI) Test(org.junit.Test)

Example 3 with MonitoringInfosVO

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

the class MonitoringWebService method getImplementedProbes.

/**
 * Return the configuration of the monitoring, which probes are available,
 * which dependency...
 *
 * @response.representation.200.qname {http://www.example.com}releaseVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The verison of the instance
 * @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_MONITORINGCONFIGVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @param request The HTTP request
 * @return The informations about the memory
 */
@GET
@Path("configuration")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getImplementedProbes() {
    MonitoringInfosVO vo = new MonitoringInfosVO();
    MonitoringModule module = CoreSpringFactory.getImpl(MonitoringModule.class);
    String probesConfig = module.getMonitoredProbes();
    String[] probes;
    if (StringHelper.containsNonWhitespace(probesConfig)) {
        probes = probesConfig.split(",");
    } else {
        probes = new String[0];
    }
    vo.setProbes(probes);
    vo.setType(SystemRegistrationManager.PRODUCT);
    vo.setDescription(module.getDescription());
    List<MonitoringDependencyVO> dependencies = new ArrayList<MonitoringDependencyVO>();
    InstantMessagingModule imConfig = CoreSpringFactory.getImpl(InstantMessagingModule.class);
    if (imConfig.isEnabled()) {
        MonitoringDependencyVO dependency = new MonitoringDependencyVO();
        dependency.setType("openfire");
        dependency.setUrl("");
        dependencies.add(dependency);
    }
    DB dbInstance = CoreSpringFactory.getImpl(DB.class);
    MonitoringDependencyVO dependency = new MonitoringDependencyVO();
    dependency.setType(dbInstance.getDbVendor());
    dependency.setUrl(module.getDatabaseHost());
    dependencies.add(dependency);
    MonitoringDependencyVO dependencyServer = new MonitoringDependencyVO();
    dependencyServer.setType("server");
    dependencyServer.setUrl(module.getServer());
    dependencies.add(dependencyServer);
    vo.setDependencies(dependencies.toArray(new MonitoringDependencyVO[dependencies.size()]));
    return Response.ok(vo).build();
}
Also used : MonitoringInfosVO(org.olat.restapi.system.vo.MonitoringInfosVO) ArrayList(java.util.ArrayList) InstantMessagingModule(org.olat.instantMessaging.InstantMessagingModule) DB(org.olat.core.commons.persistence.DB) MonitoringDependencyVO(org.olat.restapi.system.vo.MonitoringDependencyVO) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with MonitoringInfosVO

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

the class MonitoringWebService method getImplementedProbes.

/**
 * Return the configuration of the monitoring, which probes are available,
 * which dependency...
 *
 * @response.representation.200.qname {http://www.example.com}releaseVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The verison of the instance
 * @response.representation.200.example {@link org.olat.restapi.system.vo.Examples#SAMPLE_MONITORINGCONFIGVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @param request The HTTP request
 * @return The informations about the memory
 */
@GET
@Path("configuration")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getImplementedProbes() {
    MonitoringInfosVO vo = new MonitoringInfosVO();
    MonitoringModule module = CoreSpringFactory.getImpl(MonitoringModule.class);
    String probesConfig = module.getMonitoredProbes();
    String[] probes;
    if (StringHelper.containsNonWhitespace(probesConfig)) {
        probes = probesConfig.split(",");
    } else {
        probes = new String[0];
    }
    vo.setProbes(probes);
    vo.setType(SystemRegistrationManager.PRODUCT);
    vo.setDescription(module.getDescription());
    List<MonitoringDependencyVO> dependencies = new ArrayList<MonitoringDependencyVO>();
    InstantMessagingModule imConfig = CoreSpringFactory.getImpl(InstantMessagingModule.class);
    if (imConfig.isEnabled()) {
        MonitoringDependencyVO dependency = new MonitoringDependencyVO();
        dependency.setType("openfire");
        dependency.setUrl("");
        dependencies.add(dependency);
    }
    DB dbInstance = CoreSpringFactory.getImpl(DB.class);
    MonitoringDependencyVO dependency = new MonitoringDependencyVO();
    dependency.setType(dbInstance.getDbVendor());
    dependency.setUrl(module.getDatabaseHost());
    dependencies.add(dependency);
    MonitoringDependencyVO dependencyServer = new MonitoringDependencyVO();
    dependencyServer.setType("server");
    dependencyServer.setUrl(module.getServer());
    dependencies.add(dependencyServer);
    vo.setDependencies(dependencies.toArray(new MonitoringDependencyVO[dependencies.size()]));
    return Response.ok(vo).build();
}
Also used : MonitoringInfosVO(org.olat.restapi.system.vo.MonitoringInfosVO) ArrayList(java.util.ArrayList) InstantMessagingModule(org.olat.instantMessaging.InstantMessagingModule) DB(org.olat.core.commons.persistence.DB) MonitoringDependencyVO(org.olat.restapi.system.vo.MonitoringDependencyVO) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

MonitoringInfosVO (org.olat.restapi.system.vo.MonitoringInfosVO)4 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Test (org.junit.Test)2 DB (org.olat.core.commons.persistence.DB)2 InstantMessagingModule (org.olat.instantMessaging.InstantMessagingModule)2 MonitoringDependencyVO (org.olat.restapi.system.vo.MonitoringDependencyVO)2