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);
}
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();
}
Aggregations