/** {@inheritDoc} */ @Override public void updateFile(List<Object> rrd, String owner, String data) throws Exception { for (int i = 0; i < rrd.size(); i++) { m_strategies.get(i).updateFile(rrd.get(i), owner, data); } } }
/** {@inheritDoc} */ @Override public void updateFile(List<Object> rrd, String owner, String data) throws Exception { for (int i = 0; i < rrd.size(); i++) { m_strategies.get(i).updateFile(rrd.get(i), owner, data); } } }
try { rrd = strategy.openFile(rrdFile); strategy.updateFile(rrd, owner, updateVal); } catch (Throwable e) { LOG.error("updateRRD: Error updating RRD file {} with values '{}'", rrdFile, updateVal, e);
try { rrd = strategy.openFile(rrdFile); strategy.updateFile(rrd, owner, updateVal); } catch (Throwable e) { LOG.error("updateRRD: Error updating RRD file {} with values '{}'", rrdFile, updateVal, e);
@Override Object process(Object rrd) throws Exception { // open the file if we need to if (rrd == null) rrd = m_delegate.openFile(getFileName()); final String update = (String) getData(); try { // process the update m_delegate.updateFile(rrd, "", update); } catch (final Throwable e) { final String error = String.format("Error processing update for file %s: %s", getFileName(), update); m_log.debug(error, e); throw new Exception(error, e); } // keep stats setUpdatesCompleted(getUpdatesCompleted() + 1); if (getUpdatesCompleted() % m_modulus == 0) { logStats(); } // return the open rrd for further processing return rrd; }
@Override Object process(Object rrd) throws Exception { // open the file if we need to if (rrd == null) rrd = m_delegate.openFile(getFileName()); final String update = (String) getData(); try { // process the update m_delegate.updateFile(rrd, "", update); } catch (final Throwable e) { final String error = String.format("Error processing update for file %s: %s", getFileName(), update); m_log.debug(error, e); throw new Exception(error, e); } // keep stats setUpdatesCompleted(getUpdatesCompleted() + 1); if (getUpdatesCompleted() % m_modulus == 0) { logStats(); } // return the open rrd for further processing return rrd; }
@Override Object process(Object rrd) throws Exception { long ts = getFirstTimeStamp(); for (int i = 0; i < count; i++) { // open the file if we need to if (rrd == null) rrd = m_delegate.openFile(getFileName()); String update = ts + ":0"; try { // process the update m_delegate.updateFile(rrd, "", update); } catch (Throwable e) { throw new Exception("Error processing update " + i + " for file " + getFileName() + ": " + update, e); } ts += getInterval(); // keep stats setUpdatesCompleted(getUpdatesCompleted() + 1); if (getUpdatesCompleted() % m_modulus == 0) { logStats(); } } return rrd; }
@Override Object process(Object rrd) throws Exception { long ts = getFirstTimeStamp(); for (int i = 0; i < count; i++) { // open the file if we need to if (rrd == null) rrd = m_delegate.openFile(getFileName()); String update = ts + ":0"; try { // process the update m_delegate.updateFile(rrd, "", update); } catch (Throwable e) { throw new Exception("Error processing update " + i + " for file " + getFileName() + ": " + update, e); } ts += getInterval(); // keep stats setUpdatesCompleted(getUpdatesCompleted() + 1); if (getUpdatesCompleted() % m_modulus == 0) { logStats(); } } return rrd; }
@Test @Transactional @JUnitCollector( datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config.xml", datacollectionType = "snmp", anticipateRrds = { "test" }, anticipateMetaFiles = false ) public void testUsingFetch() throws Exception { System.err.println("=== testUsingFetch ==="); File snmpDir = (File)m_context.getAttribute("rrdDirectory"); // We initialize an empty attribute map, key=e.g OID; value=e.g. datasource name Map<String,String> attributeMappings = new HashMap<String, String>(); int stepSize = 1; int numUpdates = 2; long start = System.currentTimeMillis(); final int stepSizeInMillis = stepSize*1000; final int rangeSizeInMillis = stepSizeInMillis + 20000; File rrdFile = new File(snmpDir, rrd("test")); RrdStrategy<RrdDef,RrdDb> m_rrdStrategy = new JRobinRrdStrategy(); RrdDataSource rrdDataSource = new RrdDataSource("testAttr", RrdAttributeType.GAUGE, stepSize*2, "U", "U"); RrdDef def = m_rrdStrategy.createDefinition("test", snmpDir.getAbsolutePath(), "test", stepSize, Collections.singletonList(rrdDataSource), Collections.singletonList("RRA:AVERAGE:0.5:1:100")); m_rrdStrategy.createFile(def); RrdDb rrdFileObject = m_rrdStrategy.openFile(rrdFile.getAbsolutePath()); for (int i = 0; i < numUpdates; i++) { m_rrdStrategy.updateFile(rrdFileObject, "test", ((start/1000) - (stepSize*(numUpdates-i))) + ":1"); } m_rrdStrategy.closeFile(rrdFileObject); assertEquals(Double.valueOf(1.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "testAttr", stepSizeInMillis, rangeSizeInMillis)); }
m_rrdStrategy.updateFile(EasyMock.isNull(), EasyMock.eq("192.168.1.5"), EasyMock.endsWith(":42.1:1:2:3")); EasyMock.expectLastCall().once();
m_rrdStrategy.updateFile(isA(Object.class), isA(String.class), matches(".*:" + matchValue)); m_rrdStrategy.closeFile(isA(Object.class));