From 1351f1f58740ac77c350a6d704b35272ce29da65 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 19 Dec 2024 05:07:45 +0100 Subject: [PATCH 1/2] prometheus-rasdaemon-exporter: init at unstable-2023-03-15 Rasdaemon exporter for Prometheus --- .../prometheus-rasdaemon-exporter/package.nix | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 pkgs/by-name/pr/prometheus-rasdaemon-exporter/package.nix diff --git a/pkgs/by-name/pr/prometheus-rasdaemon-exporter/package.nix b/pkgs/by-name/pr/prometheus-rasdaemon-exporter/package.nix new file mode 100644 index 0000000000000..97349f5a10865 --- /dev/null +++ b/pkgs/by-name/pr/prometheus-rasdaemon-exporter/package.nix @@ -0,0 +1,43 @@ +{ + lib, + python3Packages, + fetchFromGitHub, +}: + +python3Packages.buildPythonApplication { + pname = "prometheus-rasdaemon-exporter"; + version = "unstable-2023-03-15"; + pyproject = true; + + src = fetchFromGitHub { + owner = "sanecz"; + repo = "prometheus-rasdaemon-exporter"; + rev = "e37084edeb4d397dd360298cb22f18f83a35ff46"; + hash = "sha256-O0Zzog+5jDixFRGbqmjPYi6JDpHbxpU4hKfsqTnexS8="; + }; + + build-system = with python3Packages; [ + setuptools + setuptools-scm + ]; + + env.SETUPTOOLS_SCM_PRETEND_VERSION = "0.1.dev9+ge37084e"; + + dependencies = with python3Packages; [ + prometheus-client + ]; + + pythonImportsCheck = [ + "prometheus_rasdaemon_exporter" + ]; + + doCheck = false; # no tests + + meta = { + description = "Rasdaemon exporter for Prometheus"; + homepage = "https://github.com/sanecz/prometheus-rasdaemon-exporter"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ hexa ]; + mainProgram = "prometheus-rasdaemon-exporter"; + }; +} From f6f1febc43645b48659111015e0fb322ddfb0ed5 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 19 Dec 2024 05:08:13 +0100 Subject: [PATCH 2/2] nixos/prometheux-exporters/rasdaemon: init --- .../monitoring/prometheus/exporters.nix | 1 + .../prometheus/exporters/rasdaemon.nix | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 nixos/modules/services/monitoring/prometheus/exporters/rasdaemon.nix diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 1b0a8777324d3..1c2fdbd45d1d8 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -76,6 +76,7 @@ let "process" "pve" "py-air-control" + "rasdaemon" "redis" "restic" "rspamd" diff --git a/nixos/modules/services/monitoring/prometheus/exporters/rasdaemon.nix b/nixos/modules/services/monitoring/prometheus/exporters/rasdaemon.nix new file mode 100644 index 0000000000000..9d76ea2508249 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/rasdaemon.nix @@ -0,0 +1,67 @@ +{ + config, + lib, + pkgs, + utils, + ... +}: + +let + inherit (lib) + getExe + mkOption + types + ; + + inherit (utils) escapeSystemdExecArgs; + + cfg = config.services.prometheus.exporters.rasdaemon; +in +{ + port = 10029; + extraOpts = with types; { + databasePath = mkOption { + type = path; + default = "/var/lib/rasdaemon/ras-mc_event.db"; + description = '' + Path to the RAS daemon machine check event database. + ''; + }; + + enabledCollectors = mkOption { + type = listOf (enum [ + "aer" + "mce" + "mc" + "extlog" + "devlink" + "disk" + ]); + default = [ + "aer" + "mce" + "mc" + ]; + description = '' + List of error types to collect from the event database. + ''; + }; + }; + serviceOpts = { + serviceConfig = { + ExecStart = escapeSystemdExecArgs ( + [ + (getExe pkgs.prometheus-rasdaemon-exporter) + "--address" + cfg.listenAddress + "--port" + (toString cfg.port) + "--db" + cfg.databasePath + ] + ++ map (collector: "--collector-${collector}") cfg.enabledCollectors + ++ cfg.extraFlags + ); + }; + }; +}