You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于通过Restful服务获取OpenNMS Availability by node报告的技术咨询

获取OpenNMS「Availability by node」报告的REST实现方案

Got it, I’ve run into this exact issue before with OpenNMS—there isn’t a single dedicated REST endpoint that directly spits out the exact "Availability by node" report you see in the UI, but you can absolutely build this yourself using existing OpenNMS REST APIs. Here’s how I’ve done it:

1. 先获取目标节点的基础信息

First, pull the list of nodes you want to report on using the nodes API. This lets you filter by category, foreign source, or just grab all nodes:

  • 单个节点查询:GET /rest/nodes/{nodeId}
  • 批量节点查询:GET /rest/nodes (add query params like category=Servers to filter results)

This returns core details like nodeId, nodeLabel, and current status (Up/Down) for each node—perfect for building the base of your report.

2. 拉取节点的时间范围可用性数据

OpenNMS has a dedicated availability API that calculates uptime/downtime percentages for any node over a specified window. Use this to get the actual availability metrics:

  • Request format: GET /rest/availability/nodes/{nodeId}?start={startTime}&end={endTime}
  • Or use relative time for simplicity (e.g., past week: GET /rest/availability/nodes/{nodeId}?relative=1w)

The response will include metrics like availabilityPercentage, upTime, downTime, and unresponsiveTime—exactly the data you need for the "Availability by node" breakdown.

3. 组合数据生成自定义报告

To replicate the full report:

  1. Call the nodes API to get your target node list
  2. Loop through each nodeId and call the availability API for your desired time range
  3. Merge the node metadata (label, status) with the availability metrics into a JSON/XML structure that matches your needs

Here’s a quick curl example to test:

# Get all nodes in the "Database" category
curl -u admin:admin "http://your-opennms:8980/opennms/rest/nodes?category=Database"

# Get availability for node ID 42 over the past 30 days
curl -u admin:admin "http://your-opennms:8980/opennms/rest/availability/nodes/42?relative=30d"

4. Bonus: Exporting the native UI report format

If you need the exact same output as the UI’s "Availability by node" report (e.g., PDF/CSV), you can use the reports API:

  1. First get the list of available reports with GET /rest/reports to find the ID for the "Availability by node" report
  2. Then call GET /rest/reports/{reportId}/pdf or GET /rest/reports/{reportId}/csv to download the pre-generated report file (note: this returns binary data, so you’ll need to handle the download accordingly)

Quick Notes

  • Make sure your OpenNMS version is 19.0+—these REST endpoints were standardized around that release
  • Always use Basic Auth (include your admin credentials in the request)
  • Double-check time format if using absolute dates: use yyyy-MM-dd'T'HH:mm:ss.SSSZ (e.g., 2024-01-01T00:00:00.000Z)

内容的提问来源于stack exchange,提问作者Sumit Mehta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:05:58