当前位置: 首页>>代码示例>>Java>>正文


Java RrdDb.getDatasource方法代码示例

本文整理汇总了Java中org.jrobin.core.RrdDb.getDatasource方法的典型用法代码示例。如果您正苦于以下问题:Java RrdDb.getDatasource方法的具体用法?Java RrdDb.getDatasource怎么用?Java RrdDb.getDatasource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jrobin.core.RrdDb的用法示例。


在下文中一共展示了RrdDb.getDatasource方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dump

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
private void dump(RrdDb rrd) throws IOException {
	StringBuffer line = new StringBuffer();
	int n = rrd.getDsCount();
	for (int i = 0; i < n; i++) {
		Datasource ds = rrd.getDatasource(i);
		line.append("DS[");
		line.append(ds.getDsName());
		line.append("] typ: ");
		line.append(ds.getDsType());
		while (line.length() < 24) {
			line.append(' ');
		}
		line.append("hbt: ");
		line.append(ds.getHeartbeat());
		while (line.length() < 40) {
			line.append(' ');
		}
		line.append("min: ");
		line.append(String.format("%-11f", ds.getMinValue()));
		line.append("max: ");
		line.append(String.format("%-11f", ds.getMaxValue()));
		println(line.toString());
		line.setLength(0);
	}
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:26,代码来源:RrdTuneCmd.java

示例2: execute

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
Object execute() throws RrdException, IOException, RrdException {
	boolean check = getBooleanOption("r", "range-check");
	String[] words = getRemainingWords();
	if (words.length != 3) {
		throw new RrdException("Invalid rrdrestore syntax");
	}
	String xmlPath = words[1];
	String rrdPath = words[2];
	RrdDb rrdDb = getRrdDbReference(rrdPath, xmlPath);
	try {
		if (check) {
			int dsCount = rrdDb.getHeader().getDsCount();
			for (int i = 0; i < dsCount; i++) {
				Datasource ds = rrdDb.getDatasource(i);
				double minValue = ds.getMinValue();
				double maxValue = ds.getMaxValue();
				// this will perform range check
				ds.setMinMaxValue(minValue, maxValue, true);
			}
		}
		return rrdPath;
	}
	finally {
		releaseRrdDbReference(rrdDb);
	}
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:27,代码来源:RrdRestoreCmd.java

示例3: validateJrb

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
/**
 * Validates a JRB.
 * <p>It assumes storeByGroup=true</p>
 * 
 * @param file the JRB file instance
 * @param dsnames the array of data source names
 * @param dsvalues the array of data source values
 * @throws Exception the exception
 */
public void validateJrb(File file, String[] dsnames, Double[] dsvalues) throws Exception {
    Assert.assertTrue(file.exists());
    RrdDb jrb = new RrdDb(file);
    Assert.assertEquals(dsnames.length, jrb.getDsCount());
    for (int i = 0; i < dsnames.length; i++) {
        Datasource ds = jrb.getDatasource(dsnames[i]);
        Assert.assertNotNull(ds);
        Assert.assertEquals(dsvalues[i], Double.valueOf(ds.getLastValue()));
    }

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:AbstractJsonCollectorTest.java

示例4: testHttpCollection

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
/**
 * Test HTTP Data Collection with XPath
 *
 * @throws Exception the exception
 */
@Test
@JUnitHttpServer(port=10342, https=false, webapps={
        @Webapp(context="/junit", path="src/test/resources/test-webapp")
})
public void testHttpCollection() throws Exception {
    File configFile = new File("src/test/resources/http-datacollection-config.xml");
    XmlDataCollectionConfig config = JaxbUtils.unmarshal(XmlDataCollectionConfig.class, configFile);
    XmlDataCollection collection = config.getDataCollectionByName("Http-Count");
    RrdRepository repository = createRrdRepository(collection.getXmlRrd());

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("collection", "Http-Count");

    DefaultXmlCollectionHandler collector = new DefaultXmlCollectionHandler();
    collector.setNodeDao(m_nodeDao);
    collector.setRrdRepository(repository);
    collector.setServiceName("HTTP");

    XmlCollectionSet collectionSet = collector.collect(m_collectionAgent, collection, parameters);
    Assert.assertEquals(ServiceCollector.COLLECTION_SUCCEEDED, collectionSet.getStatus());

    ServiceParameters serviceParams = new ServiceParameters(new HashMap<String,Object>());
    BasePersister persister =  new GroupPersister(serviceParams, repository); // storeByGroup=true;
    collectionSet.visit(persister);

    RrdDb jrb = new RrdDb(new File("target/snmp/1/count-stats.jrb"));
    Assert.assertNotNull(jrb);
    Assert.assertEquals(1, jrb.getDsCount());
    Datasource ds = jrb.getDatasource("count");
    Assert.assertNotNull(ds);
    Assert.assertEquals(new Double(5), Double.valueOf(ds.getLastValue()));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:38,代码来源:HttpDataCollectionTest.java

示例5: testCssSelectorHttpCollection

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
/**
 * Test HTTP Data Collection with CSS Selector
 *
 * @throws Exception the exception
 */
@Test
@JUnitHttpServer(port=10342, https=false, webapps={
        @Webapp(context="/junit", path="src/test/resources/test-webapp")
})
public void testCssSelectorHttpCollection() throws Exception {
    File configFile = new File("src/test/resources/http-datacollection-config.xml");
    XmlDataCollectionConfig config = JaxbUtils.unmarshal(XmlDataCollectionConfig.class, configFile);
    XmlDataCollection collection = config.getDataCollectionByName("Http-Market");
    RrdRepository repository = createRrdRepository(collection.getXmlRrd());

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("collection", "Http-Market");

    HttpCollectionHandler collector = new HttpCollectionHandler();
    collector.setNodeDao(m_nodeDao);
    collector.setRrdRepository(repository);
    collector.setServiceName("HTTP");

    XmlCollectionSet collectionSet = collector.collect(m_collectionAgent, collection, parameters);
    Assert.assertEquals(ServiceCollector.COLLECTION_SUCCEEDED, collectionSet.getStatus());

    ServiceParameters serviceParams = new ServiceParameters(new HashMap<String,Object>());
    BasePersister persister =  new GroupPersister(serviceParams, repository); // storeByGroup=true;
    collectionSet.visit(persister);

    RrdDb jrb = new RrdDb(new File("target/snmp/1/market.jrb"));
    Assert.assertNotNull(jrb);
    Assert.assertEquals(2, jrb.getDsCount());
    Datasource ds = jrb.getDatasource("nasdaq");
    Assert.assertNotNull(ds);
    Assert.assertEquals(new Double(3578.30), Double.valueOf(ds.getLastValue()));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:38,代码来源:HttpDataCollectionTest.java

示例6: testJsonHttpCollection

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
/**
 * Test HTTP Data Collection with JSON
 *
 * @throws Exception the exception
 */
@Test
@JUnitHttpServer(port=10342, https=false, webapps={
        @Webapp(context="/junit", path="src/test/resources/test-webapp")
})
public void testJsonHttpCollection() throws Exception {
    File configFile = new File("src/test/resources/solaris-zones-datacollection-config.xml");
    XmlDataCollectionConfig config = JaxbUtils.unmarshal(XmlDataCollectionConfig.class, configFile);
    XmlDataCollection collection = config.getDataCollectionByName("Solaris");
    RrdRepository repository = createRrdRepository(collection.getXmlRrd());

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("collection", "Solaris");

    DefaultJsonCollectionHandler collector = new DefaultJsonCollectionHandler();
    collector.setNodeDao(m_nodeDao);
    collector.setRrdRepository(repository);
    collector.setServiceName("HTTP");

    XmlCollectionSet collectionSet = collector.collect(m_collectionAgent, collection, parameters);
    Assert.assertEquals(ServiceCollector.COLLECTION_SUCCEEDED, collectionSet.getStatus());

    ServiceParameters serviceParams = new ServiceParameters(new HashMap<String,Object>());
    BasePersister persister =  new GroupPersister(serviceParams, repository); // storeByGroup=true;
    collectionSet.visit(persister);

    RrdDb jrb = new RrdDb(new File("target/snmp/1/solarisZoneStats/global/solaris-zone-stats.jrb"));
    Assert.assertNotNull(jrb);
    Assert.assertEquals(6, jrb.getDsCount());
    Datasource ds = jrb.getDatasource("nproc");
    Assert.assertNotNull(ds);
    Assert.assertEquals(new Double(245.0), Double.valueOf(ds.getLastValue()));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:38,代码来源:HttpDataCollectionTest.java

示例7: tuneHeartbeat

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
private void tuneHeartbeat(RrdDb rrd, String heartbeatStr) throws RrdException, IOException {
	String[] tokens = new ColonSplitter(heartbeatStr).split();
	if (tokens.length != 2) {
		throw new RrdException("Invalid suntax in: " + heartbeatStr);
	}
	String dsName = tokens[0];
	long heartbeat = Long.parseLong(tokens[1]);
	Datasource ds = rrd.getDatasource(dsName);
	ds.setHeartbeat(heartbeat);
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:11,代码来源:RrdTuneCmd.java

示例8: tuneMinimum

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
private void tuneMinimum(RrdDb rrd, String minimumStr) throws RrdException, IOException {
	String[] tokens = new ColonSplitter(minimumStr).split();
	if (tokens.length != 2) {
		throw new RrdException("Invalid suntax in: " + minimumStr);
	}
	String dsName = tokens[0];
	double minValue = Util.parseDouble(tokens[1]);
	Datasource ds = rrd.getDatasource(dsName);
	ds.setMinValue(minValue, false);
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:11,代码来源:RrdTuneCmd.java

示例9: tuneMaximum

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
private void tuneMaximum(RrdDb rrd, String maximumStr) throws RrdException, IOException {
	String[] tokens = new ColonSplitter(maximumStr).split();
	if (tokens.length != 2) {
		throw new RrdException("Invalid suntax in: " + maximumStr);
	}
	String dsName = tokens[0];
	double maxValue = Util.parseDouble(tokens[1]);
	Datasource ds = rrd.getDatasource(dsName);
	ds.setMaxValue(maxValue, false);
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:11,代码来源:RrdTuneCmd.java

示例10: tuneName

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
private void tuneName(RrdDb rrd, String nameStr) throws RrdException, IOException {
	String[] tokens = new ColonSplitter(nameStr).split();
	if (tokens.length != 2) {
		throw new RrdException("Invalid suntax in: " + nameStr);
	}
	String oldName = tokens[0], newName = tokens[1];
	Datasource ds = rrd.getDatasource(oldName);
	ds.setDsName(newName);
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:10,代码来源:RrdTuneCmd.java

示例11: tuneType

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
private void tuneType(RrdDb rrd, String typeStr) throws RrdException, IOException {
	String[] tokens = new ColonSplitter(typeStr).split();
	if (tokens.length != 2) {
		throw new RrdException("Invalid suntax in: " + typeStr);
	}
	String dsName = tokens[0];
	String dsType = tokens[1];
	Datasource ds = rrd.getDatasource(dsName);
	ds.setDsType(dsType);
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:11,代码来源:RrdTuneCmd.java

示例12: getInfo

import org.jrobin.core.RrdDb; //导入方法依赖的package包/类
private String getInfo(RrdDb rrd) throws IOException {
	StringBuffer b = new StringBuffer();
	b.append("filename = \"").append(rrd.getPath()).append("\"\n");
	b.append("rrd_version = \"0001\"\n");
	b.append("step = ").append(rrd.getHeader().getStep()).append("\n");
	b.append("last_update = ").append(rrd.getHeader().getLastUpdateTime()).append("\n");
	for (int i = 0; i < rrd.getDsCount(); i++) {
		Datasource ds = rrd.getDatasource(i);
		b.append("ds[").append(ds.getDsName()).append("].type = \"").append(ds.getDsType()).append("\"\n");
		b.append("ds[").append(ds.getDsName()).append("].minimal_heartbeat = ").
				append(ds.getHeartbeat()).append("\n");
		b.append("ds[").append(ds.getDsName()).append("].min = ").append(ds.getMinValue()).append("\n");
		b.append("ds[").append(ds.getDsName()).append("].max = ").append(ds.getMaxValue()).append("\n");
		b.append("ds[").append(ds.getDsName()).append("].last_ds = ").append(ds.getLastValue()).append("\n");
		b.append("ds[").append(ds.getDsName()).append("].value = ").append(ds.getAccumValue()).append("\n");
		b.append("ds[").append(ds.getDsName()).append("].unknown_sec = ").append(ds.getNanSeconds()).append("\n");
	}
	for (int i = 0; i < rrd.getArcCount(); i++) {
		Archive arc = rrd.getArchive(i);
		b.append("rra[").append(i).append("].cf = \"").append(arc.getConsolFun()).append("\"\n");
		b.append("rra[").append(i).append("].rows = ").append(arc.getRows()).append("\n");
		b.append("rra[").append(i).append("].pdp_per_row = ").append(arc.getSteps()).append("\n");
		b.append("rra[").append(i).append("].xff = ").append(arc.getXff()).append("\n");
		for (int j = 0; j < rrd.getDsCount(); j++) {
			b.append("rra[").append(i).append("].cdp_prep[").append(j).append("].value = ").
					append(arc.getArcState(j).getAccumValue()).append("\n");
			b.append("rra[").append(i).append("].cdp_prep[").append(j).append("].unknown_datapoints = ").
					append(arc.getArcState(j).getNanSteps()).append("\n");
		}
	}
	return b.toString();
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:33,代码来源:RrdInfoCmd.java


注:本文中的org.jrobin.core.RrdDb.getDatasource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。