Search in sources :

Example 1 with DefaultRrdGraphDetails

use of org.opennms.netmgt.rrd.DefaultRrdGraphDetails in project opennms by OpenNMS.

the class DefaultRrdDaoTest method preparePrintValueTest.

private OnmsResource preparePrintValueTest(long start, long end, String printLine) throws IOException, RrdException {
    String rrdDir = "snmp" + File.separator + "1" + File.separator + "eth0";
    String rrdFile = "ifInOctets.jrb";
    String escapedFile = rrdDir + File.separator + rrdFile;
    if (File.separatorChar == '\\') {
        escapedFile = escapedFile.replace("\\", "\\\\");
    }
    String[] command = new String[] { m_dao.getRrdBinaryPath(), "graph", "-", "--start=" + (start / 1000), "--end=" + (end / 1000), "DEF:ds1=\"" + escapedFile + "\":ifInOctets:AVERAGE", "PRINT:ds1:AVERAGE:\"%le\"" };
    String commandString = StringUtils.arrayToDelimitedString(command, " ");
    OnmsResource topResource = new OnmsResource("1", "Node One", new MockResourceType(), new HashSet<OnmsAttribute>(0), new ResourcePath("foo"));
    OnmsAttribute attribute = new RrdGraphAttribute("ifInOctets", rrdDir, rrdFile);
    HashSet<OnmsAttribute> attributeSet = new HashSet<OnmsAttribute>(1);
    attributeSet.add(attribute);
    MockResourceType childResourceType = new MockResourceType();
    OnmsResource childResource = new OnmsResource("eth0", "Interface One: eth0", childResourceType, attributeSet, new ResourcePath("foo"));
    childResource.setParent(topResource);
    DefaultRrdGraphDetails details = new DefaultRrdGraphDetails();
    details.setPrintLines(new String[] { printLine });
    expect(m_rrdStrategy.createGraphReturnDetails(commandString, m_dao.getRrdBaseDirectory())).andReturn(details);
    return childResource;
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) DefaultRrdGraphDetails(org.opennms.netmgt.rrd.DefaultRrdGraphDetails) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute) RrdGraphAttribute(org.opennms.netmgt.model.RrdGraphAttribute) MockResourceType(org.opennms.netmgt.mock.MockResourceType) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 MockResourceType (org.opennms.netmgt.mock.MockResourceType)1 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1 ResourcePath (org.opennms.netmgt.model.ResourcePath)1 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)1 DefaultRrdGraphDetails (org.opennms.netmgt.rrd.DefaultRrdGraphDetails)1