[修改]node-exporter特权模式

This commit is contained in:
10908
2024-09-23 14:40:41 +08:00
committed by Coding
parent 0938336791
commit d59cf061ab
4 changed files with 11 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ class NetworkMonitor extends ChartWidget
if ($selectedFilter === 'upload') {
// 查询过去 1 分钟内每秒的上传流量
$uploadQuery = 'rate(node_network_transmit_bytes_total[1m])';
$uploadQuery = 'rate(node_network_transmit_bytes_total{device="eth0"}[1m])';
$uploadResult = $prometheus->queryRange(
$uploadQuery,
now()->subMinutes(1)->timestamp,
@@ -55,14 +55,14 @@ class NetworkMonitor extends ChartWidget
foreach ($timestamps as $timestamp) {
$labels[] = date('H:i:s', $timestamp); // 格式化时间戳为小时:分钟:秒
$uploadData[] = round(floatval($uploadValues[$timestamp]) / (1024 * 1024), 2); // 转换为 MB/s
$uploadData[] = round(floatval($uploadValues[$timestamp]) / (1024*1024), 2); // 转换为 MB/s
}
}
}
if ($selectedFilter === 'download') {
// 查询过去 1 分钟内每秒的下载流量
$downloadQuery = 'rate(node_network_receive_bytes_total[1m])';
$downloadQuery = 'rate(node_network_receive_bytes_total{device="eth0"}[1m])';
$downloadResult = $prometheus->queryRange(
$downloadQuery,
now()->subMinutes(1)->timestamp,