[修改]node-exporter特权模式修正

This commit is contained in:
10908
2024-09-25 10:57:51 +08:00
committed by Coding
parent 359709d7b5
commit d233af6f50
4 changed files with 11 additions and 9 deletions

View File

@@ -22,7 +22,9 @@ services:
- prometheus
node-exporter:
build: docker/node_exporter
privileged: true
# privileged: true
network_mode: host
pid: host
volumes:
- '/:/host:ro'
opcua-exporter:

View File

@@ -24,4 +24,4 @@ RUN architecture=$(uname -m); \
RUN mkdir /host
CMD ["node_exporter","--path.rootfs=/host"]
CMD ["node_exporter","--path.rootfs=/host","--web.listen-address=0.0.0.0:9100"]

View File

@@ -4,7 +4,7 @@ global:
scrape_configs:
- job_name: 'node_exporter'
static_configs:
- targets: [ 'node-exporter:9100' ]
- targets: [ '172.17.0.1:9100' ]
- job_name: 'opcua_exporter'
static_configs:

View File

@@ -36,7 +36,7 @@ class NetworkMonitor extends ChartWidget
if ($selectedFilter === 'upload') {
// 查询过去 1 分钟内每秒的上传流量
$uploadQuery = 'rate(node_network_transmit_bytes_total{device="eth0"}[1m])';
$uploadQuery = 'rate(node_network_transmit_bytes_total{device!~"^(veth.*|docker.*|lo|br-.*)$"}[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, 2); // 转换为 MB/s
}
}
}
if ($selectedFilter === 'download') {
// 查询过去 1 分钟内每秒的下载流量
$downloadQuery = 'rate(node_network_receive_bytes_total{device="eth0"}[1m])';
$downloadQuery = 'rate(node_network_receive_bytes_total{device!~"^(veth.*|docker.*|lo|br-.*)$"}[1m])';
$downloadResult = $prometheus->queryRange(
$downloadQuery,
now()->subMinutes(1)->timestamp,
@@ -80,7 +80,7 @@ class NetworkMonitor extends ChartWidget
foreach ($timestamps as $timestamp) {
$labels[] = date('H:i:s', $timestamp); // 格式化时间戳为小时:分钟:秒
$downloadData[] = round(floatval($downloadValues[$timestamp]) / (1024 * 1024), 2); // 转换为 MB/s
$downloadData[] = round(floatval($downloadValues[$timestamp]) / 1024, 2); // 转换为 MB/s
}
}
}
@@ -89,7 +89,7 @@ class NetworkMonitor extends ChartWidget
$datasets = [];
if ($selectedFilter === 'upload') {
$datasets[] = [
'label' => '上传流量 (MB/s)',
'label' => '上传流量 (KB/s)',
'data' => $uploadData,
'borderColor' => 'rgba(255, 99, 132, 0.6)',
'backgroundColor' => 'rgba(255, 99, 132, 0.2)',
@@ -98,7 +98,7 @@ class NetworkMonitor extends ChartWidget
}
if ($selectedFilter === 'download') {
$datasets[] = [
'label' => '下载流量 (MB/s)',
'label' => '下载流量 (KB/s)',
'data' => $downloadData,
'borderColor' => 'rgba(54, 162, 235, 0.6)',
'backgroundColor' => 'rgba(54, 162, 235, 0.2)',