Search in sources :

Example 1 with StatusSummary

use of org.opennms.features.status.api.StatusSummary in project opennms by OpenNMS.

the class NodeStatusService method getSummary.

public StatusSummary getSummary(NodeStatusCalculationStrategy strategy) {
    final NodeStatusCalculatorConfig config = new NodeStatusCalculatorConfig();
    config.setSeverities(Lists.newArrayList(OnmsSeverity.NORMAL, OnmsSeverity.WARNING, OnmsSeverity.MINOR, OnmsSeverity.MAJOR, OnmsSeverity.CRITICAL));
    config.setCalculationStrategy(strategy);
    final Map<OnmsSeverity, Long> statusOverviewMap = statusCalculator.calculateStatusOverview(config);
    final long totalCount = nodeDao.countAll();
    return new StatusSummary(statusOverviewMap, totalCount);
}
Also used : StatusSummary(org.opennms.features.status.api.StatusSummary) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) NodeStatusCalculatorConfig(org.opennms.features.status.api.node.strategy.NodeStatusCalculatorConfig)

Example 2 with StatusSummary

use of org.opennms.features.status.api.StatusSummary in project opennms by OpenNMS.

the class StatusRestService method getNodeStatus.

@GET
@Path("/summary/nodes/{type}")
public Response getNodeStatus(@PathParam("type") String type) {
    final NodeStatusCalculationStrategy strategy = NodeStatusCalculationStrategy.createFrom(type);
    if (strategy == null) {
        return Response.status(Response.Status.BAD_REQUEST).entity("Strategy '" + type + "' not supported. Supported values are:" + Arrays.toString(NodeStatusCalculationStrategy.values())).build();
    }
    final StatusSummary summary = nodeStatusService.getSummary(strategy);
    return Response.ok().entity(convert(summary)).build();
}
Also used : StatusSummary(org.opennms.features.status.api.StatusSummary) NodeStatusCalculationStrategy(org.opennms.features.status.api.node.strategy.NodeStatusCalculationStrategy) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

StatusSummary (org.opennms.features.status.api.StatusSummary)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 NodeStatusCalculationStrategy (org.opennms.features.status.api.node.strategy.NodeStatusCalculationStrategy)1 NodeStatusCalculatorConfig (org.opennms.features.status.api.node.strategy.NodeStatusCalculatorConfig)1 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)1