@jaspermayone.com's dotfiles
0
fork

Configure Feed

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

Consolidate status endpoints on alastor

+32 -73
+2 -2
README.md
··· 5 5 ## Status 6 6 7 7 <img src="https://img.shields.io/website?label=alastor&up_color=green&up_message=online&down_message=offline&url=https%3A%2F%2Falastor.hogwarts.channel%2Fstatus%2Falastor"> 8 - <img src="https://img.shields.io/website?label=remus&up_color=green&up_message=online&down_message=offline&url=https%3A%2F%2Fremus.hogwarts.channel%2Fstatus%2Fremus"> 9 - <img src="https://img.shields.io/website?label=dippet&up_color=green&up_message=online&down_message=offline&url=https%3A%2F%2Fdippet.hogwarts.channel%2Fstatus%2Fdippet"> 8 + <img src="https://img.shields.io/website?label=remus&up_color=green&up_message=online&down_message=offline&url=https%3A%2F%2Falastor.hogwarts.channel%2Fstatus%2Fremus"> 9 + <img src="https://img.shields.io/website?label=dippet&up_color=green&up_message=online&down_message=offline&url=https%3A%2F%2Falastor.hogwarts.channel%2Fstatus%2Fdippet"> 10 10 11 11 12 12
+1 -71
hosts/alastor/configuration.nix
··· 148 148 hostname = "alastor"; 149 149 domain = "alastor.hogwarts.channel"; 150 150 services = [ "frps" "caddy" "tailscaled" "tangled-knot" "atuin-server" ]; 151 + remoteHosts = [ "remus" "dippet" ]; 151 152 cloudflareCredentialsFile = config.age.secrets.cloudflare-credentials.path; 152 - }; 153 - 154 - # Tailscale status checker for remote hosts (remus, dippet) 155 - systemd.services.tailscale-status = { 156 - description = "Check Tailscale host connectivity for status badges"; 157 - serviceConfig = { 158 - Type = "oneshot"; 159 - ExecStart = pkgs.writeShellScript "tailscale-status" '' 160 - STATUS_DIR="/var/lib/status" 161 - mkdir -p "$STATUS_DIR" 162 - 163 - for host in remus dippet; do 164 - if ${pkgs.iputils}/bin/ping -c 1 -W 2 "$host" >/dev/null 2>&1; then 165 - echo "ok" > "$STATUS_DIR/$host" 166 - else 167 - rm -f "$STATUS_DIR/$host" 168 - fi 169 - done 170 - ''; 171 - }; 172 - }; 173 - 174 - systemd.timers.tailscale-status = { 175 - description = "Check Tailscale hosts every minute"; 176 - wantedBy = [ "timers.target" ]; 177 - timerConfig = { 178 - OnBootSec = "30s"; 179 - OnUnitActiveSec = "1min"; 180 - }; 181 153 }; 182 154 183 155 # Tangled Knot server (official module) ··· 232 204 reverse_proxy localhost:5555 { 233 205 header_up X-Forwarded-Proto {scheme} 234 206 header_up X-Forwarded-For {remote} 235 - } 236 - ''; 237 - }; 238 - # Status endpoint for remus (Tailscale connectivity check) 239 - virtualHosts."remus.hogwarts.channel" = { 240 - extraConfig = '' 241 - tls { 242 - dns cloudflare {env.CLOUDFLARE_API_TOKEN} 243 - } 244 - @status path /status/remus 245 - handle @status { 246 - @online file /var/lib/status/remus 247 - handle @online { 248 - respond "ok" 200 249 - } 250 - handle { 251 - respond "offline" 503 252 - } 253 - } 254 - handle { 255 - respond "remus.hogwarts.channel - see /status/remus" 200 256 - } 257 - ''; 258 - }; 259 - # Status endpoint for dippet (Tailscale connectivity check) 260 - virtualHosts."dippet.hogwarts.channel" = { 261 - extraConfig = '' 262 - tls { 263 - dns cloudflare {env.CLOUDFLARE_API_TOKEN} 264 - } 265 - @status path /status/dippet 266 - handle @status { 267 - @online file /var/lib/status/dippet 268 - handle @online { 269 - respond "ok" 200 270 - } 271 - handle { 272 - respond "offline" 503 273 - } 274 - } 275 - handle { 276 - respond "dippet.hogwarts.channel - see /status/dippet" 200 277 207 } 278 208 ''; 279 209 };
+29
modules/status/default.nix
··· 24 24 # Always write host status (if this runs, host is up) 25 25 echo "ok" > "$STATUS_DIR/${cfg.hostname}" 26 26 27 + # Check remote hosts via ping (Tailscale) 28 + ${concatStringsSep "\n" (map (host: '' 29 + if ${pkgs.iputils}/bin/ping -c 1 -W 2 ${escapeShellArg host} >/dev/null 2>&1; then 30 + echo "ok" > "$STATUS_DIR/${host}" 31 + else 32 + rm -f "$STATUS_DIR/${host}" 33 + fi 34 + '') cfg.remoteHosts)} 35 + 27 36 # Build services JSON 28 37 SERVICES_JSON="{" 29 38 ${concatStringsSep "\n" (imap0 (i: svc: '' ··· 63 72 type = types.listOf types.str; 64 73 default = []; 65 74 description = "List of systemd services to monitor"; 75 + }; 76 + 77 + remoteHosts = mkOption { 78 + type = types.listOf types.str; 79 + default = []; 80 + description = "List of remote hosts to check via ping (e.g. Tailscale hosts)"; 66 81 }; 67 82 68 83 cloudflareCredentialsFile = mkOption { ··· 129 144 } 130 145 } 131 146 '') cfg.services)} 147 + 148 + # Remote host status endpoints (Tailscale) 149 + ${concatStringsSep "\n" (map (host: '' 150 + @status_${host} path /status/${host} 151 + handle @status_${host} { 152 + @online_${host} file /var/lib/status/${host} 153 + handle @online_${host} { 154 + respond "ok" 200 155 + } 156 + handle { 157 + respond "offline" 503 158 + } 159 + } 160 + '') cfg.remoteHosts)} 132 161 133 162 # Full status JSON 134 163 @status_json path /status