From 8fda0125d8641018db73b2ccafe8b8302937660f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 11 Nov 2022 16:15:19 +0100 Subject: ... --- _sources/generated.json | 43 ++++++++++++++++++++++--- _sources/generated.nix | 28 ++++++++++++++--- hosts/vidhar/prometheus/default.nix | 8 +++++ modules/prometheus-lvm-exporter.nix | 57 +++++++++++++++++++++++++++++++++ nvfetcher.toml | 11 ++++++- overlays/etesync-dav.nix | 61 ++++++++++++++++++++++++++++++++++++ overlays/prometheus-lvm-exporter.nix | 18 +++++++++++ 7 files changed, 217 insertions(+), 9 deletions(-) create mode 100644 modules/prometheus-lvm-exporter.nix create mode 100644 overlays/etesync-dav.nix create mode 100644 overlays/prometheus-lvm-exporter.nix diff --git a/_sources/generated.json b/_sources/generated.json index d7a62e6b..d3b81268 100644 --- a/_sources/generated.json +++ b/_sources/generated.json @@ -39,6 +39,26 @@ }, "version": "0077334cc299aa7885f804d88f52cdb1b35caf71" }, + "etebase-py": { + "cargoLocks": null, + "date": "2022-07-06", + "extract": null, + "name": "etebase-py", + "passthru": null, + "pinned": false, + "src": { + "deepClone": false, + "fetchSubmodules": false, + "leaveDotGit": false, + "name": null, + "owner": "etesync", + "repo": "etebase-py", + "rev": "ac3e5138a2e18dc11f77d9a75f07d4b8dd8c4445", + "sha256": "sha256-OSzOoL7o4rWYOK1OyxfpslOnNfnK5CKhdhiFEXz/WvY=", + "type": "github" + }, + "version": "ac3e5138a2e18dc11f77d9a75f07d4b8dd8c4445" + }, "lesspipe": { "cargoLocks": null, "date": null, @@ -202,6 +222,21 @@ }, "version": "2.03" }, + "prometheus-lvm-exporter": { + "cargoLocks": null, + "date": null, + "extract": null, + "name": "prometheus-lvm-exporter", + "passthru": null, + "pinned": false, + "src": { + "name": null, + "sha256": "sha256-bytPqK2kvDrskbvmyybejUr1+RU6YdOgzmtqbKyfSNA=", + "type": "url", + "url": "https://github.com/hansmi/prometheus-lvm-exporter/archive/refs/tags/v0.3.1.tar.gz" + }, + "version": "0.3.1" + }, "psql-versioning": { "cargoLocks": null, "date": "2020-02-18", @@ -253,7 +288,7 @@ }, "v4l2loopback": { "cargoLocks": null, - "date": "2022-08-05", + "date": "2022-11-09", "extract": null, "name": "v4l2loopback", "passthru": null, @@ -265,11 +300,11 @@ "name": null, "owner": "umlaeute", "repo": "v4l2loopback", - "rev": "76434ab6f71d5ecbff8a218ff6bed91ea2bf73b8", - "sha256": "sha256-c6g63jW+a+v/TxLD9NnQGn/aUgivwVkxzP+hZ65w2/o=", + "rev": "8902b3f11413166e7823c377dbf876bae1fab137", + "sha256": "sha256-p/tGXO2+EogR4BdZ+KxonyBnYHznJrqKM6cRg1G37xA=", "type": "github" }, - "version": "76434ab6f71d5ecbff8a218ff6bed91ea2bf73b8" + "version": "8902b3f11413166e7823c377dbf876bae1fab137" }, "xcompose": { "cargoLocks": null, diff --git a/_sources/generated.nix b/_sources/generated.nix index 72e6367c..89857492 100644 --- a/_sources/generated.nix +++ b/_sources/generated.nix @@ -27,6 +27,18 @@ }); date = "2015-09-10"; }; + etebase-py = { + pname = "etebase-py"; + version = "ac3e5138a2e18dc11f77d9a75f07d4b8dd8c4445"; + src = fetchFromGitHub ({ + owner = "etesync"; + repo = "etebase-py"; + rev = "ac3e5138a2e18dc11f77d9a75f07d4b8dd8c4445"; + fetchSubmodules = false; + sha256 = "sha256-OSzOoL7o4rWYOK1OyxfpslOnNfnK5CKhdhiFEXz/WvY="; + }); + date = "2022-07-06"; + }; lesspipe = { pname = "lesspipe"; version = "2.06"; @@ -124,6 +136,14 @@ sha256 = "sha256-mMKXzeqg2PfXkvGL7qugOelm/I2fZnUidq6/ugXDHa0="; }; }; + prometheus-lvm-exporter = { + pname = "prometheus-lvm-exporter"; + version = "0.3.1"; + src = fetchurl { + url = "https://github.com/hansmi/prometheus-lvm-exporter/archive/refs/tags/v0.3.1.tar.gz"; + sha256 = "sha256-bytPqK2kvDrskbvmyybejUr1+RU6YdOgzmtqbKyfSNA="; + }; + }; psql-versioning = { pname = "psql-versioning"; version = "3e578ff5e5aa6c7e5459dbfa842a64a1b2674b2e"; @@ -155,15 +175,15 @@ }; v4l2loopback = { pname = "v4l2loopback"; - version = "76434ab6f71d5ecbff8a218ff6bed91ea2bf73b8"; + version = "8902b3f11413166e7823c377dbf876bae1fab137"; src = fetchFromGitHub ({ owner = "umlaeute"; repo = "v4l2loopback"; - rev = "76434ab6f71d5ecbff8a218ff6bed91ea2bf73b8"; + rev = "8902b3f11413166e7823c377dbf876bae1fab137"; fetchSubmodules = true; - sha256 = "sha256-c6g63jW+a+v/TxLD9NnQGn/aUgivwVkxzP+hZ65w2/o="; + sha256 = "sha256-p/tGXO2+EogR4BdZ+KxonyBnYHznJrqKM6cRg1G37xA="; }); - date = "2022-08-05"; + date = "2022-11-09"; }; xcompose = { pname = "xcompose"; diff --git a/hosts/vidhar/prometheus/default.nix b/hosts/vidhar/prometheus/default.nix index 8e5ff0ea..e6de6806 100644 --- a/hosts/vidhar/prometheus/default.nix +++ b/hosts/vidhar/prometheus/default.nix @@ -69,6 +69,7 @@ in { "--systemd.collector.enable-ip-accounting" ]; }; + lvm.enable = true; blackbox = { enable = true; configFile = pkgs.writeText "blackbox-config.yaml" (builtins.toJSON { @@ -104,6 +105,13 @@ in { relabel_configs = relabelHosts; scrape_interval = "1s"; } + { job_name = "lvm"; + static_configs = [ + { targets = ["localhost:${toString config.services.prometheus.exporters.lvm.port}"]; } + ]; + relabel_configs = relabelHosts; + scrape_interval = "5s"; + } { job_name = "systemd"; static_configs = [ { targets = ["localhost:${toString config.services.prometheus.exporters.systemd.port}"]; } diff --git a/modules/prometheus-lvm-exporter.nix b/modules/prometheus-lvm-exporter.nix new file mode 100644 index 00000000..f0951d46 --- /dev/null +++ b/modules/prometheus-lvm-exporter.nix @@ -0,0 +1,57 @@ +{ lib, config, pkgs, utils, ... }: + +with lib; + +let + cfg = config.services.prometheus.exporters.lvm; +in { + options = { + services.prometheus.exporters.lvm = { + enable = mkEnableOption "Prometheus LVM exporter"; + + listenAddress = mkOption { + type = types.str; + default = "localhost"; + }; + port = mkOption { + type = types.port; + default = 9845; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc '' + Open port in firewall for incoming connections. + ''; + }; + firewallFilter = mkOption { + type = types.nullOr types.str; + default = null; + example = literalExpression '' + "-i eth0 -p tcp -m tcp --dport ${toString cfg.port}" + ''; + description = lib.mdDoc '' + Specify a filter for iptables to use when + {option}`services.prometheus.exporters.lvm.openFirewall` + is true. It is used as `ip46tables -I nixos-fw firewallFilter -j nixos-fw-accept`. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.services."prometheus-lvm-exporter" = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + ExecStart = "${pkgs.prometheus-lvm-exporter}/bin/prometheus-lvm-exporter ${utils.escapeSystemdExecArgs [ + "-web.listen-address" "${cfg.listenAddress}:${toString cfg.port}" + ]}"; + + Restart = "always"; + }; + }; + }; +} diff --git a/nvfetcher.toml b/nvfetcher.toml index 7cd52c29..5e075ae4 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -68,4 +68,13 @@ fetch.url = "https://github.com/matusnovak/prometheus-smartctl/archive/refs/tags [postfwd] src.github_tag = "postfwd/postfwd" src.prefix = "v" -fetch.url = "https://github.com/postfwd/postfwd/archive/refs/tags/v$ver.tar.gz" \ No newline at end of file +fetch.url = "https://github.com/postfwd/postfwd/archive/refs/tags/v$ver.tar.gz" + +[etebase-py] +src.git = "https://github.com/etesync/etebase-py" +fetch.github = "etesync/etebase-py" + +[prometheus-lvm-exporter] +src.github = "hansmi/prometheus-lvm-exporter" +src.prefix = "v" +fetch.url = "https://github.com/hansmi/prometheus-lvm-exporter/archive/refs/tags/v$ver.tar.gz" \ No newline at end of file diff --git a/overlays/etesync-dav.nix b/overlays/etesync-dav.nix new file mode 100644 index 00000000..49c77352 --- /dev/null +++ b/overlays/etesync-dav.nix @@ -0,0 +1,61 @@ +{ final, prev, sources, ... }: { + etesync-dav = let + python = final.python3.override { + packageOverrides = self: super: { + # flask-wtf = super.flask-wtf.overridePythonAttrs (old: rec { + # patches = []; + # version = "0.15.1"; + # src = old.src.override { + # inherit version; + # sha256 = "ff177185f891302dc253437fe63081e7a46a4e99aca61dfe086fb23e54fff2dc"; + # }; + # disabledTests = [ + # "test_outside_request" + # ]; + # }); + # wtforms = super.wtforms.overridePythonAttrs (old: rec { + # version = "2.3.3"; + # src = old.src.override { + # inherit version; + # sha256 = "81195de0ac94fbc8368abbaf9197b88c4f3ffd6c2719b5bf5fc9da744f3d829c"; + # }; + # checkPhase = '' + # ${self.python.interpreter} tests/runtests.py + # ''; + # }); + etebase = super.wtforms.overridePythonAttrs (old: rec { + inherit (sources.etebase-py) version src; + }); + }; + }; + in python.pkgs.buildPythonApplication rec { + pname = "etesync-dav"; + version = "0.32.1"; + + src = python.pkgs.fetchPypi { + inherit pname version; + sha256 = "a4e2ee83932755d29ac39c1e74005ec289880fd2d4d2164f09fe2464a294d720"; + }; + + propagatedBuildInputs = with python.pkgs; [ + appdirs + etebase + etesync + flask + flask-wtf + msgpack + pysocks + (python.pkgs.toPythonModule (final.radicale3.override { python3 = python; })) + requests + ] ++ requests.optional-dependencies.socks; + + doCheck = false; + + meta = with final.lib; { + homepage = "https://www.etesync.com/"; + description = "Secure, end-to-end encrypted, and privacy respecting sync for contacts, calendars and tasks"; + license = licenses.gpl3; + broken = final.stdenv.isDarwin; # pyobjc-framework-Cocoa is missing + }; + }; +} diff --git a/overlays/prometheus-lvm-exporter.nix b/overlays/prometheus-lvm-exporter.nix new file mode 100644 index 00000000..ead1e820 --- /dev/null +++ b/overlays/prometheus-lvm-exporter.nix @@ -0,0 +1,18 @@ +{ final, prev, sources, ... }: { + prometheus-lvm-exporter = final.buildGoModule { + pname = "prometheus-lvm-exporter"; + inherit (sources.prometheus-lvm-exporter) version src; + + vendorHash = "sha256-DyvUM3pP2P1IGfXKpkR5Y4CVcnSBsnNy0kd3WTjbWpg="; + + doCheck = false; + + nativeBuildInputs = with final; [ makeWrapper ]; + + postInstall = '' + wrapProgram $out/bin/prometheus-lvm-exporter \ + --set LC_ALL C \ + --add-flags -command --add-flags ${final.lvm2.bin}/bin/lvm + ''; + }; +} -- cgit v1.2.3