This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / configs / gg23 / internet.nix
3.8 kB 113 lines
1# Why is the gg23 internet slow? Runs on acheron, the gg23 router, whose WAN 2# (et0) sits behind the Vodafone Station (ARRIS TG3442DE cable modem, LAN 3# 192.168.0.1). Exports, via the Vector agent (configs/monitoring/agent.nix) 4# into VictoriaMetrics on the monitoring servers: 5# - the Station's DOCSIS channel power/SNR/lock and its status, scraped from 6# its web UI (tools/vodafone-station-exporter) 7# - latency and loss to the Station, the CMTS and the internet 8# (smokeping_prober) 9# - hourly speedtests (./internet-speedtest.nix) 10# WAN throughput is in the host metrics already (et0 on acheron). Grafana 11# shows it as "Internet", Home Assistant as the "Internet" dashboard 12# (./internet-hass.nix). 13{ 14 config, 15 lib, 16 pkgs, 17 self, 18 ... 19}: 20let 21 exporterPort = 9764; 22 smokeping = config.services.prometheus.exporters.smokeping; 23 24 # target label -> address. `cmts` is the first hop behind the cable modem 25 # (91.64.96.254 = gateway of the WAN 91.64.96.0/24, from mtr). If Vodafone 26 # moves us to another subnet it shows as 100% loss here: update it then. 27 targets = { 28 station = "192.168.0.1"; 29 cmts = "91.64.96.254"; 30 cloudflare = "1.1.1.1"; 31 google = "8.8.8.8"; 32 cloudflare6 = "2606:4700:4700::1111"; 33 google6 = "2001:4860:4860::8888"; 34 }; 35in 36{ 37 imports = [ 38 ./internet-hass.nix 39 ./internet-speedtest.nix 40 ]; 41 42 clan.core.vars.generators.vodafone-station.prompts.password = { 43 description = "Vodafone Station (192.168.0.1) web UI admin password, passage admin/gg23/vodafone-router/pass"; 44 type = "hidden"; 45 persist = true; 46 }; 47 48 systemd.services.vodafone-station-exporter = { 49 description = "Prometheus exporter for the Vodafone Station"; 50 wantedBy = [ "multi-user.target" ]; 51 after = [ "network-online.target" ]; 52 wants = [ "network-online.target" ]; 53 serviceConfig = { 54 ExecStart = lib.escapeShellArgs [ 55 (lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.vodafone-station-exporter) 56 "--listen" 57 "127.0.0.1:${toString exporterPort}" 58 "--password-file" 59 "%d/password" 60 ]; 61 LoadCredential = [ 62 "password:${config.clan.core.vars.generators.vodafone-station.files.password.path}" 63 ]; 64 DynamicUser = true; 65 Restart = "on-failure"; 66 RestartSec = 10; 67 }; 68 }; 69 70 services.prometheus.exporters.smokeping = { 71 enable = true; 72 listenAddress = "127.0.0.1"; 73 hosts = lib.attrValues targets; 74 }; 75 76 monitoring.extraMetrics = [ "internet_metrics" ]; 77 78 services.vector.settings = { 79 # The Station is slow: one login + three pages take ~6s. Every scrape 80 # logs in and out again, so keep the interval relaxed. 81 sources.vodafone_station_raw = { 82 type = "prometheus_scrape"; 83 endpoints = [ "http://127.0.0.1:${toString exporterPort}/metrics" ]; 84 scrape_interval_secs = 60; 85 scrape_timeout_secs = 45; 86 }; 87 sources.smokeping_raw = { 88 type = "prometheus_scrape"; 89 endpoints = [ 90 "http://127.0.0.1:${toString smokeping.port}${smokeping.telemetryPath}" 91 ]; 92 scrape_interval_secs = 30; 93 }; 94 # smokeping_prober labels the probed address `host`, which is our 95 # machine label everywhere else: move it to `target` (plus the name from 96 # `targets`), then set host like the agent does. 97 transforms.internet_metrics = { 98 type = "remap"; 99 inputs = [ 100 "vodafone_station_raw" 101 "smokeping_raw" 102 ]; 103 source = '' 104 names = ${builtins.toJSON (lib.mapAttrs' (n: v: lib.nameValuePair v n) targets)} 105 if exists(.tags.host) { 106 .tags.target = del(.tags.host) 107 .tags.target_name = get(names, [.tags.target]) ?? .tags.target 108 } 109 .tags.host = "${config.networking.hostName}" 110 ''; 111 }; 112 }; 113}