From 49661c4a1491f5df6a2b9862d847475e273d88a3 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Mon, 16 Nov 2026 08:54:49 -0700 Subject: [PATCH] Today, Services and Hosts by site: the dashboard as a briefing The dashboard (now Today) answers whether anything needs you before it shows a number (#69): a sentence on that and on customers, Needs you with I'm on it (the acknowledgement), Being handled, Can wait, the services with their last 24 hours, what happened since you last looked, and the fleet in a line with what's worth watching. The gauges and the host cards go; readings live on the Hosts page. A Services page lists every service by tier with its state, its day and its month; picking one shows its parts in trouble, what it needs and what needs it (#71). The Hosts page opens on one square per host by site and role, with the watch list above and the table a click away, from GET /api/v1/fleet. The sidebar is grouped by what people come to do: Today, Fleet, Maps, Connected to (#72). --- docs/cluster-watcher.md | 5 +- docs/formats.md | 28 +- internal/server/fleetgrid.go | 148 +++++++++ internal/server/server.go | 1 + internal/server/today_test.go | 31 ++ web/src/lib/FleetGrid.svelte | 144 ++++++++ web/src/lib/Shell.svelte | 44 ++- web/src/lib/Strip.svelte | 18 + web/src/lib/api.ts | 22 +- web/src/routes/+page.svelte | 478 ++++++++++++++++++--------- web/src/routes/hosts/+page.svelte | 31 +- web/src/routes/services/+page.svelte | 227 +++++++++++++ 12 files changed, 990 insertions(+), 187 deletions(-) create mode 100644 internal/server/fleetgrid.go create mode 100644 web/src/lib/FleetGrid.svelte create mode 100644 web/src/lib/Strip.svelte create mode 100644 web/src/routes/services/+page.svelte diff --git a/docs/cluster-watcher.md b/docs/cluster-watcher.md index 79058c5..20358c8 100644 --- a/docs/cluster-watcher.md +++ b/docs/cluster-watcher.md @@ -327,12 +327,13 @@ hide a real outage. Built on the paged, server-side lists from #69. No page ever lists everything at once. -- **Dashboard:** one line per cluster: its version, state and a summary +- **Clusters page:** one line per cluster: its version, state and a summary in its kind's terms: "31/32 nodes ready · 3,300 workloads" for Kubernetes, "2/2 controllers ready · 600 volumes · 71% used" for an array, "CPU 41% · system ASP 85% · 4 of 5 subsystems active" for an IBM i partition. The network map's cluster boxes use the same line. - The "needs attention" list takes workloads too, capped as for hosts. + The dashboard counts the clusters with a problem, and its "needs you" + and "can wait" lists take workloads too, capped as for hosts. - **Clusters:** in sections by kind (Kubernetes, Virtualization, Storage, IBM i, Secrets), the ones that need a look first in each, with a jump list counting each kind and its problems. Filters for kind, "need a diff --git a/docs/formats.md b/docs/formats.md index c70d2de..daf8275 100644 --- a/docs/formats.md +++ b/docs/formats.md @@ -728,8 +728,29 @@ restarts; admins can preview it and send it by hand on the Reports page. ### The dashboard's briefing -The same history feeds the dashboard. `GET /api/v1/overview` carries, -besides the readings: +The dashboard (Today) is written to be read, not scanned for numbers. It +opens with a sentence on whether anything needs you and whether +customers are affected (the services with `tier: public`), then: + +- **Needs you:** critical and serious problems nobody has picked up, each + with when it started, whether people were told and what it takes down. + **I'm on it** is the acknowledgement: the repeats stop, and the problem + moves to **Being handled** with who has it. +- **Can wait:** warnings, one line each with why. +- **Your services:** each service's state and its last 24 hours, one bar + per half hour. The **Services** page lists them all by tier (what + customers use, what runs it, where the data lives, the edge); picking one + shows its parts in trouble, what it needs and what needs it. +- **Since you last looked:** what opened and closed since your last visit. +- **The fleet:** hosts reporting, containers, clusters and the busiest + host, and what's worth watching: disks filling up, hosts busier than + usual for the hour, hosts restarted in the last day. The **Hosts** page + shows the same list over one square per host, grouped by the network + map's sites and by role, the host name's first word after its site + (phx1-app05 is an app server); the table is a click away. + +The same history feeds it. `GET /api/v1/overview` carries, besides the +readings: - `today`: what happened since this person last looked. A visit ends after 30 minutes without the dashboard open, and the end of the last one is @@ -754,7 +775,8 @@ besides the readings: The strips and uptimes are read from history once a minute (30 days every ten), the watch list every ten minutes, whatever the number of dashboards -open. +open. `GET /api/v1/fleet` is the Hosts page's squares: every host's state +by site and role, the hosts that need a look per site, and the watch list. ## checks.yaml: active checks diff --git a/internal/server/fleetgrid.go b/internal/server/fleetgrid.go new file mode 100644 index 0000000..bf7da5b --- /dev/null +++ b/internal/server/fleetgrid.go @@ -0,0 +1,148 @@ +package server + +import ( + "net/http" + "sort" + "strings" + "time" +) + +// The Hosts page's grid (#72): one square per host, grouped by site (the +// network map's) and role, so at thousands of hosts the odd one out still +// stands out. GET /api/v1/fleet; not under /hosts/, where a host named +// "grid" would lose its page. + +// GridSite is a site's hosts by role. +type GridSite struct { + ID string `json:"id"` + Name string `json:"name"` + Roles []GridRole `json:"roles"` + Hosts int `json:"hosts"` + // Trouble is its hosts that need a look, worst first. + Trouble []GridHost `json:"trouble"` +} + +// GridRole is one role's hosts in a site. +type GridRole struct { + Role string `json:"role"` + Hosts []GridHost `json:"hosts"` +} + +// GridHost is one square. +type GridHost struct { + Name string `json:"name"` + Status string `json:"status"` + Word string `json:"word"` +} + +// hostRole is what a host is from its name: the first word after its +// site, without its number. phx1-app05 in phx1 is "app", web-02 is "web", +// win-dc01 is "win", host3 is "host". +func hostRole(name, site string) string { + r := name + if site != "" && strings.HasPrefix(r, site) { + r = r[len(site):] + } + r = strings.Trim(r, "-_.") + if i := strings.IndexAny(r, "-_."); i >= 0 { + r = r[:i] + } + r = strings.TrimRight(r, "0123456789") + if r == "" { + return "other" + } + return r +} + +// fleetGrid groups hosts by site and role. siteOf names each host's site +// (id → name in names); hosts in none go under "Elsewhere". +func fleetGrid(hosts []HostView, siteOf map[string]string, names map[string]string) []GridSite { + by := map[string]*GridSite{} + roles := map[string]map[string]*GridRole{} + // A host the map didn't place (a collector, one without map samples) + // goes with the site its name starts with, when one does: phx1-stor01 + // with phx1. + prefixes := map[string]string{} + for id, n := range names { + if n != "" { + prefixes[n] = id + } + } + for _, h := range hosts { + id := siteOf[h.Name] + if id == "" { + if p, _, ok := strings.Cut(h.Name, "-"); ok && prefixes[p] != "" { + id = prefixes[p] + } + } + s := by[id] + if s == nil { + name := names[id] + if id == "" { + name = "Elsewhere" + } + s = &GridSite{ID: id, Name: name, Trouble: []GridHost{}} + by[id] = s + roles[id] = map[string]*GridRole{} + } + prefix := names[id] + role := hostRole(h.Name, prefix) + r := roles[id][role] + if r == nil { + r = &GridRole{Role: role} + roles[id][role] = r + } + st := h.Status + if h.Silent { + st = "critical" + } + g := GridHost{Name: h.Name, Status: st, Word: h.Word} + r.Hosts = append(r.Hosts, g) + s.Hosts++ + if st == "warning" || st == "serious" || st == "critical" { + s.Trouble = append(s.Trouble, g) + } + } + out := []GridSite{} + for id, s := range by { + for _, r := range roles[id] { + sort.Slice(r.Hosts, func(i, j int) bool { return r.Hosts[i].Name < r.Hosts[j].Name }) + s.Roles = append(s.Roles, *r) + } + // The biggest role first (the app servers), then by name. + sort.Slice(s.Roles, func(i, j int) bool { + if len(s.Roles[i].Hosts) != len(s.Roles[j].Hosts) { + return len(s.Roles[i].Hosts) > len(s.Roles[j].Hosts) + } + return s.Roles[i].Role < s.Roles[j].Role + }) + sort.SliceStable(s.Trouble, func(i, j int) bool { return statusRank[s.Trouble[i].Status] > statusRank[s.Trouble[j].Status] }) + out = append(out, *s) + } + // Sites by size, Elsewhere last. + sort.Slice(out, func(i, j int) bool { + if (out[i].ID == "") != (out[j].ID == "") { + return out[j].ID == "" + } + if out[i].Hosts != out[j].Hosts { + return out[i].Hosts > out[j].Hosts + } + return out[i].Name < out[j].Name + }) + return out +} + +func (srv *Server) handleFleet(w http.ResponseWriter, r *http.Request) { + now := time.Now() + hosts, _ := srv.view(now) + siteOf, names := map[string]string{}, map[string]string{} + if g := srv.mapGraph(now); g != nil { + for _, s := range g.Sites { + names[s.ID] = s.Name + for _, h := range s.Hosts { + siteOf[h] = s.ID + } + } + } + writeJSON(w, http.StatusOK, map[string]any{"sites": fleetGrid(hosts, siteOf, names), "watch": srv.watch(hosts, now)}) +} diff --git a/internal/server/server.go b/internal/server/server.go index d6b31c4..7670912 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -428,6 +428,7 @@ func (srv *Server) Handler() http.Handler { mux.HandleFunc("GET /api/v1/map/network", srv.needSession(srv.handleMapNetwork)) mux.HandleFunc("GET /api/v1/map/services", srv.needSession(srv.handleMapServices)) mux.HandleFunc("GET /api/v1/services", srv.needSession(srv.handleServices)) + mux.HandleFunc("GET /api/v1/fleet", srv.needSession(srv.handleFleet)) mux.HandleFunc("GET /api/v1/map/find", srv.needSession(srv.handleMapFind)) mux.HandleFunc("GET /api/v1/map/found", srv.needSession(srv.handleMapFound)) mux.HandleFunc("GET /api/v1/map/corrections", srv.needSession(srv.handleMapCorrections)) diff --git a/internal/server/today_test.go b/internal/server/today_test.go index 62b35e0..c9b4c21 100644 --- a/internal/server/today_test.go +++ b/internal/server/today_test.go @@ -151,3 +151,34 @@ func TestWithIncidents(t *testing.T) { t.Errorf("others: %+v %+v", got[1].Incident, got[2].Incident) } } + +func TestFleetGrid(t *testing.T) { + for _, c := range [][3]string{{"phx1-app05", "phx1", "app"}, {"web-02", "", "web"}, {"host3", "", "host"}, {"db1.example.com", "", "db"}, {"phx1-07", "phx1", "other"}, {"win-dc01", "", "win"}, {"lb-edge-01", "", "lb"}} { + if got := hostRole(c[0], c[1]); got != c[2] { + t.Errorf("hostRole(%s, %s) = %s, want %s", c[0], c[1], got, c[2]) + } + } + hosts := []HostView{ + {Name: "phx1-app02", Status: "good"}, {Name: "phx1-app01", Status: "warning", Word: "disk 91%"}, + {Name: "phx1-db01", Status: "good"}, {Name: "lon1-app01", Status: "good"}, + {Name: "bench", Status: "good", Silent: true}, {Name: "phx1-stor01", Status: "good"}, + } + siteOf := map[string]string{"phx1-app01": "s1", "phx1-app02": "s1", "phx1-db01": "s1", "lon1-app01": "s2"} + names := map[string]string{"s1": "phx1", "s2": "lon1"} + got := fleetGrid(hosts, siteOf, names) + if len(got) != 3 || got[0].Name != "phx1" || got[1].Name != "lon1" || got[2].Name != "Elsewhere" { + t.Fatalf("sites = %+v", got) + } + if got[0].Hosts != 4 { + t.Errorf("phx1-stor01 should join phx1 by its name: %+v", got[0]) + } + if r := got[0].Roles; len(r) != 3 || r[0].Role != "app" || r[0].Hosts[0].Name != "phx1-app01" || r[1].Role != "db" || r[2].Role != "stor" { + t.Errorf("phx1 roles = %+v", r) + } + if tr := got[0].Trouble; len(tr) != 1 || tr[0].Name != "phx1-app01" { + t.Errorf("phx1 trouble = %+v", tr) + } + if tr := got[2].Trouble; len(tr) != 1 || tr[0].Status != "critical" { + t.Errorf("a silent host is trouble: %+v", tr) + } +} diff --git a/web/src/lib/FleetGrid.svelte b/web/src/lib/FleetGrid.svelte new file mode 100644 index 0000000..f8d526d --- /dev/null +++ b/web/src/lib/FleetGrid.svelte @@ -0,0 +1,144 @@ + + +{#if error}

{error}

{/if} + +{#if watch && (watch.filling.length || watch.busier.length || watch.restarted_n)} +
+

Worth watching

+
+ {#if watch.filling.length} +
+

Filling up

+
    {#each watch.filling as d (d.host + d.mount)}
  • {d.host}{Math.round(d.pct)}%{d.mount} · full {days(d.full_days)}
  • {/each}
+
+ {/if} + {#if watch.busier.length} +
+

Busier than usual

+
    {#each watch.busier as b (b.host + b.what)}
  • {b.host}{Math.round(b.now)}% {b.what === 'cpu' ? 'CPU' : 'memory'}usually {Math.round(b.usual)}% at this hour
  • {/each}
+
+ {/if} + {#if watch.restarted_n} +
+

Restarted in the last day · {watch.restarted_n}

+
    {#each watch.restarted as r (r.host)}
  • {r.host}{duration(r.up_s)} ago
  • {/each}
+ {#if watch.restarted_n > watch.restarted.length}

and {watch.restarted_n - watch.restarted.length} more

{/if} +
+ {/if} +
+
+{/if} + +{#if sites === null} +

Loading…

+{:else} + +
+ {#each sites as s (s.id)} +
+
+

{s.name}

+ {s.hosts} {s.hosts === 1 ? 'host' : 'hosts'} · {s.trouble.length ? `${s.trouble.length} need a look` : 'all fine'} +
+ {#each s.roles as r (r.role)} +
+ {roleName(r.role)} · {r.hosts.length} + + {#each r.hosts as h (h.name)}{/each} + +
+ {/each} + {#if s.trouble.length} +
    + {#each s.trouble.slice(0, 8) as h (h.name)}
  • {h.name} {h.word}
  • {/each} + {#if s.trouble.length > 8}
  • and {s.trouble.length - 8} more
  • {/if} +
+ {/if} +
+ {/each} +
+{/if} + + diff --git a/web/src/lib/Shell.svelte b/web/src/lib/Shell.svelte index 6cfbcbb..7891e9b 100644 --- a/web/src/lib/Shell.svelte +++ b/web/src/lib/Shell.svelte @@ -70,29 +70,36 @@ store('folded', JSON.stringify(folded)); } type Item = { href: string; icon: IconName; label: string; show?: boolean; exact?: boolean; meta?: number; sev?: string; tip?: string }; - const overview = $derived(([ - { href: '/', icon: 'dashboard', label: 'Dashboard', exact: true, show: true }, - // One entry for every host: a big fleet's partial list told you little. - { href: '/hosts', icon: 'hosts', label: 'Hosts', show: true, meta: hostLook, sev: hostCritical ? 'critical' : 'warning', tip: hostLook ? `${hostLook} need a look` : '' } + // Shaped by what people come to do (#72): today's briefing and what to + // act on first, then the fleet, the maps, and what Cairn OBS is + // connected to. + const hasServices = $derived((live.overview?.services?.length ?? 0) > 0); + const today = $derived(([ + { href: '/', icon: 'dashboard', label: 'Today', exact: true, show: true }, + { href: '/services', icon: 'services', label: 'Services', show: hasServices }, + { href: '/alerts', icon: 'bell', label: 'Alerts', show: true, meta: unacked, sev: 'critical', tip: unacked ? `${unacked} not acknowledged` : '' }, + { href: '/reports', icon: 'report', label: 'Reports', show: f?.reports } ] as Item[]).filter((i) => i.show)); - const infra = $derived(([ - { href: '/map/network', icon: 'network', label: 'Network map', show: f?.maps }, - { href: '/map/services', icon: 'services', label: 'Service map', show: f?.maps }, - { href: '/mail', icon: 'mail', label: 'Mail', show: f?.mail }, - { href: '/data', icon: 'database', label: 'Data layer', show: f?.data }, + const fleet = $derived(([ + // One entry for every host: a big fleet's partial list told you little. + { href: '/hosts', icon: 'hosts', label: 'Hosts', show: true, meta: hostLook, sev: hostCritical ? 'critical' : 'warning', tip: hostLook ? `${hostLook} need a look` : '' }, { href: '/clusters', icon: 'cluster', label: 'Clusters', show: f?.workloads, meta: clusterProblems, sev: clusterSeverity, tip: clusterProblems ? `${clusterProblems} need a look` : '' }, { href: '/workloads', icon: 'grid', label: 'Workloads', show: f?.workloads }, - { href: '/containers', icon: 'box', label: 'Containers', show: f?.containers || problems > 0, meta: problems, sev: containerSeverity, tip: problems ? `${problems} need a look` : '' }, + { href: '/containers', icon: 'box', label: 'Containers', show: f?.containers || problems > 0, meta: problems, sev: containerSeverity, tip: problems ? `${problems} need a look` : '' } + ] as Item[]).filter((i) => i.show)); + const maps = $derived(([ + { href: '/map/network', icon: 'network', label: 'Network map', show: f?.maps }, + { href: '/map/services', icon: 'services', label: 'Service map', show: f?.maps } + ] as Item[]).filter((i) => i.show)); + const connected = $derived(([ + { href: '/checks', icon: 'check', label: 'Checks', show: f?.checks || checksDown > 0, meta: checksDown, sev: live.overview?.checks?.severity ?? 'warning', tip: checksDown ? `${checksDown} down` : '' }, + { href: '/mail', icon: 'mail', label: 'Mail', show: f?.mail }, + { href: '/data', icon: 'database', label: 'Data layer', show: f?.data }, { href: '/certificates', icon: 'lock', label: 'Certificates', show: f?.certificates }, { href: '/backups', icon: 'archive', label: 'Backups', show: f?.backups }, { href: '/cloudflare', icon: 'cloud', label: 'Cloudflare', show: f?.cloudflare }, { href: '/akamai', icon: 'globe', label: 'Akamai', show: f?.akamai } ] as Item[]).filter((i) => i.show)); - const watch = $derived(([ - { href: '/checks', icon: 'check', label: 'Checks', show: f?.checks || checksDown > 0, meta: checksDown, sev: live.overview?.checks?.severity ?? 'warning', tip: checksDown ? `${checksDown} down` : '' }, - { href: '/alerts', icon: 'bell', label: 'Alerts', show: true, meta: unacked, sev: 'critical', tip: unacked ? `${unacked} not acknowledged` : '' }, - { href: '/reports', icon: 'report', label: 'Reports', show: f?.reports } - ] as Item[]).filter((i) => i.show)); const setup: Item[] = [ { href: '/configure', icon: 'settings', label: 'Overview', exact: true }, { href: '/configure/hosts', icon: 'hosts', label: 'Hosts' }, @@ -215,9 +222,10 @@ {@render group('Configure', setup)} {@render group('Access', access)} {:else} - {@render group('Overview', overview)} - {#if infra.length}{@render group('Infrastructure', infra)}{/if} - {@render group('Watch', watch)} + {@render group('Today', today)} + {@render group('Fleet', fleet)} + {#if maps.length}{@render group('Maps', maps)}{/if} + {#if connected.length}{@render group('Connected to', connected)}{/if} {/if}
diff --git a/web/src/lib/Strip.svelte b/web/src/lib/Strip.svelte new file mode 100644 index 0000000..d8dacbf --- /dev/null +++ b/web/src/lib/Strip.svelte @@ -0,0 +1,18 @@ + + +{#each cells as c, i (i)}{/each} + + diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts index b4031b0..e6d9bc7 100644 --- a/web/src/lib/api.ts +++ b/web/src/lib/api.ts @@ -40,7 +40,25 @@ export interface VMLink { source: string; namespace?: string; name: string; node /** The libvirt VMs a host runs. */ export interface HostVMCount { total: number; running: number; error?: string; href: string } export interface UnitView { name: string; load: string; active: string; sub: string; restarts: number; since?: string; host: string; severity: Severity; word: string } -export interface Attention { severity: Severity; title: string; detail: string; href: string; host: string } +export interface Attention { + severity: Severity; title: string; detail: string; href: string; host: string; + key?: string; affected?: string; + /** The open incident it is, once there is one: the dashboard's "I'm on it" acknowledges it. */ + incident?: { id: string; opened: string; fired: string | null; ack: { by: string; at: string } | null }; +} +/** What happened since this person last looked (internal/server/today.go). */ +export interface Today { since: string; last_visit: boolean; events: TodayEvent[]; opened: number; resolved: number; fixed_itself: number; told: number } +export interface TodayEvent { id: string; severity: Severity; title: string; host?: string; href?: string; at: string; opened: string; resolved?: string; ack_by?: string; told: boolean } +/** A service's last 24 hours as 48 half-hour cells (the worst status in each, '' unknown), and its uptime (-1 unknown). */ +export interface ServiceHistory { cells: string[]; pct_24h: number; pct_30d: number } +export interface ServiceBrief { id: string; name: string; tier: string; status: Severity; word: string; history: ServiceHistory } +/** The few hosts heading somewhere, in place of gauges. */ +export interface Watch { + filling: { host: string; mount: string; pct: number; full_days: number }[]; + busier: { host: string; what: 'cpu' | 'memory'; now: number; usual: number }[]; + restarted: { host: string; up_s: number }[]; + restarted_n: number; +} /** Every host in a few numbers (internal/server/lists.go). */ export interface Fleet { hosts: number; @@ -58,7 +76,7 @@ export interface HostRow { os?: string; uptime_s: number; cpu_pct: number; mem_pct: number; fullest?: Disk; containers: ContainerSummary; } /** hosts is every host in a small fleet, else the ones most in need; fleet counts them all. */ -export interface Overview { now: string; version: string; hosts: Host[]; fleet: Fleet; attention: Attention[]; containers: ContainerSummary; alerts: { firing: number; unacknowledged: number }; checks?: { down: number; severity: string }; features?: Features; clusters?: Cluster[] } +export interface Overview { now: string; version: string; hosts: Host[]; fleet: Fleet; attention: Attention[]; containers: ContainerSummary; alerts: { firing: number; unacknowledged: number }; checks?: { down: number; severity: string }; features?: Features; clusters?: Cluster[]; today?: Today; services?: ServiceBrief[]; watch?: Watch } /** A cluster agent's cluster: GET /api/v1/clusters, and the overview. */ export interface Cluster { name: string; status: Severity; word: string; heard: string | null; listed: string | null; agent?: string; version?: string; diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index bb261f9..d407ca8 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -1,13 +1,14 @@ -Cairn OBS · Dashboard +Cairn OBS · Today -
-
-
-
-
- -
-

{hello}{firstName ? ', ' + firstName : ''}

-

Here's how your systems are doing.

-
+
+
+
+

{hello}{firstName ? ', ' + firstName : ''} · {dayFmt.format(now)}

+ {#if o} +

{headline} {#if needs.length}{customers}{/if}

+ {#if subline || (!needs.length && customers)}

{!needs.length && customers ? customers + ' ' : ''}{subline}

{/if} + {:else} +

Looking…

+ {/if}
-
- {reporting}/{total} hosts reporting -
{hms(now)}{zone(now)} · {utc(now)}
-
-
-
+

+ {live.error ? live.error : checked < 0 ? 'Connecting' : checked < 3 ? 'Live · checked just now' : `Live · checked ${checked} s ago`} +

+ -{#if o} -
-
- -

{o.attention.length ? `Needs attention · ${o.attention.length}` : 'All clear'}

- -
- {#if o.attention.length} -
- {#each o.attention.slice(0, 6) as a} - -
{a.title}
{#if a.detail}

{a.detail}

{/if}
- -
+ {#if o} + {#if error}{/if} + + {#if needs.length || taken.length} +
+
+

Needs you{#if needs.length} · {needs.length}{/if}

+

Worst first. {needs.length ? 'Nobody has picked these up yet.' : 'Everything urgent has someone on it.'}

+
+ {#each needs as a (a.key || a.title)} +
+
+ + + {a.host ? a.host + ' · ' : ''}{a.incident ? 'started ' + ago(a.incident.opened, now) : 'just now'}{a.incident?.fired ? ' · people were told' : ''} + +
+

{a.title}

+ {#if a.detail}

{a.detail}

{/if} + {#if a.affected}

What it touches {a.affected}

{/if} +
+ {#if a.incident && canAck} + + {:else if a.incident && live.session?.demo} + + {/if} + Open + {#if a.incident}{a.incident.id}{/if} +
+
{/each} -
- {:else} -

Every host is reporting, no disk is past 80%, and every container is where it should be.

+ {#if taken.length} +
+

Being handled · {taken.length}

+
    + {#each taken as a (a.key || a.title)} +
  • + + {a.title} + {a.incident?.ack?.by} is on it · {ago(a.incident?.ack?.at ?? now, now)} +
  • + {/each} +
+
+ {/if} +
{/if} - - -
- - - = 90 ? 'critical' : (fullest?.pct ?? 0) >= 80 ? 'warning' : 'data'} bands={[{ from: 0.8, to: 0.9, tone: 'warning' }, { from: 0.9, to: 1, tone: 'critical' }]} /> - -
-
+ {#if later.length} +
+
+

Can wait · {later.length}

+

Worth a look today. None of these is hurting anything yet.

+
+
    + {#each later.slice(0, 6) as a (a.key || a.title)} +
  • + + {a.title}{#if a.detail}{a.detail}{/if} + {#if a.incident}{duration((now - new Date(a.incident.opened).getTime()) / 1000)}{/if} + Open +
  • + {/each} +
+ {#if later.length > 6}And {later.length - 6} more on the Alerts page{/if} +
+ {/if} -
- hosts.length ? `the ${hosts.length} most in need, of ${total}` : 'cpu · last hour'} href={total > hosts.length ? '/hosts' : undefined} hrefLabel="All hosts"> - - -
+ {#if !needs.length && !later.length && !taken.length} +
+ +
+

Nothing needs you right now

+

Cairn OBS tells the alert channels if that changes.{watch?.filling.length ? ` Next to look at: ${watch.filling[0].host}'s ${watch.filling[0].mount}, which fills ${days(watch.filling[0].full_days)}.` : ''}

+
+ This week’s report +
+ {/if} - {#if o.clusters?.length} -
- - - {/if} + + {/if} - {#if c} -
- -
-
{c.running}running fine
-
0}>{c.problems}need a look
-
{c.stopped}stopped on purpose
-
{c.ci}CI jobs now
+ {#if today} +
+
+

Since you last looked

+

{today.last_visit ? `You were last here ${ago(today.since, now)}, at ${hm(today.since)}` : 'The last 12 hours'}

- -
+ {#if today.events.length} +
    + {#each today.events as e (e.id)} + {@const [word, tone] = outcome(e)} +
  1. + + + {#if e.href}{e.title}{:else}{e.title}{/if} + {word} +
  2. + {/each} +
+

+ {today.opened} opened, {today.resolved} closed{today.fixed_itself ? ` (${today.fixed_itself} on their own)` : ''}. {today.told ? `${today.told} ${today.told === 1 ? 'alert' : 'alerts'} went out to people.` : 'Nobody was alerted.'} + {#if today.opened + today.resolved > today.events.length}Everything on the Alerts page{/if} +

+ {:else} +

Nothing opened or closed since then.

+ {/if} + + {/if} + +
+
+

The fleet

+

All hosts{#if clusters.length} · Clusters{/if}

+
+ + {#if watch && (watch.filling.length || watch.busier.length || watch.restarted_n)} +
+

Worth watching

+
    + {#each watch.filling as d (d.host + d.mount)} +
  • {d.host} {d.mount} is {Math.round(d.pct)}% full and fills {days(d.full_days)}
  • + {/each} + {#each watch.busier as b (b.host + b.what)} +
  • {b.host} {b.what === 'cpu' ? 'CPU' : 'memory'} at {Math.round(b.now)}%, usually {Math.round(b.usual)}% at this hour
  • + {/each} + {#if watch.restarted_n} +
  • + {watch.restarted_n === 1 ? 'Restarted' : `${watch.restarted_n} hosts restarted`} in the last day: + {#each watch.restarted as r, i (r.host)}{i ? ', ' : ' '}{r.host} {duration(r.up_s)} ago{/each}{watch.restarted_n > watch.restarted.length ? ` and ${watch.restarted_n - watch.restarted.length} more` : ''} +
  • + {/if} +
+
+ {/if} +
{/if} -{:else} -

Loading…

-{/if} +
diff --git a/web/src/routes/hosts/+page.svelte b/web/src/routes/hosts/+page.svelte index 5496d25..230a870 100644 --- a/web/src/routes/hosts/+page.svelte +++ b/web/src/routes/hosts/+page.svelte @@ -2,12 +2,22 @@ import Icon from '$lib/Icon.svelte'; import Status from '$lib/Status.svelte'; import Pager from '$lib/Pager.svelte'; + import FleetGrid from '$lib/FleetGrid.svelte'; + import { goto } from '$app/navigation'; + import { page } from '$app/state'; import { get, SignedOut, type HostRow } from '$lib/api'; import { live } from '$lib/live.svelte'; import { ago, pct } from '$lib/format'; - // The hosts list, filtered and paged by obs-beacond: a fleet can be - // thousands of hosts. + // Squares by site and role first (#72); the list, filtered and paged by + // obs-beacond, a click away: a fleet can be thousands of hosts. + const view = $derived(page.url.searchParams.get('view') === 'list' ? 'list' : 'grid'); + function setView(v: string) { + const u = new URL(page.url); + if (v === 'list') u.searchParams.set('view', 'list'); + else u.searchParams.delete('view'); + void goto(u, { replaceState: true, noScroll: true, keepFocus: true }); + } const limit = 100; let rows = $state([]); let total = $state(0); @@ -41,6 +51,7 @@ } } $effect(() => { + if (view !== 'list') return; const args = [q, status, offset] as const; void load(...args); const t = setInterval(() => void load(...args), 10_000); @@ -62,10 +73,20 @@
-

Hosts

Every host with an agent, the ones that need a look first. Adding and removing hosts is under Configure.

- {#if live.seesAll}{/if} +

Hosts

Every host with an agent, grouped by site and role so the odd one out stands out. Adding and removing hosts is under Configure.

+
+ + + + + {#if live.seesAll} Configure{/if} +
+{#if view === 'grid'} + +{:else} + {#if error}

{error}

{/if}
@@ -97,8 +118,10 @@
+{/if}

Refreshes every 10 seconds.

diff --git a/web/src/routes/services/+page.svelte b/web/src/routes/services/+page.svelte new file mode 100644 index 0000000..83dc6db --- /dev/null +++ b/web/src/routes/services/+page.svelte @@ -0,0 +1,227 @@ + + +Cairn OBS · Services + +
+
+
+
+

{heading || 'Services'}

+

Grouped by who depends on them. Pick one to see what it’s made of and what breaks if it goes.

+
+ {#if all.length} +
+ + + +
+ {/if} +
+ + {#if error}{/if} + + {#if services === null} +

Loading…

+ {:else if !topology || !all.length} +

No services yet. Services come from the service map: declare them in topology.yaml, or correct what the map found (docs/maps.md).

+ {:else} +
+
+ {#each tiers as t (t.id)} +
+

{t.name}{#if t.blurb} · {t.blurb}{/if}

+
+ {#each t.rows as s (s.id)} + + {/each} +
+
+ {/each} +
+ + {#if sel} + + {/if} +
+ {/if} +
+ + -- 2.54.0