[修改]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

@@ -27,14 +27,14 @@ class SystemStats extends BaseWidget
$memoryDisplay = round($memoryUsed / (1024 * 1024 * 1024), 2) . ' GB / ' . round($memoryTotal / (1024 * 1024 * 1024), 2) . ' GB';
// 获取硬盘总量
$diskTotalQuery = 'node_filesystem_size_bytes{fstype!="rootfs",fstype!="tmpfs",fstype!="squashfs"}';
$diskTotalQuery = 'node_filesystem_size_bytes{fstype!="rootfs",fstype!="tmpfs",fstype!="squashfs",mountpoint=~"/|/home|/boot"}';
$diskTotalResult = $prometheus->query($diskTotalQuery);
$diskTotal = array_sum(array_map(function ($item) {
return $item['value'][1] ?? 0;
}, $diskTotalResult['data']['result']));
// 获取已用硬盘
$diskFreeQuery = 'node_filesystem_free_bytes{fstype!="rootfs",fstype!="tmpfs",fstype!="squashfs"}';
$diskFreeQuery = 'node_filesystem_free_bytes{fstype!="rootfs",fstype!="tmpfs",fstype!="squashfs",mountpoint=~"/|/home|/boot"}';
$diskFreeResult = $prometheus->query($diskFreeQuery);
$diskFree = array_sum(array_map(function ($item) {
return $item['value'][1] ?? 0;