mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-17 21:51:03 +01:00
feat(monitoring): GPU-aware btop variants and GPU metrics (#330)
This commit is contained in:
1 parent
523f4940a7
commit
9ab5eca60c
14 files changed
+690
-10
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
{
|
||||
imports = [
|
||||
../base/btrbk.nix
|
||||
../base/btop.nix
|
||||
../base/core.nix
|
||||
../base/i18n.nix
|
||||
../base/monitoring.nix
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# =========================================================================
|
||||
|
||||
imports = [
|
||||
../base/btop.nix
|
||||
../base/core.nix
|
||||
../base/i18n.nix
|
||||
../base/monitoring.nix
|
||||
|
||||
Reference in new issue
Block a user