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