summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/router.nix1
-rw-r--r--modules/pms7003-exporter.nix31
2 files changed, 32 insertions, 0 deletions
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";
+ };
+ };
+ };
+}