gpt4 book ai didi

java - Hyperic Java API

转载 作者:行者123 更新时间:2023-12-01 05:43:27 25 4
gpt4 key购买 nike

我编写了一些 Java 代码,通过它们从 Hyperic Server 获取某些操作的指标。我无法获取这些指标的值。

对于 eq,我有公制 CPU 空闲,但是当我使用 List<Data Point> dp= m1.getDataPoint() 时哪里m1是指标CPU Idle 的指标数据对象。在输出中,列表的大小 dp0 .

除“可用性”之外的所有指标都存在此问题。我该怎么办?

我还检查了图形界面中的时间间隔;它显示相应的值。

代码是

 //  m_rrc is resource ( Process Server) on agent
for (int z = 0; z < m_rrrc.size(); z++) {
System.out.println(m_rrrc.get(z).getName())
MetricsResponse m_mr= m_a.getMetrics(m_rrrc.get(z));

// m_m is metric like CPU idle CPU utilization, System CPU
List<Metric> m_m = m_mr.getMetric();

for (int a = 0; a < m_m.size(); a++) {
MetricDataResponse m_mdr = m_mdapi.getData(m_m.get(a), 1309147200,1309147800);
MetricData m_md = m_mdr.getMetricData();

System.out.println(m_md.getMetricName());

List<DataPoint> m_dp = m_md.getDataPoint();
System.out.println(m_dp.size());

for (int b = 0; b < m_dp.size(); b++) {
System.out.println("abc");
System.out.println(m_dp.get(b).getValue());
System.out.println("i am Prannoy Mittal");
}
}
}

此处所有指标输出中的数据点列表大小为零

最佳答案

这是来自 Hyperic ( http://svn.hyperic.org/projects/hqapi/trunk/src/org/hyperic/hq/hqapi1/test/MetricData_test.java ) 的示例源代码,如果您可以在代码中添加正确的 'assertEquals' 我相信您会看到问题出在哪里。祝你好运

    public void testGetEnabledMetricData() throws Exception {

MetricApi api = getApi().getMetricApi();
Resource r = getLocalPlatformResource(false, false);
MetricsResponse resp = api.getEnabledMetrics(r);
hqAssertSuccess(resp);

assertTrue("No enabled metrics found for " + r.getName(),
resp.getMetric().size() > 0);
Metric m = resp.getMetric().get(0);

long end = System.currentTimeMillis();
long start = end - (8 * 60 * 60 * 1000);

MetricDataResponse dataResponse = api.getMetricData(m.getId(),
start, end);
hqAssertSuccess(dataResponse);
assertTrue("No metric data found for " + m.getName(),
dataResponse.getMetricData().getDataPoint().size() > 0);
for (DataPoint d : dataResponse.getMetricData().getDataPoint()) {

assertTrue("Metric point timestamp greater than end time. ts=" +
d.getTimestamp() + " end=" + end,
d.getTimestamp() <= end);
assertTrue("Metric point timestamp less than start time ts=" +
d.getTimestamp() + " start=" + start,
d.getTimestamp() >= start);
assertTrue("Metric value less than zero",
d.getValue() >= 0);
}
}

关于java - Hyperic Java API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6509309/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com