From 4801b0f626e6f393e7c865b084e7b80a518ada96 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Fri, 12 Nov 2021 17:55:06 -0500 Subject: Create static IP mapping for firelink --- config/router.nix | 1 + modules/pms7003-exporter.nix | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 modules/pms7003-exporter.nix diff --git a/config/router.nix b/config/router.nix index 9fdbdd0..eff8491 100644 --- a/config/router.nix +++ b/config/router.nix @@ -249,6 +249,7 @@ in { dhcp-option=net:vlan30,option:dns-server,172.20.30.1 dhcp-range=vlan100,172.20.100.50,172.20.100.254,5m + dhcp-host=vlan100,d8:3b:bf:59:22:de,172.20.100.10 dhcp-range=vlan100,::100,::500,constructor:bond0.100,ra-only dhcp-option=net:vlan100,option:router,172.20.100.1 dhcp-option=net:vlan100,option:dns-server,172.20.100.1 diff --git a/modules/pms7003-exporter.nix b/modules/pms7003-exporter.nix new file mode 100644 index 0000000..cc27e4c --- /dev/null +++ b/modules/pms7003-exporter.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.orbekk.pms7003-exporter; + aliases = import ../data/aliases.nix; +in +{ + options = { + orbekk.pms7003-exporter = { + enable = lib.mkEnableOption "Enable PMS7003 exporter"; + bind-addr = lib.mkOption { + type = lib.types.str; + default = let + port = aliases.services.prometheus-snmp-exporter.port; + in "127.0.0.1:${toString port}"; + }; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.pms7003-exporter = { + description = "PMS7003 prometheus exporter"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + DynamicUser = true; + SupplementaryGroups = "dialout"; + ExecStart = "${pkgs.pms7003}/bin/pms7003 --prometheus-bind-address ${cfg.bind-addr} --quiet -v"; + }; + }; + }; +} -- cgit v1.2.3