Search in sources :

Example 1 with PrefabGraph

use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.

the class GraphRestService method getGraphNames.

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Transactional(readOnly = true)
public GraphNameCollection getGraphNames() {
    List<String> graphNames = Lists.newLinkedList();
    for (PrefabGraph prefabGraph : m_graphDao.getAllPrefabGraphs()) {
        graphNames.add(prefabGraph.getName());
    }
    Collections.sort(graphNames);
    return new GraphNameCollection(graphNames);
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with PrefabGraph

use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.

the class GraphRestService method getGraphNamesForResource.

private GraphNameCollection getGraphNamesForResource(final OnmsResource resource) {
    List<String> graphNames = Lists.newLinkedList();
    for (PrefabGraph prefabGraph : m_graphDao.getPrefabGraphsForResource(resource)) {
        graphNames.add(prefabGraph.getName());
    }
    Collections.sort(graphNames);
    return new GraphNameCollection(graphNames);
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph)

Example 3 with PrefabGraph

use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.

the class NrtHelperTest method testStringProperties.

@Test
public void testStringProperties() {
    String rawString = "--title='Current TCP Connections' --vertical-label='Current Connections ({ifSpeed})' DEF:currEstab={rrd1}:tcpCurrEstab:AVERAGE DEF:minCurrEstab={rrd1}:tcpCurrEstab:MIN DEF:maxCurrEstab={rrd1}:tcpCurrEstab:MAX LINE2:currEstab#00ff00:'Current ' GPRINT:currEstab:AVERAGE:'Avg  \n: %8.2lf %s' GPRINT:currEstab:MIN:'Min  \n: %8.2lf %s' GPRINT:currEstab:MAX:'Max  \n: %8.2lf %s\n'";
    final Map<String, String> properties = new HashMap<String, String>();
    properties.put("ifSpeed", "monkey");
    final PrefabGraph prefabGraph = new PrefabGraph("foo", "bar", new String[] {}, rawString, new String[] {}, new String[] {}, 0, null, null, null, null, new String[] {});
    final String graphString = nrtHelper.cleanUpRrdGraphStringForWebUi(prefabGraph, m_emptyMap, properties);
    assertTrue(graphString.contains("(monkey)"));
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 4 with PrefabGraph

use of org.opennms.netmgt.model.PrefabGraph 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 5 with PrefabGraph

use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.

the class PropertiesGraphDaoIT method testCompareToLessThan.

@Test
public void testCompareToLessThan() {
    PrefabGraph bits = m_graphs.get("mib2.bits").getObject();
    PrefabGraph discards = m_graphs.get("mib2.discards").getObject();
    ;
    assertEquals("compareTo", -1, bits.compareTo(discards));
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph) Test(org.junit.Test)

Aggregations

PrefabGraph (org.opennms.netmgt.model.PrefabGraph)50 Test (org.junit.Test)28 OnmsResource (org.opennms.netmgt.model.OnmsResource)16 File (java.io.File)8 ArrayList (java.util.ArrayList)8 FileSystemResource (org.springframework.core.io.FileSystemResource)8 HashMap (java.util.HashMap)7 ObjectRetrievalFailureException (org.springframework.orm.ObjectRetrievalFailureException)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)5 Resource (org.springframework.core.io.Resource)5 FileOutputStream (java.io.FileOutputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)4 HashSet (java.util.HashSet)4 Report (org.opennms.netmgt.config.kscReports.Report)4 MockResourceType (org.opennms.netmgt.mock.MockResourceType)4 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)4 Calendar (java.util.Calendar)3 LinkedHashMap (java.util.LinkedHashMap)3 Graph (org.opennms.netmgt.config.kscReports.Graph)3