feat(monitoring): GPU-aware btop variants and GPU metrics (#330)

This commit is contained in:
ryan4yin | 二花 authored and GitHub committed 2026-09-30 00:16:50 +08:00
1 parent 523f4940a7
commit 9ab5eca60c
14 files changed
+690 -10

No files matched your search

+2 -1
View File
@@ -21,7 +21,8 @@
# system monitoring
procs # a moreden ps
btop
# btop is provided per host: the GPU-aware `modules.btop` build on NixOS, or
# Home Manager on macOS. Not listed here to avoid a second, plain copy.
# archives
zip
+50
View File
@@ -0,0 +1,50 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.modules.btop;
in
{
options.modules.btop = {
package = lib.mkOption {
type = lib.types.package;
default = pkgs.btop;
defaultText = lib.literalExpression "pkgs.btop";
description = ''
btop build to install. The per-vendor GPU modules set this to
`btop-cuda`/`btop-rocm`, whose RUNPATH includes the vendor library that
btop otherwise cannot find (and Intel needs no library, only perf
access, see `perfmon`).
'';
};
perfmon = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Install btop as a `CAP_PERFMON` wrapper so it can read Intel GPU stats
without lowering `kernel.perf_event_paranoid` system-wide.
'';
};
};
config = {
# Exactly one btop per host: a plain package normally, or the capability
# wrapper only when `perfmon` is set. Home Manager skips its own copy on
# NixOS (see home/base/core/btop.nix).
environment.systemPackages = lib.optional (!cfg.perfmon) cfg.package;
# perf_event_paranoid stays at its default; only the wrapper gets the
# capability, and exactly one `btop` remains on PATH (/run/wrappers/bin).
security.wrappers = lib.mkIf cfg.perfmon {
btop = {
source = "${cfg.package}/bin/btop";
owner = "root";
group = "root";
capabilities = "cap_perfmon+ep";
};
};
};
}
@@ -25,6 +25,10 @@ in
# LAN/tailnet/local containers.
ip saddr != ${monitoringHost} tcp dport 9100 drop
# The NVIDIA GPU exporter (desktop only) is likewise scraped only by the
# monitoring host.
ip saddr != ${monitoringHost} tcp dport 9835 drop
# The local container bridge and the tailnet have the same access as the
# LAN. Kept after the drop above so neither can reach node_exporter.
iifname "podman0" accept
+5
View File
@@ -24,6 +24,11 @@ in
};
config = mkMerge [
# Mesa userspace (OpenGL/Vulkan) for every GUI host.
{
hardware.graphics.enable = true;
}
(mkIf cfgWayland.enable {
####################################################################
# NixOS's Configuration for Wayland based Window Manager
+1
View File
@@ -7,6 +7,7 @@
{
imports = [
../base/btrbk.nix
../base/btop.nix
../base/core.nix
../base/i18n.nix
../base/monitoring.nix
+1
View File
@@ -5,6 +5,7 @@
# =========================================================================
imports = [
../base/btop.nix
../base/core.nix
../base/i18n.nix
../base/monitoring.nix