支持服务器详情24h流量统计
This commit is contained in:
@@ -204,6 +204,8 @@ async function getOverviewMetrics(url, sourceName) {
|
||||
diskFreeResult,
|
||||
netRxResult,
|
||||
netTxResult,
|
||||
netRx24hResult,
|
||||
netTx24hResult,
|
||||
targetsResult
|
||||
] = await Promise.all([
|
||||
// CPU usage per instance: 1 - avg idle
|
||||
@@ -222,6 +224,10 @@ async function getOverviewMetrics(url, sourceName) {
|
||||
query(url, 'sum by (instance, job) (rate(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[1m]))').catch(() => []),
|
||||
// Network transmit rate (bytes/sec)
|
||||
query(url, 'sum by (instance, job) (rate(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[1m]))').catch(() => []),
|
||||
// 24h Network receive total (bytes)
|
||||
query(url, 'sum by (instance, job) (increase(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[24h]))').catch(() => []),
|
||||
// 24h Network transmit total (bytes)
|
||||
query(url, 'sum by (instance, job) (increase(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[24h]))').catch(() => []),
|
||||
// Targets status from /api/v1/targets
|
||||
getTargets(url).catch(() => [])
|
||||
]);
|
||||
@@ -254,6 +260,8 @@ async function getOverviewMetrics(url, sourceName) {
|
||||
diskUsed: 0,
|
||||
netRx: 0,
|
||||
netTx: 0,
|
||||
traffic24hRx: 0,
|
||||
traffic24hTx: 0,
|
||||
up: false,
|
||||
memPercent: 0,
|
||||
diskPercent: 0
|
||||
@@ -322,6 +330,16 @@ async function getOverviewMetrics(url, sourceName) {
|
||||
inst.netTx = parseFloat(r.value[1]) || 0;
|
||||
}
|
||||
|
||||
// Parse 24h traffic
|
||||
for (const r of netRx24hResult) {
|
||||
const inst = getOrCreate(r.metric);
|
||||
inst.traffic24hRx = parseFloat(r.value[1]) || 0;
|
||||
}
|
||||
for (const r of netTx24hResult) {
|
||||
const inst = getOrCreate(r.metric);
|
||||
inst.traffic24hTx = parseFloat(r.value[1]) || 0;
|
||||
}
|
||||
|
||||
for (const inst of instances.values()) {
|
||||
if (!inst.up && (inst.cpuPercent > 0 || inst.memTotal > 0)) {
|
||||
inst.up = true;
|
||||
|
||||
Reference in New Issue
Block a user