Search in sources :

Example 1 with ServiceGraph

use of org.opennms.web.svclayer.model.DistributedStatusHistoryModel.ServiceGraph in project opennms by OpenNMS.

the class DefaultDistributedStatusService method getServiceGraphForService.

private ServiceGraph getServiceGraphForService(OnmsLocationMonitor locMon, OnmsMonitoredService service, long[] times) {
    OnmsResource resource;
    try {
        resource = m_resourceDao.getResourceForIpInterface(service.getIpInterface(), locMon);
    } catch (ObjectRetrievalFailureException e) {
        resource = null;
    }
    if (resource == null) {
        return new ServiceGraph(service, new String[] { "Resource could not be found.  Has any response time data been collected for this service from this remote poller?" });
    }
    String graphName = service.getServiceName().toLowerCase();
    try {
        m_graphDao.getPrefabGraph(graphName);
    } catch (ObjectRetrievalFailureException e) {
        return new ServiceGraph(service, new String[] { "Graph definition could not be found for '" + graphName + "'.  A graph definition needs to be created for this service." });
    }
    PrefabGraph[] prefabGraphs = m_graphDao.getPrefabGraphsForResource(resource);
    for (PrefabGraph graph : prefabGraphs) {
        if (graph.getName().equals(graphName)) {
            String url = "graph/graph.png" + "?report=" + Util.encode(graph.getName()) + "&resourceId=" + Util.encode(resource.getId().toString()) + "&start=" + times[0] + "&end=" + times[1];
            return new ServiceGraph(service, url);
        }
    }
    return new ServiceGraph(service, new String[] { "Graph could not be found for '" + graphName + "' on this resource.  Has any response time data been collected for this service from this remote poller and is the graph definition correct?" });
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) PrefabGraph(org.opennms.netmgt.model.PrefabGraph) ServiceGraph(org.opennms.web.svclayer.model.DistributedStatusHistoryModel.ServiceGraph) ObjectRetrievalFailureException(org.springframework.orm.ObjectRetrievalFailureException)

Example 2 with ServiceGraph

use of org.opennms.web.svclayer.model.DistributedStatusHistoryModel.ServiceGraph in project opennms by OpenNMS.

the class DefaultDistributedStatusService method initializeGraphUrls.

private void initializeGraphUrls(DistributedStatusHistoryModel model) {
    if (model.getChosenMonitor() != null) {
        Collection<OnmsMonitoredService> services = model.getChosenApplicationMemberServices();
        long[] times = model.getChosenPeriod().getStartAndEndTimes();
        SortedSet<ServiceGraph> serviceGraphs = new TreeSet<ServiceGraph>(SERVICE_GRAPH_COMPARATOR);
        for (OnmsMonitoredService service : services) {
            serviceGraphs.add(getServiceGraphForService(model.getChosenMonitor(), service, times));
        }
        model.setServiceGraphs(serviceGraphs);
    }
}
Also used : TreeSet(java.util.TreeSet) ServiceGraph(org.opennms.web.svclayer.model.DistributedStatusHistoryModel.ServiceGraph) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Aggregations

ServiceGraph (org.opennms.web.svclayer.model.DistributedStatusHistoryModel.ServiceGraph)2 TreeSet (java.util.TreeSet)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)1 ObjectRetrievalFailureException (org.springframework.orm.ObjectRetrievalFailureException)1