diff --git a/nix/base-system/darwin-configuration.nix b/nix/base-system/darwin-configuration.nix index a0e7491..adbd2ac 100644 --- a/nix/base-system/darwin-configuration.nix +++ b/nix/base-system/darwin-configuration.nix @@ -40,6 +40,7 @@ }; }; + services.durnitisp.enable = true; services.node-exporter.enable = true; services.prometheus.enable = true; services.heracles.enable = true; @@ -90,6 +91,38 @@ } ]; } + { + title = "Network Quality"; + query_type = "Range"; + d3_tick_format = "~s"; + yaxes = [ + { + anchor = "y"; + } + ]; + plots = [ + { + source = "http://${config.services.prometheus.listen}"; + query = '' + stun_attempt_latency_ms + ''; + meta = { + name_format = "`UDP \${labels.domain} latency`"; + yaxis = "y"; + }; + } + { + source = "http://${config.services.prometheus.listen}"; + query = '' + ping_latency + ''; + meta = { + name_format = "`Ping \${labels.device} latency`"; + yaxis = "y"; + }; + } + ]; + } { title = "Network Traffic Bytes"; query_type = "Range"; @@ -122,38 +155,6 @@ } ]; } - { - title = "Network problems"; - query_type = "Range"; - d3_tick_format = "~s"; - yaxes = [ - { - anchor = "y"; - } - ]; - plots = [ - { - source = "http://${config.services.prometheus.listen}"; - query = '' - irate(node_network_transmit_errs_total{device=~'(lo|en).*'}[5m]) / irate(node_network_transmit_packets_total{device=~'(lo|en).*'}[5m]) - ''; - meta = { - name_format = "`\${labels.device} Tx Err rate`"; - yaxis = "y"; - }; - } - { - source = "http://${config.services.prometheus.listen}"; - query = '' - irate(node_network_receive_drop_total{device=~'(lo|en).*'}[5m]) / irate(node_network_receive_packets_total{device=~'(lo|en).*'}[5m]) - ''; - meta = { - name_format = "`\${labels.device} Rx drop rate`"; - yaxis = "y"; - }; - } - ]; - } ]; } ]; diff --git a/nix/base-system/flake.nix b/nix/base-system/flake.nix index ab31493..1d3d286 100644 --- a/nix/base-system/flake.nix +++ b/nix/base-system/flake.nix @@ -191,6 +191,7 @@ EOF"; lua-language-server rust-analyzer omnisharp-roslyn + dbeaver ]); }; }; @@ -219,6 +220,7 @@ EOF"; # This is needed because the ccache used by lean4Pkg is broken ccache = prev.ccache.override { doCheck = false; }; heracles = heracles-flake.packages."${system}".default; + durnitisp = durnitisp; }) rust-overlay ]; diff --git a/nix/base-system/modules/darwin-monitor.nix b/nix/base-system/modules/darwin-monitor.nix index 8e69db7..d1f4fe8 100644 --- a/nix/base-system/modules/darwin-monitor.nix +++ b/nix/base-system/modules/darwin-monitor.nix @@ -24,6 +24,15 @@ with lib; defaultText = "[]"; }; }; + + options.services.durnitisp = { + enable = mkEnableOption "Enable the heracles server"; + listen = mkOption { + description = "[host]:port to listen on for the durnitisp metrics server"; + default = "localhost:9002"; + defaultText = "localhost:9002"; + }; + }; options.services.prometheus = { enable = lib.mkEnableOption "Enable the prometheus server"; @@ -48,6 +57,18 @@ with lib; } ]; } + { + job_name = "network_quality"; + scrape_interval = "30s"; + metrics_path = "/"; + static_configs = [ + { + targets = [ + "${config.services.durnitisp.listen}" + ]; + } + ]; + } ]; }; defaultText = ''{ @@ -109,6 +130,18 @@ with lib; RunAtLoad = true; }; }; + + launchd.daemons.durnitisp = mkIf config.services.durnitisp.enable { + serviceConfig = { + ProgramArguments = [ + "${pkgs.durnitisp}/bin/durnitisp" + "--listenHost=${config.services.durnitisp.listen}" + ]; + + KeepAlive = true; + RunAtLoad = true; + }; + }; launchd.user.agents.prometheus = mkIf config.services.prometheus.enable { serviceConfig = { @@ -121,6 +154,9 @@ with lib; StandardOutPath = "${config.services.prometheus.dataPath}/prometheus-out.log"; StandardErrorPath = "${config.services.prometheus.dataPath}/prometheus-err.log"; WorkingDirectory=config.services.prometheus.dataPath; + WatchPaths = [ + "/etc/${config.environment.etc."prometheus.yaml".target}" + ]; KeepAlive = true; RunAtLoad = true; };