From d590aa6d3f6682d32a2defa3d3ca75ea61466bd9 Mon Sep 17 00:00:00 2001 From: CJ Rivas Date: Tue, 24 Nov 2026 07:34:21 -0500 Subject: [PATCH] WZ: Add balerion to the fleet - monitor balerion (UGreen NAS) as the sixth host; FM_HOST_IPS now takes six addresses - allow hosts with no Plex (empty plex_url) - the fleet config names each host's console (DSM, or UGOS on 9999 for balerion) and /fleet sends it as `console`; the host card links to it and names it in the link's description - add a sixth chart series colour - teach nas-host.sh, the smoke test, docs and .env.example about the sixth host --- .claude/skills/security-audit/SKILL.md | 10 +-- .env.example | 8 +- apps/admin-portal/src/lib/fleetApi.test.ts | 6 +- apps/admin-portal/src/lib/fleetApi.ts | 9 --- .../src/pages/Fleet/Fleet.test.tsx | 18 ++++- .../src/pages/Fleet/HostCard.module.scss | 8 +- .../admin-portal/src/pages/Fleet/HostCard.tsx | 21 +++-- .../src/pages/Fleet/series.module.scss | 4 + .../src/pages/Fleet/seriesPalette.ts | 1 + apps/admin-portal/src/styles/globals.scss | 3 +- apps/fleet-monitor/src/api/api.test.ts | 4 +- apps/fleet-monitor/src/config.test.ts | 52 ++++++++++--- apps/fleet-monitor/src/config.ts | 76 +++++++++++++------ apps/fleet-monitor/src/fleet.test.ts | 2 +- apps/fleet-monitor/src/fleet.ts | 5 +- apps/fleet-monitor/src/series.test.ts | 2 +- apps/fleet-monitor/src/test/env.ts | 10 +-- docs/fleet-monitor-deployment.md | 4 +- libs/wire/src/fleet.ts | 3 + scripts/ci/smoke-container.sh | 2 +- scripts/nas-host.sh | 7 +- 21 files changed, 168 insertions(+), 87 deletions(-) diff --git a/.claude/skills/security-audit/SKILL.md b/.claude/skills/security-audit/SKILL.md index a2e914b4..933722e3 100644 --- a/.claude/skills/security-audit/SKILL.md +++ b/.claude/skills/security-audit/SKILL.md @@ -99,11 +99,11 @@ warn about them. The fleet's hosts are not in the code. They come from the gitignored `.env`: -| Variable | Holds | -| ------------- | ------------------------------------------------------------------------------------------ | -| `FM_HOST_IPS` | one comma-separated list of five IPv4 addresses: meleys, vermithor, caraxes, syrax, vhagar | -| `FM_SSH_USER` | the ssh account on those hosts | -| `WZ_NAS_HOST` | optional `user@host` override for the NAS; otherwise built from the two above | +| Variable | Holds | +| ------------- | --------------------------------------------------------------------------------------------------- | +| `FM_HOST_IPS` | one comma-separated list of six IPv4 addresses: meleys, vermithor, caraxes, syrax, vhagar, balerion | +| `FM_SSH_USER` | the ssh account on those hosts | +| `WZ_NAS_HOST` | optional `user@host` override for the NAS; otherwise built from the two above | `scripts/nas-host.sh [host]` turns those into an ssh target for the skills' scripts, and the fleet monitor refuses to boot if `FM_HOST_IPS` is missing, the wrong length, or holds diff --git a/.env.example b/.env.example index 066cec59..02fc998f 100644 --- a/.env.example +++ b/.env.example @@ -163,13 +163,13 @@ FM_SUPABASE_URL=https://.supabase.co FM_ADMIN_ALLOWED_EMAILS=you@example.com # --- 3b. Fleet hosts -------------------------------------------------------- -# The unprivileged account the collector SSHes into all five hosts as. +# The unprivileged account the collector SSHes into all six hosts as. # Required: the monitor refuses to boot without it. FM_SSH_USER= # The fleet's addresses, one list, in this order: meleys, vermithor, caraxes, -# syrax, vhagar. Required, exactly five IPv4 addresses; the monitor refuses to -# boot on anything else. scripts/nas-host.sh reads this same list (plus -# FM_SSH_USER) to build the NAS SSH target for every skill script. +# syrax, vhagar, balerion. Required, exactly six IPv4 addresses; the monitor +# refuses to boot on anything else. scripts/nas-host.sh reads this same list +# (plus FM_SSH_USER) to build the NAS SSH target for every skill script. FM_HOST_IPS= # --- 3c. Play history ------------------------------------------------------- diff --git a/apps/admin-portal/src/lib/fleetApi.test.ts b/apps/admin-portal/src/lib/fleetApi.test.ts index aecc5f6b..8851fee1 100644 --- a/apps/admin-portal/src/lib/fleetApi.test.ts +++ b/apps/admin-portal/src/lib/fleetApi.test.ts @@ -33,11 +33,15 @@ vi.mock('@/lib/supabaseClient', () => ({ // percent, dividing load by a hardcoded four, comparing disk against a warn // threshold, regex-parsing container names out of metric keys - moved to the // side that owns those facts, and is tested there. +// A TEST-NET-1 address (RFC 5737): reserved for examples, never a real host. +const HOST_IP = '192.0.2.3' + const host: FleetHost = { name: 'vermithor', - ip: '192.0.2.3', + ip: HOST_IP, has_gpu: true, has_docker: true, + console: { name: 'DiskStation Manager', url: `http://${HOST_IP}:5000/` }, collected: true, status: 'ok', cores: 4, diff --git a/apps/admin-portal/src/lib/fleetApi.ts b/apps/admin-portal/src/lib/fleetApi.ts index df1ba507..b58feae2 100644 --- a/apps/admin-portal/src/lib/fleetApi.ts +++ b/apps/admin-portal/src/lib/fleetApi.ts @@ -62,15 +62,6 @@ export const plural = ({ count, unit }: { count: number; unit: string }): string /** A metric age in words. "unknown" for an absent age, because a host that was never measured has no age at all, and rendering it as 0 would read as fresh. */ -/* DiskStation Manager's own port. Every box answers on both 5000 (http) and - 5001 (https, self-signed), checked 2026-11-07; the plain port opens straight - to the login page instead of behind a certificate warning, and DSM encrypts - the password itself before it leaves the browser. */ -const DSM_PORT = 5000 - -/** A host's DSM login page, which its card on the Fleet page links to. */ -export const dsmUrl = ({ ip }: { ip: string }): string => `http://${ip}:${DSM_PORT}/` - export const formatAge = (seconds: number | null): string => { if (seconds === null || !Number.isFinite(seconds) || seconds < 0) return 'unknown' const unit = AGE_UNITS.find((candidate) => seconds >= candidate.seconds) diff --git a/apps/admin-portal/src/pages/Fleet/Fleet.test.tsx b/apps/admin-portal/src/pages/Fleet/Fleet.test.tsx index 5caa68f8..a18be0c6 100644 --- a/apps/admin-portal/src/pages/Fleet/Fleet.test.tsx +++ b/apps/admin-portal/src/pages/Fleet/Fleet.test.tsx @@ -13,12 +13,16 @@ import { useFleetPrefsStore, } from '@/stores/fleetPrefsStore' +// A TEST-NET-1 address (RFC 5737): reserved for examples, never a real host. +const HOST_IP = '192.0.2.3' + // What a card is rendered from: one /fleet host, read as the wire sends it. const card: FleetHost = { name: 'vermithor', - ip: '192.0.2.3', + ip: HOST_IP, has_gpu: true, has_docker: true, + console: { name: 'DiskStation Manager', url: `http://${HOST_IP}:5000/` }, collected: true, status: 'warn', cores: 4, @@ -38,9 +42,10 @@ const card: FleetHost = { const host: FleetHost = { name: 'vermithor', - ip: '192.0.2.3', + ip: HOST_IP, has_gpu: true, has_docker: true, + console: { name: 'DiskStation Manager', url: `http://${HOST_IP}:5000/` }, collected: true, status: 'ok', cores: 4, @@ -258,6 +263,15 @@ test('HostCard opens its DSM login page in a new tab', () => { expect(link).toHaveAccessibleDescription('Opens DiskStation Manager in a new tab') }) +test('HostCard links to whichever console the monitor names', () => { + const ugos = { name: 'UGOS', url: 'http://192.0.2.7:9999/' } + render() + + const link = screen.getByRole('link', { name: 'balerion' }) + expect(link).toHaveAttribute('href', ugos.url) + expect(link).toHaveAccessibleDescription('Opens UGOS in a new tab') +}) + /* A warn host prints no status word at all: the finding is the disk and load figures the monitor judged, not a phrase summarising them over the name. */ test('HostCard prints no status line on a warn host', () => { diff --git a/apps/admin-portal/src/pages/Fleet/HostCard.module.scss b/apps/admin-portal/src/pages/Fleet/HostCard.module.scss index a1771798..b756a15b 100644 --- a/apps/admin-portal/src/pages/Fleet/HostCard.module.scss +++ b/apps/admin-portal/src/pages/Fleet/HostCard.module.scss @@ -39,7 +39,7 @@ translate 180ms ease-out; &:hover, - &:has(.dsmLink:focus-visible) { + &:has(.consoleLink:focus-visible) { border-color: color-mix( in oklab, var(--series-color, var(--color-border)) 70%, @@ -53,7 +53,7 @@ } } - &:has(.dsmLink:focus-visible) { + &:has(.consoleLink:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; } @@ -62,7 +62,7 @@ /* The host name, and through its overlay the whole card. Inherits the name's colour rather than link blue: the card's lift and the mark beside the name are what say it opens something. */ -.dsmLink { +.consoleLink { display: inline-grid; align-items: center; grid-auto-flow: column; @@ -85,7 +85,7 @@ } // Says "opens elsewhere" without words; the words are in the hidden span. -.dsmMark { +.consoleMark { color: var(--color-muted); transition: color 180ms ease-out; diff --git a/apps/admin-portal/src/pages/Fleet/HostCard.tsx b/apps/admin-portal/src/pages/Fleet/HostCard.tsx index fce6e179..488a532e 100644 --- a/apps/admin-portal/src/pages/Fleet/HostCard.tsx +++ b/apps/admin-portal/src/pages/Fleet/HostCard.tsx @@ -3,7 +3,6 @@ import { Icon, type IconName } from '@/components/Icon/Icon' import { IconTile, type IconTileTone } from '@/components/IconTile/IconTile' import { formatAge, - dsmUrl, formatBytes, type FleetContainer, type FleetHost, @@ -239,7 +238,7 @@ export const HostCard = ({ host, className }: HostCardProps) => { const coreContext = host.cores === null ? '' : `${host.cores} ${host.cores === 1 ? 'core' : 'cores'}` const hasFooter = host.has_gpu || host.has_docker - const dsmHintId = useId() + const consoleHintId = useId() return (
{

{/* The whole card is the link: the anchor's overlay stretches over the - card, so a click anywhere opens DSM, while the name stays the one - focusable, announced element. The containers disclosure sits above - the overlay and keeps its own click. */} + card, so a click anywhere opens the host's console, while the name + stays the one focusable, announced element. The containers + disclosure sits above the overlay and keeps its own click. */} {host.name} - +

- - Opens DiskStation Manager in a new tab + + Opens {host.console.name} in a new tab

{host.ip}

{/* status is stated in text, never by color alone: the tile restates diff --git a/apps/admin-portal/src/pages/Fleet/series.module.scss b/apps/admin-portal/src/pages/Fleet/series.module.scss index c442fa3d..4f0f0236 100644 --- a/apps/admin-portal/src/pages/Fleet/series.module.scss +++ b/apps/admin-portal/src/pages/Fleet/series.module.scss @@ -21,3 +21,7 @@ .series5 { --series-color: var(--color-series-5); } + +.series6 { + --series-color: var(--color-series-6); +} diff --git a/apps/admin-portal/src/pages/Fleet/seriesPalette.ts b/apps/admin-portal/src/pages/Fleet/seriesPalette.ts index 4af09e1a..87df1c16 100644 --- a/apps/admin-portal/src/pages/Fleet/seriesPalette.ts +++ b/apps/admin-portal/src/pages/Fleet/seriesPalette.ts @@ -10,6 +10,7 @@ const SERIES_CLASSES = [ styles.series3, styles.series4, styles.series5, + styles.series6, ] as const /** The class binding one host position to its colour, or '' past the palette. */ diff --git a/apps/admin-portal/src/styles/globals.scss b/apps/admin-portal/src/styles/globals.scss index 44e6b906..878bbfc3 100644 --- a/apps/admin-portal/src/styles/globals.scss +++ b/apps/admin-portal/src/styles/globals.scss @@ -22,7 +22,7 @@ /* Chart series identity, one slot per fleet host, always paired with the host's name in text. The order is the colourblind-safety mechanism, not a mood: this exact sequence passes the dataviz palette validator against - --color-surface (worst adjacent CVD ΔE 8.4, normal-vision 19.3), so never + --color-surface (worst adjacent CVD ΔE 8.4, normal-vision 17.4), so never reorder or restep a slot without re-running it. Slots 2 and 5 sit just under 3:1 on the surface, which is why the chart ships a table view. */ --color-series-1: #3987e5; @@ -30,6 +30,7 @@ --color-series-3: #199e70; --color-series-4: #c98500; --color-series-5: #d55181; + --color-series-6: #9b7be0; /* Play types on the plays tables, always beside the type's name. Hues the series palette leaves alone, so a type never reads as a server. Each diff --git a/apps/fleet-monitor/src/api/api.test.ts b/apps/fleet-monitor/src/api/api.test.ts index 31cc33d1..4b9cbc4c 100644 --- a/apps/fleet-monitor/src/api/api.test.ts +++ b/apps/fleet-monitor/src/api/api.test.ts @@ -250,7 +250,7 @@ describe('the fleet API', () => { const body = await fleet() expect(new Set(body.hosts.map((host) => host.name))).toEqual( - new Set(['vermithor', 'meleys', 'syrax', 'vhagar', 'caraxes']), + new Set(['vermithor', 'meleys', 'syrax', 'vhagar', 'caraxes', 'balerion']), ) const vermithor = hostNamed(body, 'vermithor') expect(vermithor.metrics['load.1m']).toBe(0.46) @@ -761,7 +761,7 @@ describe('the fleet API', () => { const wide = await history('/fleet/cpu?minutes=30') expect(narrow.window_minutes).toBe(5) - expect(narrow.hosts.map((host) => host.points)).toEqual([[], [], [], [], []]) + expect(narrow.hosts.map((host) => host.points)).toEqual([[], [], [], [], [], []]) expect(values(wide.hosts[0].points)).toEqual([25.0]) }) diff --git a/apps/fleet-monitor/src/config.test.ts b/apps/fleet-monitor/src/config.test.ts index 5167ddaf..b5202e44 100644 --- a/apps/fleet-monitor/src/config.test.ts +++ b/apps/fleet-monitor/src/config.test.ts @@ -3,6 +3,7 @@ import { dbPath, fleetHosts, host, + hostConsole, hostIps, MAX_ROUND_SECONDS, PLEX_HISTORY_INTERVAL, @@ -30,11 +31,11 @@ describe('config', () => { }) it('configures every fleet host', () => { - expect(names(HOSTS)).toEqual(['caraxes', 'meleys', 'syrax', 'vermithor', 'vhagar']) + expect(names(HOSTS)).toEqual(['balerion', 'caraxes', 'meleys', 'syrax', 'vermithor', 'vhagar']) }) it('gives only vermithor and vhagar a render node', () => { - // measured 2026-08-10: meleys is AMD, syrax is Atom, caraxes is ARM + // measured 2026-08-10: meleys is AMD, syrax is Atom, caraxes is ARM; balerion is unprobed expect(names(HOSTS.filter(({ has_gpu }) => has_gpu))).toEqual(['vermithor', 'vhagar']) }) @@ -56,30 +57,38 @@ describe('config', () => { caraxes: '192.0.2.4', syrax: '192.0.2.5', vhagar: '192.0.2.6', + balerion: '192.0.2.7', }) }) it.each([ ['is unset', undefined], ['is empty', ''], - ['is one address short', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5'], - ['has one address too many', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,192.0.2.7'], - ['holds a hostname', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,nas.example.com'], - ['holds an octet over 255', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.256'], + ['is one address short', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6'], + [ + 'has one address too many', + '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,192.0.2.7,192.0.2.8', + ], + ['holds a hostname', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,nas.example.com'], + ['holds an octet over 255', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,192.0.2.256'], ])('refuses a fleet list that %s', (_label, value) => { vi.stubEnv('FM_HOST_IPS', value) - expect(() => hostIps()).toThrow(/FM_HOST_IPS must list 5/) + expect(() => hostIps()).toThrow(/FM_HOST_IPS must list 6/) expect(() => fleetHosts()).toThrow(/FM_HOST_IPS/) }) it('trims whitespace around each address', () => { - vi.stubEnv('FM_HOST_IPS', ' 192.0.2.12 , 192.0.2.13,192.0.2.14 ,192.0.2.15,192.0.2.16') + vi.stubEnv( + 'FM_HOST_IPS', + ' 192.0.2.12 , 192.0.2.13,192.0.2.14 ,192.0.2.15,192.0.2.16,192.0.2.17', + ) expect(fleetHosts().map(({ ip }) => ip)).toEqual([ '192.0.2.12', '192.0.2.13', '192.0.2.14', '192.0.2.15', '192.0.2.16', + '192.0.2.17', ]) }) @@ -125,14 +134,32 @@ describe('config', () => { expect(MAX_ROUND_SECONDS).toBe((VITALS_TIMEOUT + SLOW_TIMEOUT) * CAPTURE_FACTOR) }) - it('gives every host a plex url', () => { - // Plex runs natively on all five boxes (measured 2026-09-18), so an empty - // url here would silently drop a server from every play-history view + it('links balerion to UGOS and every other host to DSM', () => { + expect(Object.fromEntries(fleetHosts().map((each) => [each.name, hostConsole(each)]))).toEqual({ + meleys: { name: 'DiskStation Manager', url: 'http://192.0.2.2:5000/' }, + vermithor: { name: 'DiskStation Manager', url: 'http://192.0.2.3:5000/' }, + caraxes: { name: 'DiskStation Manager', url: 'http://192.0.2.4:5000/' }, + syrax: { name: 'DiskStation Manager', url: 'http://192.0.2.5:5000/' }, + vhagar: { name: 'DiskStation Manager', url: 'http://192.0.2.6:5000/' }, + balerion: { name: 'UGOS', url: 'http://192.0.2.7:9999/' }, + }) + }) + + it('gives every host that runs plex a plex url', () => { + /* Plex runs natively on the five Synology boxes (measured 2026-09-18), so an + empty url here would silently drop a server from every play-history view; + balerion is the media store and runs none */ expect(names(plexHosts())).toEqual(['caraxes', 'meleys', 'syrax', 'vermithor', 'vhagar']) }) it('keeps plex hosts in config order', () => { - expect(plexHosts().map(({ name }) => name)).toEqual(HOSTS.map(({ name }) => name)) + expect(plexHosts().map(({ name }) => name)).toEqual([ + 'meleys', + 'vermithor', + 'caraxes', + 'syrax', + 'vhagar', + ]) }) it('addresses the two secure-only servers over https', () => { @@ -145,6 +172,7 @@ describe('config', () => { caraxes: 'http://192.0.2.4:32400', syrax: 'http://192.0.2.5:32400', vhagar: 'https://192.0.2.6:32400', + balerion: '', }) }) diff --git a/apps/fleet-monitor/src/config.ts b/apps/fleet-monitor/src/config.ts index 0ea1f955..84c32b7d 100644 --- a/apps/fleet-monitor/src/config.ts +++ b/apps/fleet-monitor/src/config.ts @@ -58,22 +58,26 @@ export type Host = Readonly<{ docker_url: string // Empty means "no Plex here", the same contract docker_url follows. plex_url: string + console: ConsoleKind }> -/** A host, frozen, with `plex_url` defaulting to empty like the Python dataclass. */ +/** A host, frozen, with `plex_url` defaulting to empty like the Python + dataclass and `console` to DSM, which every box but balerion runs. */ export const host = ({ name, ip, has_gpu, docker_url, plex_url = '', + console = 'dsm', }: { name: string ip: string has_gpu: boolean docker_url: string plex_url?: string -}): Host => Object.freeze({ name, ip, has_gpu, docker_url, plex_url }) + console?: ConsoleKind +}): Host => Object.freeze({ name, ip, has_gpu, docker_url, plex_url, console }) // Measured 2026-08-10, GPU absence re-verified 2026-08-11. // @@ -100,39 +104,65 @@ export const host = ({ // against the docker: target only; the containers behind it are never // observed, so no container result is recorded either way. See collector. // -// plex_url: Plex Media Server runs natively on all five (measured 2026-09-18, -// all on 1.43.4). vermithor and vhagar require secure connections and close a -// plain-http socket without a response, so they are addressed over https; -// the certificate they present is Plex's *.plex.direct wildcard, which cannot +// plex_url: Plex Media Server runs natively on all five Synology boxes +// (measured 2026-09-18, all on 1.43.4). vermithor and vhagar require secure +// connections and close a plain-http socket without a response, so they are +// addressed over https; the certificate they present is Plex's *.plex.direct wildcard, which cannot // verify against a LAN ip, so plex sync connects to an https url with // verification off. The owner token still authorizes every request. +// +// balerion is a UGreen NAS (UGOS, not DSM) added 2026-11-23 as the media store +// Meleys mounts over CIFS. Plex stays on Meleys, so it has no plex_url; Docker +// and GPU are unprobed until ssh is enabled there and they can be measured. const DOCKER_PORT = 2375 const PLEX_PORT = 32400 +/* Each NAS vendor's management console, over plain http. DSM answers on both + 5000 and 5001 (https, self-signed), checked 2026-11-07; the plain port opens + straight to the login page instead of behind a certificate warning, and DSM + encrypts the password itself before it leaves the browser. UGOS answers on + 9999, checked 2026-11-23. */ +const CONSOLES = { + dsm: { name: 'DiskStation Manager', port: 5000 }, + ugos: { name: 'UGOS', port: 9999 }, +} as const + +type ConsoleKind = keyof typeof CONSOLES + +/** A host's management console: the login page its Fleet card links to, and + the product's name for the link's description. */ +export const hostConsole = ({ ip, console }: Pick) => { + const { name, port } = CONSOLES[console] + return { name, url: `http://${ip}:${port}/` } +} + /** * What the fleet is, minus where it lives: the address of each box comes from * FM_HOST_IPS, in this order, so no ip is ever committed. * * `docker` marks a host that exposes Docker over TCP; `plex` is the scheme its - * Plex answers on. + * Plex answers on; `console` is the vendor management UI it runs. */ const FLEET: readonly Readonly<{ name: string has_gpu: boolean docker: boolean - plex: 'http' | 'https' + // null where no Plex runs: the host is monitored but has no play history. + plex: 'http' | 'https' | null + console: ConsoleKind }>[] = [ - { name: 'meleys', has_gpu: false, docker: true, plex: 'http' }, - { name: 'vermithor', has_gpu: true, docker: true, plex: 'https' }, - { name: 'caraxes', has_gpu: false, docker: false, plex: 'http' }, - { name: 'syrax', has_gpu: false, docker: false, plex: 'http' }, - { name: 'vhagar', has_gpu: true, docker: true, plex: 'https' }, + { name: 'meleys', has_gpu: false, docker: true, plex: 'http', console: 'dsm' }, + { name: 'vermithor', has_gpu: true, docker: true, plex: 'https', console: 'dsm' }, + { name: 'caraxes', has_gpu: false, docker: false, plex: 'http', console: 'dsm' }, + { name: 'syrax', has_gpu: false, docker: false, plex: 'http', console: 'dsm' }, + { name: 'vhagar', has_gpu: true, docker: true, plex: 'https', console: 'dsm' }, + { name: 'balerion', has_gpu: false, docker: false, plex: null, console: 'ugos' }, ] /** * The fleet's addresses from FM_HOST_IPS, a comma-separated list of IPv4 * addresses in the order FLEET names the hosts (meleys, vermithor, caraxes, - * syrax, vhagar). + * syrax, vhagar, balerion). * * Throws, naming the variable and the expected order but never echoing a * value, when the list is missing, the wrong length, or holds anything that is @@ -158,15 +188,17 @@ export const hostIps = (): readonly string[] => { export const fleetHosts = (): readonly Host[] => { const ips = hostIps() return Object.freeze( - FLEET.map(({ name, has_gpu, docker, plex }, index) => - host({ + FLEET.map(({ name, has_gpu, docker, plex, console }, index) => { + const ip = ips[index] ?? '' + return host({ name, - ip: ips[index] ?? '', + ip, has_gpu, - docker_url: docker ? `http://${ips[index] ?? ''}:${DOCKER_PORT}` : '', - plex_url: `${plex}://${ips[index] ?? ''}:${PLEX_PORT}`, - }), - ), + docker_url: docker ? `http://${ip}:${DOCKER_PORT}` : '', + plex_url: plex ? `${plex}://${ip}:${PLEX_PORT}` : '', + console, + }) + }), ) } @@ -182,7 +214,7 @@ export const plexHosts = (hosts: readonly Host[] = fleetHosts()): readonly Host[ export const dbPath = (): string => process.env.FM_DB_PATH ?? '/data/fleet.db' /** - * The unprivileged account that holds the shared key on all five boxes. + * The unprivileged account that holds the shared key on every fleet host. * Throws when FM_SSH_USER is unset, so a missing account fails loudly instead * of probing as a guessed one. */ diff --git a/apps/fleet-monitor/src/fleet.test.ts b/apps/fleet-monitor/src/fleet.test.ts index 8f51e182..e05439b7 100644 --- a/apps/fleet-monitor/src/fleet.test.ts +++ b/apps/fleet-monitor/src/fleet.test.ts @@ -144,7 +144,7 @@ describe('fleetView', () => { const fleet = view() expect(new Set(fleet.hosts.map((host) => host.name))).toEqual( - new Set(['vermithor', 'meleys', 'syrax', 'vhagar', 'caraxes']), + new Set(['vermithor', 'meleys', 'syrax', 'vhagar', 'caraxes', 'balerion']), ) const vermithor = hostNamed('vermithor') expect(vermithor.metrics['load.1m']).toBe(0.46) diff --git a/apps/fleet-monitor/src/fleet.ts b/apps/fleet-monitor/src/fleet.ts index 33e76b21..cbba82d5 100644 --- a/apps/fleet-monitor/src/fleet.ts +++ b/apps/fleet-monitor/src/fleet.ts @@ -9,7 +9,7 @@ // Nothing here opens a session. Every function takes the connection the route // already has, so answering for the whole fleet costs one. -import { fleetHosts, type Host, SLOW_INTERVAL, VITALS_INTERVAL } from '@/config.js' +import { fleetHosts, type Host, hostConsole, SLOW_INTERVAL, VITALS_INTERVAL } from '@/config.js' import type { Connection } from '@/db.js' import { observedRun, uptimePercent } from '@/incidents.js' import { type ContainerView, fromSamples } from '@/probes/docker.js' @@ -89,6 +89,8 @@ export type HostView = Readonly<{ ip: string has_gpu: boolean has_docker: boolean + // the vendor UI the portal's card links to, which only the fleet config knows + console: ReturnType collected: boolean status: HostState cores: number | null @@ -293,6 +295,7 @@ export const hostView = ({ ip: host.ip, has_gpu: host.has_gpu, has_docker: !!host.docker_url, + console: hostConsole(host), collected, status: hostState({ collected, diskPercent, loadPerCore }), cores, diff --git a/apps/fleet-monitor/src/series.test.ts b/apps/fleet-monitor/src/series.test.ts index db8d1fae..2cb1c4a3 100644 --- a/apps/fleet-monitor/src/series.test.ts +++ b/apps/fleet-monitor/src/series.test.ts @@ -410,7 +410,7 @@ describe('fleetHistory', () => { const narrow = fleetHistory({ connection: db, kind: 'cpu', minutes: 5, now: NOW }) expect(narrow.window_minutes).toBe(5) - expect(narrow.hosts.map((host) => host.points)).toEqual([[], [], [], [], []]) + expect(narrow.hosts.map((host) => host.points)).toEqual([[], [], [], [], [], []]) expect(valuesByHost({ kind: 'cpu', minutes: 30 }).meleys).toEqual([25]) }) diff --git a/apps/fleet-monitor/src/test/env.ts b/apps/fleet-monitor/src/test/env.ts index 373349e5..3b9fd51e 100644 --- a/apps/fleet-monitor/src/test/env.ts +++ b/apps/fleet-monitor/src/test/env.ts @@ -1,6 +1,6 @@ -// The fleet's addresses and ssh account come from the environment, so every -// test file starts with the same documentation-range fleet (RFC 5737) in -// meleys, vermithor, caraxes, syrax, vhagar order. A test that needs another -// value stubs it with vi.stubEnv, which restores these afterwards. -process.env.FM_HOST_IPS = '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6' +/* The fleet's addresses and ssh account come from the environment, so every + test file starts with the same documentation-range fleet (RFC 5737) in + meleys, vermithor, caraxes, syrax, vhagar, balerion order. A test that needs + another value stubs it with vi.stubEnv, which restores these afterwards. */ +process.env.FM_HOST_IPS = '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,192.0.2.7' process.env.FM_SSH_USER = 'fleet' diff --git a/docs/fleet-monitor-deployment.md b/docs/fleet-monitor-deployment.md index 698e612c..41dd56d9 100644 --- a/docs/fleet-monitor-deployment.md +++ b/docs/fleet-monitor-deployment.md @@ -49,7 +49,7 @@ both probe it without a session, and it reports only liveness and staleness. ### 1. Mint an ssh key for the collector -The collector reaches all five hosts over ssh. It needs its own key, **not** a +The collector reaches all six hosts over ssh. It needs its own key, **not** a copy of a human's: revoking the monitor should be deleting one `authorized_keys` line. As of this writing `` on meleys has no private key at all, so this step is required, not a check. @@ -64,7 +64,7 @@ chmod 700 /volume1/docker/stripe-bridge/fleet-monitor-ssh chmod 600 /volume1/docker/stripe-bridge/fleet-monitor-ssh/id_ed25519 ``` -Then append that public key to `~/.ssh/authorized_keys` on **all five** +Then append that public key to `~/.ssh/authorized_keys` on **all six** hosts — meleys included, since the collector ssh-es to the box it runs on: ```bash diff --git a/libs/wire/src/fleet.ts b/libs/wire/src/fleet.ts index b6934ad3..e0259ad1 100644 --- a/libs/wire/src/fleet.ts +++ b/libs/wire/src/fleet.ts @@ -43,6 +43,9 @@ export const fleetHostSchema = z.object({ ip: z.string(), has_gpu: z.boolean(), has_docker: z.boolean(), + /** The vendor management UI the card links to: DSM on the Synology boxes, + UGOS on balerion. Fleet knowledge, so the monitor names it. */ + console: z.object({ name: z.string(), url: z.string() }), collected: z.boolean(), status: hostStatusSchema, cores: z.number().nullable(), diff --git a/scripts/ci/smoke-container.sh b/scripts/ci/smoke-container.sh index 7bb23033..de8d8acf 100644 --- a/scripts/ci/smoke-container.sh +++ b/scripts/ci/smoke-container.sh @@ -27,7 +27,7 @@ case "$app" in port=8010 ready=/health config=( - -e 'FM_HOST_IPS=192.0.2.10,192.0.2.11,192.0.2.12,192.0.2.13,192.0.2.14' + -e 'FM_HOST_IPS=192.0.2.10,192.0.2.11,192.0.2.12,192.0.2.13,192.0.2.14,192.0.2.15' -e FM_SSH_USER=sanity -e FM_DB_PATH=/tmp/sanity.db ) diff --git a/scripts/nas-host.sh b/scripts/nas-host.sh index cc29daf3..c939642b 100755 --- a/scripts/nas-host.sh +++ b/scripts/nas-host.sh @@ -2,13 +2,13 @@ # Prints the ssh target (user@ip) of one fleet host, built from the gitignored # .env so no address or account name is ever committed. # -# scripts/nas-host.sh [meleys|vermithor|caraxes|syrax|vhagar] (default meleys) +# scripts/nas-host.sh [meleys|vermithor|caraxes|syrax|vhagar|balerion] (default meleys) # # Resolution, first hit wins: # 1. the host's override: WZ_NAS_HOST for meleys, WZ__SSH for any host # 2. FM_SSH_USER plus the host's position in FM_HOST_IPS, the same # comma-separated list the fleet monitor reads (meleys, vermithor, -# caraxes, syrax, vhagar order) +# caraxes, syrax, vhagar, balerion order) # Values come from the environment, then from the .env at the repo root # (WZ_ENV_FILE points at another one). Fails, naming what is missing, rather # than guessing a target. @@ -24,7 +24,8 @@ case "$host" in caraxes) index=3 ;; syrax) index=4 ;; vhagar) index=5 ;; - *) echo "nas-host: unknown host '$host' (meleys, vermithor, caraxes, syrax, vhagar)" >&2; exit 2 ;; + balerion) index=6 ;; + *) echo "nas-host: unknown host '$host' (meleys, vermithor, caraxes, syrax, vhagar, balerion)" >&2; exit 2 ;; esac # The value of a variable: the environment wins, then the last assignment in the env file.