From 7722eb62435dc5752ed86c480b75a4add0b2e259 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 24 Oct 2023 01:17:41 +0200 Subject: [PATCH] nix/nixos-module/container/dhcp-server: fix dyndns and stats --- nix/nixos-module/collectd/dhcpcount.rb | 6 ++++-- nix/nixos-module/container/dhcp-server.nix | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nix/nixos-module/collectd/dhcpcount.rb b/nix/nixos-module/collectd/dhcpcount.rb index d7ef59d..7bd6b24 100755 --- a/nix/nixos-module/collectd/dhcpcount.rb +++ b/nix/nixos-module/collectd/dhcpcount.rb @@ -10,13 +10,15 @@ STDOUT.sync = true loop do seen = {} count = 0 - - header = nil + now = Time.now.to_i CSV::readlines("/var/lib/kea/kea-leases4.csv", headers: true).each do |rec| h = rec.to_h addr = h["hwaddr"] next unless addr + last = h["expire"].to_i + elapsed = now - last + next if elapsed >= TIMEOUT unless seen[addr] count += 1 diff --git a/nix/nixos-module/container/dhcp-server.nix b/nix/nixos-module/container/dhcp-server.nix index cbb6fbc..3321ed0 100644 --- a/nix/nixos-module/container/dhcp-server.nix +++ b/nix/nixos-module/container/dhcp-server.nix @@ -50,6 +50,7 @@ in code = 6; data = "172.20.73.8, 9.9.9.9"; } ]; + ddns-qualifying-suffix = domainName; }); match-client-id = false;