• F# 89.7%
  • CSS 7.3%
  • Nix 3%
Find a file
2026-11-29 21:21:22 +01:00
Metrics fix: align NIC temperature states with server cooling 2026-11-10 11:18:53 +01:00
nix feat: keep maintenance windows in memory and expose effective task settings 2026-10-22 16:21:15 +02:00
Views chore: remove obsolete schedule editing comment 2026-10-24 14:05:33 +02:00
wwwroot refactor: move maintenance scheduling out of dashboard 2026-10-24 14:01:48 +02:00
.gitignore chore: scaffold F# web project 2026-10-01 13:02:10 +02:00
appsettings.Development.json feat: read metrics from prometheus and graph cpu, gpu and memory load 2026-10-03 13:42:32 +02:00
appsettings.json feat: read metrics from prometheus and graph cpu, gpu and memory load 2026-10-03 13:42:32 +02:00
Config.fs refactor: move maintenance scheduling out of dashboard 2026-10-24 14:01:48 +02:00
Domain.fs fix(metrics): classify NIC temperatures at 75 and 85 degrees 2026-10-30 19:13:35 +01:00
Errors.fs refactor: move maintenance scheduling out of dashboard 2026-10-24 14:01:48 +02:00
flake.lock fix: align FSharp.Core with .NET SDK 10.0.404 2026-11-29 21:21:22 +01:00
flake.nix chore: formatting 2026-10-01 17:30:53 +02:00
Handlers.fs refactor: move maintenance scheduling out of dashboard 2026-10-24 14:01:48 +02:00
Logging.fs refactor: flatten project to repo root and include readme, flake and nix files in fsproj 2026-10-03 09:20:10 +02:00
Program.fs refactor: flatten project to repo root and include readme, flake and nix files in fsproj 2026-10-03 09:20:10 +02:00
README.md fix: align NIC temperature states with server cooling 2026-11-10 11:18:53 +01:00
Router.fs refactor: move maintenance scheduling out of dashboard 2026-10-24 14:01:48 +02:00
ServerDashboard.fsproj fix: align FSharp.Core with .NET SDK 10.0.404 2026-11-29 21:21:22 +01:00
Settings.fs refactor: move maintenance scheduling out of dashboard 2026-10-24 14:01:48 +02:00
Startup.fs refactor: move maintenance scheduling out of dashboard 2026-10-24 14:01:48 +02:00

server-dashboard

The dashboard for nixos-server at server.steenblik.ch: the public services for everyone, and on the LAN or VPN also the internal services and server metrics (load, temperatures, free space, fan speeds, internet speed).

F# (Giraffe + Giraffe.ViewEngine) renders the HTML; the only browser script toggles the theme and probes the internal origin.

How the VPN view works

The app listens on two loopback ports:

Port nginx host Serves
publicPort (5180) server.steenblik.ch the public services
internalPort (5181) server.internal.steenblik.ch / the full dashboard, /fragment metrics + all services, /stream live metrics, POST /fan-mode/{id}, POST /speedtest

/, /fragment and /stream take ?window=1h|24h|7d for the load graphs (1h by default).

The public page fetches https://server.internal.steenblik.ch/fragment. That host only resolves and answers on the LAN or VPN (nginx allow-list), so when the fetch succeeds the page swaps in the internal content. CORS on the internal port allows only PublicOrigin.

Configuration

appsettings.json holds defaults; the file named by SERVER_DASHBOARD_SETTINGS is layered on top, and environment variables (Dashboard__Server__PublicOrigin=...) win over both. Lists (Dashboard:Services, Dashboard:Metrics:Temperatures|Disks|Fans) come only from the settings file, so they never merge index-by-index with the defaults. appsettings.Development.json is a complete example.

Metrics come from the Prometheus server at Dashboard:Metrics:PrometheusUrl, in one instant query per refresh for the readings and one range query per load graph. Temperatures and fans select a sample by metric name and labels (node_hwmon_temp_celsius{chip=...,sensor=...}); a disk with a MountPoint uses node_filesystem_{avail,size}_bytes on that mount point, and one with a Pool uses zfs_exporter's zfs_pool_{free,size}_bytes for that pool, since a ZFS dataset's size is only its own data plus the pool's free space. An Hdd temperature shows "Spun down" instead of 0 °C, which is what CoolerControl reports for a sleeping disk. A temperature's Kind (Cpu, Gpu, Board, Nic, Chipset, Hdd, Ssd or Nvme) picks when it counts as warm or hot; the card's headline shows the worst state across all sensors. A Nic counts as warm at 80 °C and hot at 85 °C. A Chipset counts as warm at 80 °C and hot at 90 °C, matching the server’s cooling and alert thresholds.

The load card graphs CPU (node_cpu_seconds_total), GPU (nvidia_gpu_exporter's nvidia_smi_utilization_gpu_ratio) and memory (node_memory_{MemAvailable,MemTotal}_bytes) over the last hour, day or week, in about 120 steps that each average their whole span.

Dashboard:Metrics:Speedtest (true) shows the last speedtest, for example from node_exporter's textfile collector. It reads speedtest_{download,upload}_bytes_per_second, speedtest_{ping,download,upload}_latency_seconds, speedtest_ping_jitter_seconds, speedtest_packet_loss_ratio (NaN when unmeasured) and speedtest_timestamp_seconds. The card also shows the viewer's own round trip, which the browser times against /healthz. With Dashboard:Metrics:SpeedtestUnit set, a button runs systemctl start --no-block on that unit (the dashboard's user needs a polkit rule for it) and shows "Testing…" while it is activating. Like the fan modes it is only routed on the internal port and needs the X-Dashboard-Action header.

Dashboard:Metrics:FanControlUrl is a CoolerControl daemon, with FanControlTokenFile holding a token that has write access. Its modes then show as buttons in the fan card; a click posts to /fan-mode/{id}, which activates the mode through CoolerControl's API. The browser sends an X-Dashboard-Action header, so the request is preflighted and only the dashboard's own origins can make it. With KeepCoolMode and KeepCoolOffMode set to the names of two CoolerControl modes, the first becomes a snowflake toggle between Quiet (mute icon) and Full (fan icon) in the Fans card; switching it off activates the second. Hovering a fan control for 250 ms shows its label. What keeping cool does is up to that mode's profiles.

Maintenance scheduling and presence automation belong to the host's Home Assistant configuration. The dashboard retains manual fan controls. KeepCoolManualUnit optionally identifies a systemd oneshot that records manual ownership after a fan change; the dashboard user needs permission to start it. The dashboard does not schedule maintenance or expose schedule endpoints.

To find the labels on the server:

curl -s localhost:9100/metrics | grep -E '^node_hwmon_(temp_celsius|fan_rpm)'

Develop

nix develop
ASPNETCORE_ENVIRONMENT=Development dotnet run

Then open http://localhost:5180 (public) or http://localhost:5181 (internal).

After changing NuGet packages, refresh the lock file:

nix build .#default.fetch-deps && ./result nix/deps.json

Deploy

In nixos-server, add the flake input and import the module:

inputs.server-dashboard.url = "git+file:///path/to/server-dashboard"; # or the forge URL
# ...
modules = [ inputs.server-dashboard.nixosModules.default ];
services.prometheus.exporters.node = {
  enable = true;
  listenAddress = "127.0.0.1";
};

services.prometheus = {
  enable = true;
  listenAddress = "127.0.0.1";
  scrapeConfigs = [
    { job_name = "node"; static_configs = [ { targets = [ "127.0.0.1:9100" ]; } ]; }
  ];
};

services.server-dashboard = {
  enable = true;
  settings.Dashboard = {
    Services = [ /* { Name; Description; Url; Icon; Group; Visibility = "Public" | "Internal"; } */ ];
    Metrics = {
      PrometheusUrl = "http://127.0.0.1:9090";
      FanControlUrl = "http://127.0.0.1:11987"; # optional, with an optional FanControlTokenFile
      KeepCoolMode = "Keep cool"; # optional, together with KeepCoolOffMode
      KeepCoolOffMode = "Quiet";
      KeepCoolWindowStart = "02:00"; # optional, together with KeepCoolWindowEnd
      KeepCoolWindowEnd = "05:00";
      Speedtest = true; # optional
      SpeedtestUnit = "speedtest.service"; # optional, adds a button that starts it
      Temperatures = [ /* { Label; Metric; Labels = [ { Name; Value; } ]; Kind?; } */ ];
      Disks = [ /* { Label; MountPoint | Pool; } */ ];
      Fans = [ /* same shape as Temperatures */ ];
    };
  };
};

and in proxy.nix add server = config.services.server-dashboard.publicPort; to publicServices and server = config.services.server-dashboard.internalPort; to privateServices.