rigscope 0.1.8 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +3 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/administration/page_client-reference-manifest.js +1 -1
- package/.next/server/app/administration.html +1 -1
- package/.next/server/app/administration.rsc +3 -3
- package/.next/server/app/administration.segments/_full.segment.rsc +3 -3
- package/.next/server/app/administration.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/administration.segments/administration/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/alerts/page_client-reference-manifest.js +1 -1
- package/.next/server/app/alerts.html +1 -1
- package/.next/server/app/alerts.rsc +3 -3
- package/.next/server/app/alerts.segments/_full.segment.rsc +3 -3
- package/.next/server/app/alerts.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/alerts.segments/alerts/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/connections/page.js +1 -1
- package/.next/server/app/connections/page_client-reference-manifest.js +1 -1
- package/.next/server/app/connections.html +1 -1
- package/.next/server/app/connections.rsc +4 -4
- package/.next/server/app/connections.segments/_full.segment.rsc +4 -4
- package/.next/server/app/connections.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/connections.segments/connections/__PAGE__.segment.rsc +4 -4
- package/.next/server/app/history/page.js +2 -2
- package/.next/server/app/history/page_client-reference-manifest.js +1 -1
- package/.next/server/app/history.html +1 -1
- package/.next/server/app/history.rsc +6 -6
- package/.next/server/app/history.segments/_full.segment.rsc +6 -6
- package/.next/server/app/history.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/history.segments/history/__PAGE__.segment.rsc +6 -6
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +3 -3
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +3 -3
- package/.next/server/app/login.segments/_full.segment.rsc +3 -3
- package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/machines/[machineId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/processes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/processes.html +1 -1
- package/.next/server/app/processes.rsc +3 -3
- package/.next/server/app/processes.segments/_full.segment.rsc +3 -3
- package/.next/server/app/processes.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/processes.segments/processes/__PAGE__.segment.rsc +3 -3
- package/.next/server/app-paths-manifest.json +1 -1
- package/.next/server/chunks/161.js +1 -1
- package/.next/server/chunks/168.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/408-351fe4a1e9a2d556.js +1 -0
- package/.next/static/chunks/939-92930fde48061e20.js +1 -0
- package/.next/static/chunks/app/connections/page-7d18b901f2338f20.js +1 -0
- package/.next/static/chunks/app/history/page-adc25194b30c689d.js +3 -0
- package/.next/static/css/{f5d3162842dcac31.css → 2abef6d49c1c2970.css} +1 -1
- package/ARCHITECTURE.md +43 -15
- package/CHANGELOG.md +62 -0
- package/README.md +10 -3
- package/dist/cli.cjs +868 -511
- package/dist/collector.cjs +603 -120
- package/dist/hub.cjs +3429 -1451
- package/dist/ops.cjs +1178 -888
- package/dist/system.cjs +1322 -363
- package/docs/configuration.md +34 -1
- package/docs/installation.md +12 -6
- package/docs/monitoring.md +60 -17
- package/docs/operations.md +78 -22
- package/docs/system-installation.md +11 -4
- package/docs/telemetry-storage.md +258 -0
- package/package.json +3 -1
- package/packaging/collector.env.example +6 -0
- package/packaging/system/rigscope-collector.service.example +3 -0
- package/.next/static/chunks/408-9fdba9e4e956ef08.js +0 -1
- package/.next/static/chunks/939-514e554087419c71.js +0 -1
- package/.next/static/chunks/app/connections/page-75abd16fc495fcbd.js +0 -1
- package/.next/static/chunks/app/history/page-a25ba8fab7bd7cb9.js +0 -3
- /package/.next/static/{ip43TIgmaByEBn2GFtvfO → JbaLjudQSxrMUD_VHPrnD}/_buildManifest.js +0 -0
- /package/.next/static/{ip43TIgmaByEBn2GFtvfO → JbaLjudQSxrMUD_VHPrnD}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Telemetry storage, history and recording
|
|
2
|
+
|
|
3
|
+
Rigscope has two explicit telemetry-history modes. The default is RAM-only.
|
|
4
|
+
Persistent history is opt-in and writes compact summaries, not one row per
|
|
5
|
+
collector reading.
|
|
6
|
+
|
|
7
|
+
> "No persistent telemetry history" is accurate for memory mode. It is not a
|
|
8
|
+
> promise of zero disk writes: hub logs, SQLite control state, alert state,
|
|
9
|
+
> recordings and operating-system swap may still write.
|
|
10
|
+
|
|
11
|
+
Configuration and non-history state always remain in SQLite: users, password
|
|
12
|
+
hashes, sessions' audit records, collector enrollment and credentials, grants,
|
|
13
|
+
alert rules/incidents/jobs/webhook settings, machine display names/tags, and
|
|
14
|
+
inventory. Only telemetry history is ephemeral by default.
|
|
15
|
+
|
|
16
|
+
## Modes
|
|
17
|
+
|
|
18
|
+
| | `HUB_TELEMETRY_MODE=memory` (default) | `HUB_TELEMETRY_MODE=persistent` |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| Live readings | Updated immediately in RAM | Updated immediately in RAM |
|
|
21
|
+
| Recent charts | Bounded typed-array RAM rings | Compact worst-case summaries in SQLite |
|
|
22
|
+
| Ack meaning | Accepted into hub RAM; intentional loss on restart | Committed transaction; durable delivery |
|
|
23
|
+
| Restart | History and latest snapshots disappear | Summaries and latest snapshots restore |
|
|
24
|
+
| Routine telemetry writes | None | One transaction roughly every 5 seconds |
|
|
25
|
+
| Deduplication | Per-run in-RAM interval set | `sample_receipts` with an independent 7-day TTL |
|
|
26
|
+
|
|
27
|
+
The hub sends `delivery: "memory"` or `"durable"` in `welcome`: it describes the
|
|
28
|
+
hub's choice, not the collector's. Collectors retry and hold in-flight batches
|
|
29
|
+
the same way in both cases, so delayed acknowledgements do not move sustained
|
|
30
|
+
writes from the hub to the collectors.
|
|
31
|
+
|
|
32
|
+
## Collector delivery queue
|
|
33
|
+
|
|
34
|
+
Unacknowledged samples wait in a bounded queue per destination. Its retention is
|
|
35
|
+
independent of the hub's history mode.
|
|
36
|
+
|
|
37
|
+
| | `COLLECTOR_QUEUE_MODE=memory` (default) | `COLLECTOR_QUEUE_MODE=durable` |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| Pending samples | RAM | SQLite file per destination |
|
|
40
|
+
| Routine collector disk writes | None | One insert, one in-flight update and one delete per sample |
|
|
41
|
+
| Collector restart | Pending samples are lost | Everything unacknowledged is replayed |
|
|
42
|
+
| Reported to the hub | `delivery.queueMode: "memory"` | `delivery.queueMode: "durable"` |
|
|
43
|
+
|
|
44
|
+
Both modes share the same bounds (10 minutes and 64 MiB per destination, 256 MiB
|
|
45
|
+
aggregate), the same live-slot priority, and the same coalesced `gap` records
|
|
46
|
+
that tell the hub "samples were captured here and dropped" rather than "no
|
|
47
|
+
samples were captured". Choose `durable` when a collector restart losing a few
|
|
48
|
+
minutes of samples matters more than a database write per sample; `rigscope`
|
|
49
|
+
reports `queueMode` under a connection's delivery facts so the difference is
|
|
50
|
+
visible without guessing the configuration.
|
|
51
|
+
|
|
52
|
+
### Memory history defaults
|
|
53
|
+
|
|
54
|
+
The RAM budget is `HUB_HISTORY_MEMORY_BYTES` (default **128 MiB**) for the whole
|
|
55
|
+
hub, not per machine. Within it, each series keeps:
|
|
56
|
+
|
|
57
|
+
| Tier | Default retention | Purpose |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| 1 second | 2 minutes | Short incident lead-up |
|
|
60
|
+
| 10 seconds | 1 hour | Recent troubleshooting |
|
|
61
|
+
| 1 minute | 24 hours | Medium-term history |
|
|
62
|
+
| 1 hour | 7 days | Longer-term trends |
|
|
63
|
+
|
|
64
|
+
Per-core CPU uses shorter detail: 10-second buckets for 10 minutes, 1-minute for
|
|
65
|
+
6 hours and 1-hour for 2 days. Other metrics use the table above.
|
|
66
|
+
|
|
67
|
+
Each reading updates the current bucket of each applicable tier. Buckets keep
|
|
68
|
+
`min`, `max`, `sum`, non-null `count` and an explicit unavailable `nullCount`, so
|
|
69
|
+
a one-second spike is still represented after it is aggregated into a minute or
|
|
70
|
+
hour. This is aggregation, not "keep every tenth sample". Empty buckets are
|
|
71
|
+
omitted; an all-unavailable bucket renders as unknown, never zero.
|
|
72
|
+
|
|
73
|
+
All current metrics are gauges or already-derived rates: the collector computes
|
|
74
|
+
network/disk bytes per second from monotonic counters before sending, so the hub
|
|
75
|
+
never averages a cumulative counter and does not need first/last values for rate
|
|
76
|
+
reconstruction. If a cumulative counter metric is added later, it needs an
|
|
77
|
+
explicit delta/first-last aggregation policy rather than this gauge path.
|
|
78
|
+
|
|
79
|
+
When a new series would exceed the global budget, the least-recently-seen series
|
|
80
|
+
lose their finest tiers first, then whole series are evicted. New cardinality
|
|
81
|
+
that still does not fit is rejected and reported as pressure. This makes the
|
|
82
|
+
budget finite even for a machine that adds hundreds of disks or cores.
|
|
83
|
+
|
|
84
|
+
### Persistent summary history
|
|
85
|
+
|
|
86
|
+
Persistent mode buffers ingestion and commits all series for roughly five
|
|
87
|
+
seconds in one transaction. It writes `points_10s` plus folded one-minute and
|
|
88
|
+
one-hour rollups. It does **not** write `points_raw` unless an operator
|
|
89
|
+
explicitly constructs the store in raw mode (used by tests and measurement).
|
|
90
|
+
|
|
91
|
+
- Live publication is decoupled from the commit, so the dashboard is not one
|
|
92
|
+
flush behind.
|
|
93
|
+
- A sample is acknowledged only after `COMMIT` returns with `synchronous=FULL`.
|
|
94
|
+
- Retries are deduplicated by `(collectorId, runId, sequence)` before any
|
|
95
|
+
point/rollup side effect. Committed records cannot be counted twice.
|
|
96
|
+
- After a crash, uncommitted buffered samples are replayed by the collector
|
|
97
|
+
because they were never acknowledged. Committed samples have receipts.
|
|
98
|
+
- A graceful shutdown flushes pending summaries before closing within the hub's
|
|
99
|
+
bounded shutdown window.
|
|
100
|
+
- Late/replayed samples extend the correct immutable summary bucket; the
|
|
101
|
+
one-minute and one-hour rows receive only the new delta, never a recomputed
|
|
102
|
+
total. Out-of-order samples inside the retained RAM ring update the matching
|
|
103
|
+
completed bucket; samples older than the retained window are counted as late
|
|
104
|
+
and dropped rather than corrupting a newer bucket.
|
|
105
|
+
- Buckets use absolute minute/hour boundaries. A query includes the current
|
|
106
|
+
partial window once, and a later query recomputes only that bucket from the
|
|
107
|
+
same summaries, so completed data is not double-counted.
|
|
108
|
+
- Flush failures resolve pending batches as retry/busy, so collectors keep the
|
|
109
|
+
data and back off. The queue is bounded (`HUB` storage queue and the
|
|
110
|
+
collector's in-flight window) and does not grow without limit.
|
|
111
|
+
- The collector's local in-flight window and the hub's welcome window are both
|
|
112
|
+
64 batches, the wire maximum. The hub's persistent flush interval is capped
|
|
113
|
+
at five seconds, which fits that window at the fastest supported 100 ms
|
|
114
|
+
cadence (6.4 s of coverage) and leaves 1.4 s for COMMIT/ack latency; it is
|
|
115
|
+
also far below the collector's 30-second per-batch ack timeout. The
|
|
116
|
+
collector reserves enough slots for a full flush window of live samples,
|
|
117
|
+
plus two samples of headroom, and drains a waiting live
|
|
118
|
+
record as soon as an acknowledgement frees capacity. Its delivery queue keeps
|
|
119
|
+
the existing 10-minute/64 MiB per-destination bounds in either mode, so
|
|
120
|
+
delayed acks do not turn into unbounded queueing or silent data movement.
|
|
121
|
+
|
|
122
|
+
Dedup receipts default to **7 days** and are independent of chart retention.
|
|
123
|
+
Shortening raw/10-second history can no longer let a replayed sample recreate
|
|
124
|
+
expired chart data.
|
|
125
|
+
|
|
126
|
+
### Which readers exist
|
|
127
|
+
|
|
128
|
+
Charts, exports and recordings all use the same bounded history query interface,
|
|
129
|
+
so memory and persistent modes do not have separate chart code. Query work is
|
|
130
|
+
bounded by series count, scanned rows, elapsed time and output points. The
|
|
131
|
+
finest tier whose retention covers the requested range is selected; an empty
|
|
132
|
+
finer tier falls through to the next one (for example after upgrading an
|
|
133
|
+
existing database).
|
|
134
|
+
|
|
135
|
+
## Recording
|
|
136
|
+
|
|
137
|
+
A recording is an explicit, bounded capture and is separate from chart history.
|
|
138
|
+
|
|
139
|
+
- Start/stop from **History → Recording**.
|
|
140
|
+
- Choose the current machine, selected metrics, resolution (1s, 10s, 1m, 5m or
|
|
141
|
+
1h), duration, and whether to include recent RAM history (the lead-up).
|
|
142
|
+
- The hub writes private JSON-lines data under `HUB_RECORDINGS_DIR`
|
|
143
|
+
(default `<hub database directory>/recordings`, mode 0700 files 0600).
|
|
144
|
+
- Recordings are bounded by `HUB_RECORDING_MAX_DURATION_MS` (default 1 hour) and
|
|
145
|
+
`HUB_RECORDING_MAX_BYTES` (default 64 MiB). A duration or size limit ends the
|
|
146
|
+
capture with an explicit reason.
|
|
147
|
+
- Metadata survives restart. A capture active during a restart is marked
|
|
148
|
+
interrupted and its partial file stays downloadable.
|
|
149
|
+
- Download/list/delete are authenticated and authorized to the creating account
|
|
150
|
+
(administrators can see all) and to the caller's current machine scope. The
|
|
151
|
+
browser names an opaque recording id; it can never name a filesystem path.
|
|
152
|
+
|
|
153
|
+
Recordings are not part of a database-only backup. If they matter, include the
|
|
154
|
+
recordings directory in the same private backup set as the hub database.
|
|
155
|
+
|
|
156
|
+
## The one-time machine-data transition
|
|
157
|
+
|
|
158
|
+
The first `rigscope upgrade` (or `rigscope system upgrade --apply`) after the
|
|
159
|
+
RAM-first release completes a one-time transition. It discards the previous
|
|
160
|
+
design's on-disk machine-derived data once, explicitly authorized for this
|
|
161
|
+
transition even for data an operator had opted into keeping:
|
|
162
|
+
|
|
163
|
+
- hub database: telemetry rows and their summaries, `sample_receipts`, `gaps`,
|
|
164
|
+
`machine_latest`, `series`, `inventory`, and the machine-derived alert
|
|
165
|
+
history (`alert_incidents`, `alert_machine_progress`,
|
|
166
|
+
`alert_observed_resources`);
|
|
167
|
+
- the collector's pre-RAM-first durable outbox tree.
|
|
168
|
+
|
|
169
|
+
It always preserves accounts and sessions, collector enrollment and grants,
|
|
170
|
+
settings, alert rules/jobs/webhook configuration, machine display names and
|
|
171
|
+
tags (`machine_meta`), and recordings.
|
|
172
|
+
|
|
173
|
+
The transition is recorded in a version-independent
|
|
174
|
+
`machine-data-transition.json` marker in the installation's state root, written
|
|
175
|
+
only after the activated release verified healthy. Every upgrade after that —
|
|
176
|
+
including upgrades to future versions — reads the marker and preserves durable
|
|
177
|
+
history and queues you opt back into, so `COLLECTOR_QUEUE_MODE=durable` and
|
|
178
|
+
durable hub history survive later upgrades intact. An installation created by
|
|
179
|
+
`install` (fresh or reset) is recorded as already transitioned.
|
|
180
|
+
|
|
181
|
+
Until the marker is written the transition is reversible: the queue tree is
|
|
182
|
+
renamed aside rather than deleted, and the upgrade's recorded pre-upgrade
|
|
183
|
+
database copy restores the cleared rows if activation fails — even when the
|
|
184
|
+
previous runtime could still read the schema, because the transition removed
|
|
185
|
+
rows, not schema. A cleanup that cannot finish never fails an otherwise healthy
|
|
186
|
+
upgrade: it is reported as a visible warning, the marker stays unwritten, and
|
|
187
|
+
the next upgrade retries it. The upgrade output states exactly how much was
|
|
188
|
+
discarded.
|
|
189
|
+
|
|
190
|
+
If you skipped the transition window (for example after re-registering an
|
|
191
|
+
installation with `rigscope install`) and want old rows gone, use the explicit
|
|
192
|
+
reset below.
|
|
193
|
+
|
|
194
|
+
## Reset old history
|
|
195
|
+
|
|
196
|
+
Switching an existing installation to memory mode does not read or rewrite old
|
|
197
|
+
telemetry rows, but they still occupy the database if the one-time transition
|
|
198
|
+
above has not run. To discard them explicitly while preserving users,
|
|
199
|
+
enrollment, settings and alert state:
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
rigscope stop
|
|
203
|
+
node dist/ops.cjs reset-telemetry \
|
|
204
|
+
--database /path/to/telemetry.sqlite \
|
|
205
|
+
--backup-dir /path/to/private-backups \
|
|
206
|
+
--confirm-stopped
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The command deletes only `points_raw`, `points_10s`, `points_1m`, `points_1h`,
|
|
210
|
+
`sample_receipts`, `gaps`, `machine_latest` and `series`. It refuses without
|
|
211
|
+
`--confirm-stopped` and while the hub lock exists. It never drops the database
|
|
212
|
+
file, users, collector registry, alert rules/incidents, metadata, inventory or
|
|
213
|
+
recordings. `--backup-dir` is optional but recommended; a consistent backup is
|
|
214
|
+
taken first when supplied.
|
|
215
|
+
|
|
216
|
+
## Benchmark
|
|
217
|
+
|
|
218
|
+
`npm run benchmark:telemetry -- --machines 2 --seconds 120` drives the real
|
|
219
|
+
stores with a realistic ~186-series-per-machine, one-second payload. It reports
|
|
220
|
+
process-attributed `/proc/self/io` write bytes (not database size), ingestion
|
|
221
|
+
enqueue/commit latency, history-query latency, RSS, row counts and database
|
|
222
|
+
size. `--json` prints machine-readable output; `--dir` selects a real filesystem
|
|
223
|
+
because tmpfs does not account storage writes in `/proc/self/io`.
|
|
224
|
+
|
|
225
|
+
One development-host result for **2 machines × 60 simulated seconds** (186
|
|
226
|
+
series each) was:
|
|
227
|
+
|
|
228
|
+
| Mode | Steady writes | Close/checkpoint | DB size | Commit p95 | History query |
|
|
229
|
+
| --- | --- | --- | --- | --- | --- |
|
|
230
|
+
| memory | **0.00 MiB** | 248 KiB | 0.3 MiB | 42 ms | 3.0 ms |
|
|
231
|
+
| persistent summaries | **0.98 MiB** | 264 KiB | 1.2 MiB | 35 ms | 5.9 ms |
|
|
232
|
+
| legacy raw, per-batch commit | 21.66 MiB | 692 KiB | 21.6 MiB | 15 ms | 6.8 ms |
|
|
233
|
+
|
|
234
|
+
That run measured persistent summaries at about **0.05×** the legacy write
|
|
235
|
+
volume (roughly 22× less) and memory mode at zero sustained ingestion writes.
|
|
236
|
+
|
|
237
|
+
A second run with **10 machines** (1,860 series) and the default 128 MiB RAM
|
|
238
|
+
budget reported `RAM 128/128 MiB pressure` while keeping all series readable
|
|
239
|
+
through the coarser tiers: memory wrote 0.00 MiB, persistent summaries 4.05 MiB,
|
|
240
|
+
and legacy raw 104.76 MiB of steady ingestion-phase writes. RSS peaks include
|
|
241
|
+
the Node baseline and temporary query/flush allocations, so they are higher than
|
|
242
|
+
the history-array budget.
|
|
243
|
+
|
|
244
|
+
These numbers are development-host measurements, not a promised multiplier or
|
|
245
|
+
capacity guarantee. Re-run on the deployment host and payload before choosing
|
|
246
|
+
retention or budgets.
|
|
247
|
+
|
|
248
|
+
If an earlier transition attempt was interrupted, its staged collector queue is
|
|
249
|
+
kept for manual recovery; a retry does not delete another attempt's copy. If a
|
|
250
|
+
failed replacement runtime creates a new queue, rollback preserves that queue
|
|
251
|
+
separately and restores the original pending queue. An existing malformed or
|
|
252
|
+
unreadable transition marker blocks the upgrade before clearing data; repair
|
|
253
|
+
the marker rather than deleting it, which would request another reset.
|
|
254
|
+
|
|
255
|
+
Failure to write the completion marker is reported without failing a healthy
|
|
256
|
+
upgrade and leaves the transition pending. Failure to remove a staged queue
|
|
257
|
+
after the marker was written is also reported, but later upgrades still preserve
|
|
258
|
+
new history because completion has already been recorded.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rigscope",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=26.0.0"
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"test": "node scripts/test.cjs",
|
|
23
23
|
"test:runtime": "npm run build:runtime && node scripts/test-runtime.cjs",
|
|
24
24
|
"test:dev": "npm run build:runtime && node scripts/test.cjs --suite development",
|
|
25
|
+
"benchmark:telemetry": "tsx scripts/telemetry-benchmark.ts",
|
|
25
26
|
"validate:https": "node scripts/validate-https.cjs",
|
|
26
27
|
"build:ui": "next build --webpack",
|
|
27
28
|
"rigscope": "node bin/rigscope.cjs",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"docs/system-installation.md",
|
|
71
72
|
"docs/configuration.md",
|
|
72
73
|
"docs/monitoring.md",
|
|
74
|
+
"docs/telemetry-storage.md",
|
|
73
75
|
"docs/operations.md",
|
|
74
76
|
"docs/bottlenecks.md",
|
|
75
77
|
"docs/exports.md",
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
# string, not a credential for any real deployment.
|
|
9
9
|
|
|
10
10
|
# COLLECTOR_MODE=real
|
|
11
|
+
# Unacknowledged samples wait in RAM by default, so routine delivery writes no
|
|
12
|
+
# queue to disk and a collector restart loses what was never acknowledged.
|
|
13
|
+
# Set this only when surviving a collector restart with unacknowledged samples
|
|
14
|
+
# is worth one database write per sample; it is bounded per destination to
|
|
15
|
+
# 10 minutes and 64 MiB.
|
|
16
|
+
# COLLECTOR_QUEUE_MODE=durable
|
|
11
17
|
# COLLECTOR_STATE_FILE=/home/operator/.local/state/rigscope/collector/collector.json
|
|
12
18
|
# COLLECTOR_INTERVAL_MS=1000
|
|
13
19
|
# COLLECTOR_HOSTNAME=rig-01
|
|
@@ -42,6 +42,9 @@ SupplementaryGroups=rigscope-rapl
|
|
|
42
42
|
Environment="COLLECTOR_MODE=real"
|
|
43
43
|
Environment="COLLECTOR_STATE_FILE=/var/lib/rigscope/collector/state.json"
|
|
44
44
|
Environment="COLLECTOR_HEALTH_FILE=/var/lib/rigscope/collector/health.json"
|
|
45
|
+
# Unacknowledged samples wait in RAM, so routine delivery writes no queue file.
|
|
46
|
+
# Uncomment to keep them in a per-hub SQLite outbox across collector restarts.
|
|
47
|
+
# Environment="COLLECTOR_QUEUE_MODE=durable"
|
|
45
48
|
ReadWritePaths="/var/lib/rigscope/collector"
|
|
46
49
|
ReadOnlyPaths="/opt/rigscope/current"
|
|
47
50
|
TimeoutStopSec=10s
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[408],{4150:(e,t,r)=>{r.d(t,{Au:()=>u,_C:()=>a,eg:()=>c});var n=r(5155),s=r(2115),i=r(6304),l=r(5078);let o=(0,s.createContext)(null);function a({children:e}){let[t,r]=(0,s.useState)(null),i=(0,s.useCallback)(e=>r(t=>t?.timeMs===e?.timeMs&&t?.source===e?.source?t:e),[]),l=(0,s.useMemo)(()=>({cursor:t,setCursor:i}),[t,i]);return(0,n.jsx)(o.Provider,{value:l,children:e})}function u({series:e,fromMs:t,toMs:r,stepMs:n,gaps:l}){let a=(0,s.useId)(),[c,d]=(0,s.useState)(null),m=(0,s.useContext)(o),f=m?m.cursor:c,p=m?m.setCursor:d,h=(0,s.useRef)(null),g=(0,s.useRef)(null),y=(0,s.useCallback)(()=>{null!==h.current&&cancelAnimationFrame(h.current),h.current=null,g.current=null},[]);(0,s.useEffect)(()=>y,[y]);let b=(0,s.useMemo)(()=>(0,i.X)(e).filter(e=>e.t<=r&&e.t+n/2>=t),[e,t,r,n]),x=f&&f.timeMs>=t-n/2&&f.timeMs<=r?f.timeMs:null,v=null!==x&&f?.source===a;(0,s.useEffect)(()=>{if(!v)return;let e=e=>{"Escape"===e.key&&(y(),p(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v,p,y]);let M=()=>{y(),f?.source===a&&p(null)};return{id:a,timeMs:x,active:v,inspect:e=>{let s=Math.max(t,Math.min(r,e)),o=(0,i.bO)(b,s,n,l);g.current={timeMs:o?.t??s,source:a},null===h.current&&(h.current=requestAnimationFrame(()=>{h.current=null,p(g.current),g.current=null}))},clear:M,onKeyDown:e=>{if(y(),"Escape"===e.key)e.preventDefault(),M();else if(["ArrowLeft","ArrowRight","Home","End"].includes(e.key)){e.preventDefault();let t=(0,i.o7)(b,x,e.key);null!==t&&p({timeMs:t,source:a})}},onFocus:()=>{y(),p({timeMs:b.at(-1)?.t??r,source:a})}}}function c({id:e,timeMs:t,fraction:r,unit:i,readings:o}){let[a]=(0,s.useState)(()=>r>.5?"left":"right");return(0,n.jsxs)("div",{id:e,role:"tooltip",className:`pointer-events-none absolute bottom-full mb-2 md:pointer-events-auto md:bottom-auto md:top-2 md:mb-0 z-10 max-h-56 w-56 max-w-[calc(100%-1rem)] overflow-y-auto rounded-md border border-border bg-card p-3 text-xs text-foreground ${"left"===a?"left-2":"right-2"}`,children:[(0,n.jsx)("p",{className:"tnum font-medium",children:(0,l.r6)(t)}),(0,n.jsx)("p",{className:"mb-2 text-muted-foreground",children:"Recorded bucket average"}),(0,n.jsx)("dl",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-4 gap-y-1.5",children:o.map(({key:e,label:r,color:s,point:o})=>(0,n.jsxs)("div",{className:"contents",children:[(0,n.jsxs)("dt",{className:"flex min-w-0 items-center gap-1.5",children:[(0,n.jsx)("span",{"aria-hidden":!0,className:"h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:s}}),(0,n.jsx)("span",{className:"break-words",children:r})]}),(0,n.jsxs)("dd",{className:"tnum text-right",children:[o?.avg==null?"No reading":(0,l.dd)(o.avg,i),o&&o.t!==t?(0,n.jsx)("span",{className:"block text-muted-foreground",children:(0,l.ei)(o.t)}):null]})]},e))})]})}},4567:(e,t,r)=>{r.d(t,{Cv:()=>s,H9:()=>n,Lf:()=>u,P$:()=>i,RL:()=>g,bP:()=>h,er:()=>m,oB:()=>a,ue:()=>p,yv:()=>d});let n=[{metric:"cpu.usage",label:"CPU usage",shortLabel:"CPU",unit:"percent",family:"cpu",colorSlot:0,description:"Total processor utilization"},{metric:"cpu.core",label:"Per-core CPU",shortLabel:"Per-core",unit:"percent",family:"cpu",colorSlot:0,description:"Logical-core utilization; heatmap for large selections"},{metric:"cpu.temperature",label:"CPU temperature",shortLabel:"Temperature",unit:"celsius",family:"cpu",colorSlot:3,description:"Identifiable CPU hwmon sensor temperature"},{metric:"cpu.power",label:"CPU package power",shortLabel:"Power",unit:"watts",family:"cpu",colorSlot:4,description:"Top-level RAPL package power draw"},{metric:"cpu.iowait",label:"CPU I/O wait",shortLabel:"I/O wait",unit:"percent",family:"cpu",colorSlot:2,description:"Processor time waiting on I/O"},{metric:"cpu.pressure",label:"CPU pressure",shortLabel:"Pressure",unit:"percent",family:"cpu",colorSlot:4,description:"Linux PSI CPU stall pressure (avg10)"},{metric:"memory.used",label:"Memory used",shortLabel:"Memory",unit:"bytes",family:"memory",colorSlot:1,description:"Physical memory in use"},{metric:"memory.usage",label:"Memory usage",shortLabel:"Memory %",unit:"percent",family:"memory",colorSlot:1,description:"Physical memory used as a share of total"},{metric:"memory.pressure.some",label:"Memory pressure (some)",shortLabel:"Pressure some",unit:"percent",family:"memory",colorSlot:2,description:"Linux PSI memory stall pressure, some tasks (avg10)"},{metric:"memory.pressure.full",label:"Memory pressure (full)",shortLabel:"Pressure full",unit:"percent",family:"memory",colorSlot:4,description:"Linux PSI memory stall pressure, all tasks (avg10)"},{metric:"swap.used",label:"Swap used",shortLabel:"Swap",unit:"bytes",family:"swap",colorSlot:2,description:"Swap space in use"},{metric:"gpu.utilization",label:"GPU utilization",shortLabel:"Utilization",unit:"percent",family:"gpus",colorSlot:0,description:"Per-card graphics processor utilization"},{metric:"gpu.memory.used",label:"GPU memory used",shortLabel:"VRAM",unit:"bytes",family:"gpus",colorSlot:1,description:"Per-card video memory in use"},{metric:"gpu.temperature",label:"GPU temperature",shortLabel:"Temperature",unit:"celsius",family:"gpus",colorSlot:3,description:"Per-card temperature"},{metric:"gpu.power",label:"GPU power",shortLabel:"Power",unit:"watts",family:"gpus",colorSlot:4,description:"Per-card power draw"},{metric:"fs.used",label:"Filesystem used",shortLabel:"Filesystem",unit:"bytes",family:"disks",colorSlot:1,description:"Used space per mounted filesystem"},{metric:"fs.usage",label:"Filesystem usage",shortLabel:"Filesystem %",unit:"percent",family:"disks",colorSlot:1,description:"Used capacity per mounted filesystem, derived from a positive total"},{metric:"fs.inodes.usage",label:"Inode usage",shortLabel:"Inodes %",unit:"percent",family:"disks",colorSlot:2,description:"Used inodes per filesystem where the collector can read them"},{metric:"disk.read",label:"Disk read",shortLabel:"Read",unit:"bytes_per_second",family:"disks",colorSlot:0,description:"Device read throughput"},{metric:"disk.write",label:"Disk write",shortLabel:"Write",unit:"bytes_per_second",family:"disks",colorSlot:2,description:"Device write throughput"},{metric:"disk.read.latency",label:"Disk read latency",shortLabel:"Read latency",unit:"milliseconds",family:"disks",colorSlot:0,description:"Average device read latency"},{metric:"disk.write.latency",label:"Disk write latency",shortLabel:"Write latency",unit:"milliseconds",family:"disks",colorSlot:2,description:"Average device write latency"},{metric:"disk.utilization",label:"Disk utilization",shortLabel:"Utilization",unit:"percent",family:"disks",colorSlot:3,description:"Share of time the device had I/O in flight"},{metric:"io.pressure.some",label:"I/O pressure (some)",shortLabel:"I/O some",unit:"percent",family:"disks",colorSlot:3,description:"Linux PSI I/O stall pressure, some tasks (avg10)"},{metric:"io.pressure.full",label:"I/O pressure (full)",shortLabel:"I/O full",unit:"percent",family:"disks",colorSlot:4,description:"Linux PSI I/O stall pressure, all tasks (avg10)"},{metric:"net.rx",label:"Network received",shortLabel:"Received",unit:"bytes_per_second",family:"network",colorSlot:0,description:"Interface receive rate"},{metric:"net.tx",label:"Network sent",shortLabel:"Sent",unit:"bytes_per_second",family:"network",colorSlot:2,description:"Interface transmit rate"}];function s(e,t){return e.filter(r=>{for(let[n,s,i]of[["memory","memory.used","memory.usage"],["filesystem","fs.used","fs.usage"]])if(e.includes(s)&&e.includes(i)&&(r===s||r===i))return r===("percent"===t[n]?i:s);return!0})}let i=[{id:"cpu",label:"CPU",metrics:["cpu.usage","cpu.core","cpu.iowait","cpu.pressure","cpu.temperature","cpu.power"]},{id:"memory",label:"Memory",metrics:["memory.used","memory.usage","swap.used","memory.pressure.some","memory.pressure.full"]},{id:"gpu",label:"GPU",metrics:["gpu.utilization","gpu.memory.used","gpu.temperature","gpu.power"]},{id:"disk",label:"Storage",metrics:["fs.used","fs.usage","fs.inodes.usage","disk.read","disk.write","disk.read.latency","disk.write.latency","disk.utilization","io.pressure.some","io.pressure.full"]},{id:"network",label:"Network",metrics:["net.rx","net.tx"]}],l=["var(--cpu)","var(--mem)","color-mix(in oklab, var(--swap) 75%, var(--foreground))","var(--warn)","var(--crit)","var(--accent)"],o=[void 0,"7 4","2 3","10 3 2 3","4 4","1 3"];function a(e){return n.find(t=>t.metric===e)??null}function u(e,t){let r=Math.max(0,t),n=e.colorSlot+r,s=(r+Math.floor(n/l.length))%o.length;return{color:l[n%l.length],dash:o[s]}}let c={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPU metrics",disks:"Disk metrics",network:"Network metrics"};function d(e,t){let r=a(t);if(null===r||void 0===e)return{available:!0,reason:null};let n=e.inventory?.capabilities?.[r.family];if(!n||"supported"===n.status)return{available:!0,reason:null};let s=n.reason?.trim();return{available:!1,reason:s?`${c[r.family]}: ${n.status} — ${s}`:`${c[r.family]} are ${n.status} on this machine.`}}function m(e){if(void 0===e)return[];let t=[],r=r=>{!(t.length>=16)&&d(e,r).available&&t.push(r)};r("cpu.usage"),r("memory.used");let n=function(e){let t=e.inventory?.memory.swapTotalBytes;if("number"==typeof t)return t;let r=e.metrics?.payload.swap;return r?.status==="ok"?r.totalBytes:null}(e);return null!==n&&n>0&&r("swap.used"),p(e,[]).length>0&&(r("gpu.utilization"),r("gpu.memory.used")),t}function f(e){let t=e.includes(":")?e.slice(e.indexOf(":")+1):e;return t.length<=18?t:`${t.slice(0,10)}…${t.slice(-4)}`}function p(e,t){let r=new Set(t.filter(e=>e.metric.startsWith("gpu.")&&""!==e.resourceId&&e.points.some(e=>null!==e.avg||null!==e.min||null!==e.max)).map(e=>e.resourceId)),n=[],s=new Set;(e?.inventory?.gpus??[]).forEach(e=>{let t="supported"===e.telemetry;(t||r.has(e.id))&&(s.add(e.id),n.push({id:e.id,label:e.name.trim()||f(e.id),index:n.length,totalBytes:e.memoryTotalBytes,supported:t,hasHistory:r.has(e.id)}))});let i=e?.metrics?.payload.gpus;if(i?.status==="ok")for(let e of i.devices)s.has(e.id)||"ok"!==e.status||(s.add(e.id),n.push({id:e.id,label:f(e.id),index:n.length,totalBytes:e.memoryTotalBytes,supported:!0,hasHistory:r.has(e.id)}));for(let e of[...r].sort())s.has(e)||n.push({id:e,label:e.startsWith("pci:")?`Previously detected GPU (${f(e)})`:f(e),index:n.length,totalBytes:null,supported:!0,hasHistory:!0});return n}function h(e,t,r){if(""===r)return a(t)?.shortLabel??"Total";let n=a(t);if(null===n)return f(r);switch(n.family){case"gpus":{let t=e?.inventory?.gpus.find(e=>e.id===r);return t?.name.trim()||f(r)}case"disks":{if(t.startsWith("fs.")){let t=e?.inventory?.filesystems.find(e=>e.id===r);return t?.mountPoint||f(r)}let n=e?.inventory?.disks.find(e=>e.id===r);return n?.name||f(r)}case"network":{let t=e?.inventory?.network.find(e=>e.id===r);return t?.name||f(r)}case"cpu":{let e=/^core:(\d+)$/.exec(r);return e?`Core ${e[1]}`:f(r)}default:return f(r)}}function g(e){switch(e){case"percent":return"%";case"bytes":return"bytes";case"bytes_per_second":return"bytes/s";case"celsius":return"\xb0C";case"watts":return"W";case"milliseconds":return"ms";default:return e}}},5078:(e,t,r)=>{r.d(t,{Ah:()=>d,I_:()=>h,O5:()=>p,Vw:()=>M,bf:()=>v,dd:()=>c,ei:()=>m,fH:()=>g,ly:()=>s,pI:()=>n,r6:()=>f,zp:()=>i});let n=[{id:"10m",shortLabel:"10m",label:"Last 10 minutes",ms:6e5,refreshMs:1e3},{id:"1h",shortLabel:"1h",label:"Last hour",ms:36e5,refreshMs:1e3},{id:"6h",shortLabel:"6h",label:"Last 6 hours",ms:216e5,refreshMs:1e3},{id:"24h",shortLabel:"24h",label:"Last 24 hours",ms:864e5,refreshMs:1e3},{id:"7d",shortLabel:"7d",label:"Last 7 days",ms:6048e5,refreshMs:1e3}];function s(e){return n.find(t=>t.id===e)??n[0]}function i(e){return s(e).refreshMs}let l=["B","KiB","MiB","GiB","TiB","PiB"];function o(e){let t=Math.abs(e),r=0;for(;t>=1024&&r<l.length-1;)t/=1024,r+=1;return{value:e<0?-t:t,unit:l[r]}}function a(e,t){return String(Number(e.toFixed(t)))}function u(e,t=""){let{value:r,unit:n}=o(e),s=Math.abs(r)>=100?0:1;return`${a(r,s)} ${n}${t}`}function c(e,t){if(null==e||!Number.isFinite(e))return"—";switch(t){case"percent":return`${a(e,1)}%`;case"bytes":return u(e);case"bytes_per_second":return u(e,"/s");case"celsius":return`${a(e,1)}\xb0C`;case"watts":return`${a(e,1)} W`;case"milliseconds":return`${a(e,10>Math.abs(e)?2:1)} ms`;default:return a(e,2)}}function d(e,t){if(!Number.isFinite(e))return"—";switch(t){case"percent":return`${a(e,0)}%`;case"bytes":case"bytes_per_second":{let{value:r,unit:n}=o(e),s=Math.abs(r)>=10||0===r?0:1;return`${a(r,s)} ${n}${"bytes_per_second"===t?"/s":""}`}case"celsius":return`${a(e,0)}\xb0C`;case"watts":return`${a(e,0)} W`;case"milliseconds":return`${a(e,+(10>Math.abs(e)))} ms`;default:return a(e,1)}}function m(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function f(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function p(e,t){let r=new Date(e);return t>=1728e5?r.toLocaleDateString(void 0,{month:"short",day:"numeric"}):t>=864e5?r.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}):r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function h(e){let t=Math.max(0,e);return t>=36e5?`${a(t/36e5,1)} h`:t>=6e4?`${a(t/6e4,1)} min`:`${a(t/1e3,1)} s`}function g(e,t,r){let n=e.filter(e=>e.toMs>=t&&e.fromMs<=r);if(0===n.length)return"No recorded gaps in this range.";let s=n.filter(e=>"dropped"===e.kind).length,i=n.length-s,l=[];i>0&&l.push(`${i} missed interval${1===i?"":"s"}`),s>0&&l.push(`${s} dropped report${1===s?"":"s"}`);let o=[...new Set(n.map(e=>e.reason).filter(e=>"string"==typeof e&&e.length>0))],a=o.length>0?` (${o.slice(0,3).join("; ")})`:"";return`${l.join(" and ")}${a}.`}function y(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function b(e){return"number"==typeof e&&Number.isFinite(e)}function x(e){return null===e||b(e)}function v(e){if(!y(e)||"string"!=typeof e.machineId||0===e.machineId.length||!b(e.fromMs)||!b(e.toMs)||e.toMs<=e.fromMs||!b(e.stepMs)||e.stepMs<=0||"raw"!==e.tier&&"1m"!==e.tier&&"1h"!==e.tier||"boolean"!=typeof e.truncated||!b(e.elapsedMs)||!Array.isArray(e.series)||!Array.isArray(e.gaps))return null;let t=[];for(let r of e.series){if(!y(r)||"string"!=typeof r.metric||"string"!=typeof r.resourceId||"string"!=typeof r.unit||!Array.isArray(r.points))return null;let e=[];for(let t of r.points){if(!y(t)||!b(t.t)||!x(t.min)||!x(t.max)||!x(t.avg))return null;e.push({t:t.t,min:t.min,max:t.max,avg:t.avg})}t.push({metric:r.metric,resourceId:r.resourceId,unit:r.unit,points:e})}let r=[];for(let t of e.gaps){if(!y(t)||!b(t.fromMs)||!b(t.toMs)||"missing"!==t.kind&&"dropped"!==t.kind)return null;let e={fromMs:t.fromMs,toMs:t.toMs,kind:t.kind};"string"==typeof t.reason&&(e.reason=t.reason),b(t.droppedRecords)&&(e.droppedRecords=t.droppedRecords),r.push(e)}return{machineId:e.machineId,fromMs:e.fromMs,toMs:e.toMs,stepMs:e.stepMs,tier:e.tier,series:t,gaps:r,truncated:e.truncated,elapsedMs:e.elapsedMs}}function M(e,t,r,n,i=600,l){let{fromMs:o,toMs:a}={fromMs:n-s(r).ms,toMs:n},u=new URLSearchParams({machineId:e,metrics:t.join(","),from:String(Math.floor(o)),to:String(Math.floor(a)),maxPoints:String(i)});return void 0!==l&&u.set("coreIds",l.join(",")),`/api/history?${u.toString()}`}},6304:(e,t,r)=>{function n(e,t,r,n){if(n.some(e=>t>e.fromMs&&t<e.toMs))return null;let s=0,i=e.length;for(;s<i;){let r=s+i>>>1;e[r].t<t?s=r+1:i=r}let l=e[s-1],o=e[s],a=l&&(!o||t-l.t<=o.t-t)?l:o;return!a||Math.abs(a.t-t)>r/2||n.some(e=>e.toMs>Math.min(t,a.t)&&e.fromMs<Math.max(t,a.t))?null:a}function s(e){return[...new Set(e.flatMap(e=>e.points.map(e=>e.t)))].sort((e,t)=>e-t).map(e=>({t:e,min:null,max:null,avg:null}))}function i(e,t,r,n,s,l=0){return Math.round(n+Math.max(0,Math.min(1,((r>0?(e-t)/r:0)-l)/(1-2*l)))*(s-n))}function l(e,t,r){return 0===e.length?null:"Home"===r?e[0].t:"End"===r||null===t?e.at(-1).t:"ArrowLeft"===r?[...e].reverse().find(e=>e.t<t)?.t??e[0].t:"ArrowRight"===r?e.find(e=>e.t>t)?.t??e.at(-1).t:t}r.d(t,{X:()=>s,bO:()=>n,o7:()=>l,yk:()=>i})},7284:(e,t,r)=>{r.d(t,{t:()=>c});var n=r(5155),s=r(2115),i=r(7726),l=r(5078),o=r(4567),a=r(6304),u=r(4150);function c(e){let{title:t,unit:r,series:c,fromMs:d,toMs:m,stepMs:f,gaps:p,hiddenKeys:h,onToggleSeries:g,emptyMessage:y,note:b}=e,x=(0,s.useMemo)(()=>c.filter(e=>!h.has(e.key)),[c,h]),v=(0,u.Au)({series:x,fromMs:d,toMs:m,stepMs:f,gaps:p}),M=(0,s.useRef)(null),k=(0,s.useMemo)(()=>x.flatMap(e=>e.points),[x]),w=k.some(e=>null!==e.avg||null!==e.min||null!==e.max),$=Math.max(1,m-d),j=(0,s.useMemo)(()=>(0,i.$z)(p,d,m,k),[p,d,m,k]),S=(0,s.useMemo)(()=>(0,i.kk)(r,k.flatMap(e=>[e.min,e.max,e.avg]).filter(e=>null!==e)),[r,k]),L=Math.max(1e-9,S.max-S.min),N=(0,s.useCallback)(e=>6+(Math.min(m,Math.max(d,e))-d)/$*788,[d,m,$]),P=(0,s.useCallback)(e=>6+(1-(e-S.min)/L)*148,[S.min,L]),I=(0,s.useMemo)(()=>x.map(t=>{let r=(0,i.o)(t.points,{stepMs:f,gaps:j,fromMs:d,toMs:m}).map(t=>(0,i.SG)(t,e.maxDrawPoints??601,f));return{...t,segments:r,envelope:r.filter(e=>e.length>1).map(e=>{let t=e.map(e=>`${N(e.t).toFixed(2)},${P(e.max??e.avg).toFixed(2)}`),r=[...e].reverse().map(e=>`${N(e.t).toFixed(2)},${P(e.min??e.avg).toFixed(2)}`);return`M${t.join("L")}L${r.join("L")}Z`}).join(" "),path:r.filter(e=>e.length>1).map(e=>e.map((e,t)=>`${0===t?"M":"L"}${N(e.t).toFixed(2)},${P(e.avg).toFixed(2)}`).join(" ")).join(" ")}}),[x,e.maxDrawPoints,f,j,d,m,N,P]),C=(0,s.useMemo)(()=>(function(e,t,r,n,s,o){if(0===r.length)return`${e} chart: no series selected.`;let a=r.map(e=>{let r=(0,i.T6)(e.points);return`${e.label}: ${function(e,t){let r=[];if(null!==e.latest){let n=null!==e.latestT?(0,l.ei)(e.latestT):null;r.push(`latest ${(0,l.dd)(e.latest,t)}${n?` at ${n}`:""}`)}return r.push(`average ${(0,l.dd)(e.avg,t)}`),null!==e.min&&null!==e.max&&r.push(`recorded range ${(0,l.dd)(e.min,t)} to ${(0,l.dd)(e.max,t)}`),r.join(", ")}(r,t)}`}),u=o>0?`${o} shaded interval${1===o?"":"s"} without stored data.`:"";return`${e} time-series chart. ${a.join(". ")}. ${u} Time range ${(0,l.ei)(n)} to ${(0,l.ei)(s)}.`})(t,r,x,d,m,j.length),[t,r,x,d,m,j.length]),A=(0,s.useMemo)(()=>new Map(c.map(e=>[e.key,(0,i.T6)(e.points)])),[c]),D=null===v.timeMs?[]:x.map(e=>({...e,point:(0,a.bO)(e.points,v.timeMs,f,p)})),F=null===v.timeMs?null:N(v.timeMs),R=`${v.id}-tooltip`,T=`${v.id}-instructions`,U=(0,s.useMemo)(()=>(0,n.jsxs)(n.Fragment,{children:[S.ticks.map(e=>(0,n.jsx)("line",{x1:6,x2:794,y1:P(e),y2:P(e),stroke:"var(--border)",strokeWidth:"1",vectorEffect:"non-scaling-stroke"},`grid-${e}`)),j.map(e=>(0,n.jsx)("rect",{x:N(e.fromMs),y:6,width:Math.max(1,N(e.toMs)-N(e.fromMs)),height:148,fill:"var(--muted-foreground)",opacity:"0.09"},`gap-${e.fromMs}-${e.toMs}-${e.kind}`)),I.map(e=>{let t=e.envelope;return""===t?null:(0,n.jsx)("path",{d:t,fill:e.color,opacity:"0.14",stroke:"none"},`band-${e.key}`)}),I.map(e=>{let t=e.path;return""===t?null:(0,n.jsx)("path",{d:t,fill:"none",stroke:e.color,strokeWidth:"2",strokeDasharray:e.dash,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"},`line-${e.key}`)}),I.flatMap(e=>e.segments.filter(e=>1===e.length).map(t=>{let r=t[0],s=N(r.t),i=P(r.avg);return(0,n.jsx)("line",{x1:s-2.5,x2:s+2.5,y1:i,y2:i,stroke:e.color,strokeWidth:"2.5",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"},`dot-${e.key}-${r.t}`)}))]}),[S,N,P,j,I]);return(0,n.jsxs)("figure",{className:`flex min-w-0 flex-col gap-2 ${e.className??""}`,children:[(0,n.jsxs)("div",{className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[(0,n.jsx)("h3",{className:"text-xs font-medium tracking-tight text-foreground",children:t}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("span",{className:"tnum shrink-0 text-xs text-muted-foreground",children:b??(0,o.RL)(r)}),e.action]})]}),w?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex min-w-0 gap-2",children:[(0,n.jsx)("div",{"aria-hidden":!0,className:"flex h-40 w-14 shrink-0 flex-col justify-between py-0.5 text-right text-xs leading-none tnum text-muted-foreground",children:[...S.ticks].reverse().map(e=>(0,n.jsx)("span",{children:(0,l.Ah)(e,r)},e))}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"relative touch-pan-y select-none",onPointerLeave:e=>{"mouse"===e.pointerType&&v.clear()},onPointerDown:e=>{if("mouse"===e.pointerType)return;e.currentTarget.setPointerCapture(e.pointerId);let t=M.current?.getBoundingClientRect();t&&v.inspect((0,a.yk)(e.clientX,t.left,t.width,d,m,.0075))},onPointerCancel:v.clear,onContextMenu:e=>e.preventDefault(),onPointerMove:e=>{let t=M.current?.getBoundingClientRect();t&&v.inspect((0,a.yk)(e.clientX,t.left,t.width,d,m,.0075))},children:[(0,n.jsx)("p",{id:T,className:"sr-only",children:"Touch and drag horizontally to inspect readings. Use Left and Right arrows to inspect recorded readings, Home or End to jump, and Escape to dismiss."}),(0,n.jsxs)("svg",{ref:M,viewBox:"0 0 800 160",preserveAspectRatio:"none",role:"img","aria-label":C,tabIndex:0,"aria-describedby":`${T}${v.active?` ${R}`:""}`,onFocus:v.onFocus,onBlur:v.clear,onKeyDown:v.onKeyDown,className:"block h-40 w-full cursor-crosshair rounded-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",children:[(0,n.jsx)("title",{children:t}),U,null!==F?(0,n.jsxs)("g",{"aria-hidden":!0,pointerEvents:"none",children:[(0,n.jsx)("line",{x1:F,x2:F,y1:6,y2:154,stroke:"var(--muted-foreground)",strokeWidth:"1",strokeDasharray:"3 3",vectorEffect:"non-scaling-stroke"}),D.map(({key:e,color:t,point:r})=>r?.avg==null?null:(0,n.jsx)("circle",{cx:N(r.t),cy:P(r.avg),r:"3.5",fill:t,stroke:"var(--card)",strokeWidth:"1.5",vectorEffect:"non-scaling-stroke"},e))]}):null]}),v.active&&null!==v.timeMs&&null!==F?(0,n.jsx)(u.eg,{id:R,timeMs:v.timeMs,fraction:F/800,unit:r,readings:D}):null]}),(0,n.jsx)("div",{"aria-hidden":!0,className:"mt-1 flex justify-between gap-2 text-xs leading-tight tnum text-muted-foreground",children:(0,i.Cf)(d,m).map((e,t,r)=>(0,n.jsx)("span",{className:`${0===t?"text-left":t===r.length-1?"text-right":"hidden text-center sm:inline"}`,children:(0,l.O5)(e,$)},e))})]})]}),(0,n.jsx)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs",children:c.map(e=>{let t=!h.has(e.key),s=A.get(e.key);return(0,n.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center gap-1.5",title:t?`Hide ${e.label}`:`Show ${e.label}`,children:[(0,n.jsx)("input",{type:"checkbox",checked:t,onChange:()=>g(e.key),className:"peer sr-only"}),(0,n.jsx)("span",{"aria-hidden":!0,className:"flex h-4 w-5 shrink-0 items-center justify-center rounded-sm peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]",children:(0,n.jsx)("svg",{viewBox:"0 0 20 8",className:"h-2 w-5","aria-hidden":!0,children:(0,n.jsx)("line",{x1:"1",y1:"4",x2:"19",y2:"4",stroke:e.color,strokeWidth:"2.5",strokeDasharray:e.dash,strokeLinecap:"round"})})}),(0,n.jsx)("span",{className:t?"text-foreground":"text-muted-foreground line-through",children:e.label}),(0,n.jsx)("span",{className:"tnum text-muted-foreground",children:(0,l.dd)(s.latest,r)})]},`legend-${e.key}`)})})]}):(0,n.jsx)("div",{className:"flex min-h-32 items-center justify-center rounded-lg border border-dashed border-border px-4 py-6 text-center text-xs text-muted-foreground",children:0===c.length?y:0===x.length?"All series are hidden. Re-enable one in the legend below.":y}),!w&&c.length>0?(0,n.jsx)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs",children:c.map(e=>{let t=!h.has(e.key);return(0,n.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center gap-1.5",children:[(0,n.jsx)("input",{type:"checkbox",checked:t,onChange:()=>g(e.key),className:"peer sr-only"}),(0,n.jsx)("span",{"aria-hidden":!0,className:"flex h-4 w-5 shrink-0 items-center justify-center peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]",children:(0,n.jsx)("svg",{viewBox:"0 0 20 8",className:"h-2 w-5","aria-hidden":!0,children:(0,n.jsx)("line",{x1:"1",y1:"4",x2:"19",y2:"4",stroke:e.color,strokeWidth:"2.5",strokeDasharray:e.dash,strokeLinecap:"round"})})}),(0,n.jsx)("span",{className:t?"text-foreground":"text-muted-foreground line-through",children:e.label})]},`legend-empty-${e.key}`)})}):null]})}},7726:(e,t,r)=>{function n(e){return null!==e.avg&&Number.isFinite(e.avg)}function s(e){return null!==e&&Number.isFinite(e)?e:null}function i(e){let t=[];for(let r of e){let e=t.at(-1);if(void 0!==e&&r.fromMs<=e.toMs){e.toMs=Math.max(e.toMs,r.toMs),"missing"===e.kind&&"dropped"===r.kind&&(e.kind="dropped"),void 0===e.reason&&void 0!==r.reason&&(e.reason=r.reason),void 0===e.droppedRecords&&void 0!==r.droppedRecords&&(e.droppedRecords=r.droppedRecords);continue}t.push({...r})}return t}function l(e,t,r,s){let l=i(e.map(e=>({...e,fromMs:Math.max(t,e.fromMs),toMs:Math.min(r,e.toMs)})).filter(e=>e.toMs>e.fromMs).sort((e,t)=>e.fromMs-t.fromMs||e.toMs-t.toMs));return void 0===s?l:function(e,t,r,s){if(0===e.length)return[];let l=[...new Set(t.filter(n).map(e=>e.t).filter(e=>Number.isFinite(e)))].sort((e,t)=>e-t),o=[];for(let t of e){let e=Math.max(r,Math.min(s,t.fromMs)),n=Math.max(r,Math.min(s,t.toMs));if(n<=e)continue;let i=Math.max(r,function(e,t){let r=0,n=e.length;for(;r<n;){let s=r+n>>>1;e[s]<=t?r=s+1:n=s}return r>0?e[r-1]:null}(l,e)??e),a=Math.min(s,function(e,t){let r=0,n=e.length;for(;r<n;){let s=r+n>>>1;e[s]<t?r=s+1:n=s}return r<e.length?e[r]:null}(l,n)??n);a<=i||o.push({...t,fromMs:i,toMs:a})}return o.sort((e,t)=>e.fromMs-t.fromMs||e.toMs-t.toMs),i(o)}(l,s,t,r)}function o(e,t,r){return Math.max(e,"1h"===t?36e5:"1m"===t?6e4:100,r??0)}function a(e,t){let r=[...e].sort((e,t)=>e.t-t.t),s=l(t.gaps,t.fromMs,t.toMs),i=Math.max(1,t.stepMs),o=[],a=[],u=()=>{a.length>0&&o.push(a),a=[]};for(let e of r){if(!n(e)){u();continue}let t=a.at(-1);if(void 0!==t){let r=!e.merged&&!t.merged&&(e.t<t.t||e.t-t.t>1.5*i),n=!0===e.gapBefore||function(e,t,r){return r.some(r=>r.toMs>e&&r.fromMs<t)}(t.t,e.t,s);(r||n)&&u()}a.push(e)}return u(),o}function u(e,t,r){if(t<=0)return[];let i=[...e].sort((e,t)=>e.t-t.t);if(i.length<=t)return i.map(e=>({...e}));let l=Math.max(2,Math.ceil(i.length/t)),o=Math.max(1,r),a=[],u=[],c=!1,d=null,m=()=>{if(0===u.length)return;let e=null,t=null,r=0,n=0;for(let i of u){let l=s(i.min),o=s(i.max);null!==l&&(null===e||l<e)&&(e=l),null!==o&&(null===t||o>t)&&(t=o);let a=s(i.avg);null!==a&&(r+=a,n+=1)}a.push({t:u[0].t,min:e,max:t,avg:n>0?r/n:null,...u.length>1?{merged:!0}:{},...c?{gapBefore:!0}:{}}),u=[],c=!1};for(let e of i){if(!n(e)){m(),a.push({...e}),d=null;continue}let t=null!==d&&e.t>=d.t&&e.t-d.t<=1.5*o;u.length>0&&(!t||u.length>=l)&&m(),0===u.length&&(c=null!==d&&!t),u.push(e),d=e}return m(),a}function c(e){let t=null,r=null,n=0,i=0,l=null,o=null,a=null,u=null;for(let c of e){if(null===c.avg)continue;(null===a||c.t<a)&&(a=c.t),(null===u||c.t>u)&&(u=c.t);let e=s(c.min),d=s(c.max);null!==e&&(null===t||e<t)&&(t=e),null!==d&&(null===r||d>r)&&(r=d),null!==c.avg&&Number.isFinite(c.avg)&&(n+=c.avg,i+=1,l=c.avg,o=c.t)}return{count:i,min:t,max:r,avg:i>0?n/i:null,latest:l,latestT:o,firstT:a,lastT:u}}function d(e){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.pow(10,Math.floor(Math.log10(e))),r=e/t;return(r<=1?1:r<=2?2:r<=5?5:10)*t}function m(e,t){if("percent"===e)return{min:0,max:100,ticks:[0,25,50,75,100]};let r=t.filter(e=>null!==e&&Number.isFinite(e));if(0===r.length)return{min:0,max:1,ticks:[0,1]};let n=Math.min(...r),s=Math.max(...r);if("celsius"===e){let e=Math.max(1,(s-n)*.1);n=5*Math.floor((n-e)/5),s=5*Math.ceil((s+e)/5)}else n=0,s=s>0?s:1;s<=n&&(s=n+1);let i=d((s-n)/4),l=Math.floor(n/i)*i,o=Math.ceil(s/i)*i,a=function(e,t,r=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[0,1];if(t<=e)return[e];let n=d((t-e)/Math.max(1,r)),s=Math.ceil(e/n)*n,i=[];for(let e=s;e<=t+.001*n&&i.length<20;e+=n)i.push(Number(e.toPrecision(12)));return i.length>0?i:[e,t]}(l,o,4);return{min:l,max:o,ticks:a}}function f(e,t,r=4){let n=Math.max(2,Math.floor(r)),s=Math.max(0,t-e);return Array.from({length:n},(t,r)=>e+s*r/(n-1))}r.d(t,{$z:()=>l,Cf:()=>f,SG:()=>u,T6:()=>c,jl:()=>o,kk:()=>m,o:()=>a})},9429:(e,t,r)=>{r.d(t,{n:()=>l});var n=r(2115),s=r(5078);async function i(e){let t=null;try{let r=await e.json();if(null!==r&&"object"==typeof r&&"error"in r){let e=r.error;"string"==typeof e&&(t=e)}}catch{}switch(e.status){case 401:return{kind:"unauthorized",message:"Your session is no longer accepted."};case 403:return{kind:"denied",message:t??"You do not have access to this machine's history."};case 404:return{kind:"missing",message:t??"This machine is not available to the hub."};case 429:return{kind:"rate-limited",message:t??"The hub is limiting history requests."};case 503:return{kind:"unavailable",message:t??"History is temporarily unavailable."};default:return{kind:"invalid",message:t??`The hub could not answer this history query (${e.status}).`}}}function l({machineId:e,metricsKey:t,coreIdsKey:r,range:o,enabled:a=!0,autoRefresh:u=!0,refreshNonce:c=0}){let[d,m]=(0,n.useState)({machineId:e,metricsKey:t,coreIdsKey:r,range:o}),f=d.machineId===e&&d.range===o;(0,n.useEffect)(()=>{if(!f)return void m({machineId:e,metricsKey:t,coreIdsKey:r,range:o});let n=window.setTimeout(()=>m({machineId:e,metricsKey:t,coreIdsKey:r,range:o}),300);return()=>window.clearTimeout(n)},[e,t,r,o,f]);let p=f?d:{machineId:e,metricsKey:t,coreIdsKey:r,range:o},h=p.metricsKey,g=p.coreIdsKey,y=`${e}|${h}|${o}|${g??"all"}`,[b,x]=(0,n.useState)(null),[v,M]=(0,n.useState)(null),[k,w]=(0,n.useState)(null),$=(0,n.useRef)(c);return(0,n.useEffect)(()=>{let t=$.current!==c;if($.current=c,!a||!e||!h)return;let r=!0,n=!1,l=!1,d=-1/0,m=new AbortController,f=(0,s.zp)(o),p=async(t=!1)=>{if(r&&!n&&!l){n=!0,d=Date.now(),w({key:y,manual:t});try{let t=await fetch((0,s.Vw)(e,h.split(","),o,Date.now(),600,void 0===g?void 0:g.split(",").filter(Boolean)),{signal:"function"!=typeof AbortSignal.any||"function"!=typeof AbortSignal.timeout?m.signal:AbortSignal.any([m.signal,AbortSignal.timeout(2e4)]),cache:"no-store",headers:{Accept:"application/json"}});if(!t.ok)throw await i(t);let n=(0,s.bf)(await t.json());if(null===n||n.machineId!==e)throw{kind:"invalid",message:"Unexpected history response."};if(!r)return;x({key:y,range:o,result:n,loadedAt:Date.now()}),M(null)}catch(t){if(!r||m.signal.aborted)return;let e=null!==t&&"object"==typeof t&&"kind"in t&&"message"in t&&"string"==typeof t.message?t:{kind:"network",message:"Could not reach the hub. Try again."};l="rate-limited"===e.kind,["unauthorized","denied","missing"].includes(e.kind)&&x(null),M({key:y,error:e})}finally{n=!1,r&&w(null)}}},b=()=>{"visible"!==document.visibilityState||Date.now()-d<f||p()};p(t);let v=u?window.setInterval(b,f):null;return u&&document.addEventListener("visibilitychange",b),()=>{r=!1,m.abort(),null!==v&&window.clearInterval(v),document.removeEventListener("visibilitychange",b)}},[a,e,h,g,o,y,u,c]),{data:a&&b?.result.machineId===e&&b.range===o?b:null,error:a&&v?.key===y?v.error:null,loading:a&&k?.key===y,manualRefreshing:a&&k?.key===y&&k.manual}}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[939],{592:(e,t,r)=>{r.d(t,{U8:()=>n,Q_:()=>l,FZ:()=>T});let n=1024,i=Date.parse("2000-01-01T00:00:00Z"),s=Date.parse("2200-01-01T00:00:00Z"),a=["metrics","inventory","processes"],o=["cpu","memory","swap","gpus","disks","network"],u=["outbox-age","outbox-bytes","disk-budget","write-failure","rejected"];function l(e){let t=b(e,"collector message");switch(t.type){case"hello":{k(t,["type","collectorId","runId","bootId","hostname","capabilities","expectedIntervalMs"],"hello");let e=$(t.capabilities,"hello.capabilities",1,a.length).map(e=>A(e,a,"hello.capabilities"));if(new Set(e).size!==e.length||!e.includes("metrics"))throw Error("invalid hello: capabilities must be unique and include metrics");return{type:"hello",collectorId:E(t.collectorId,"collectorId"),runId:E(t.runId,"runId"),bootId:B(t.bootId,"bootId",0,128),hostname:B(t.hostname,"hostname",0,255),capabilities:e,expectedIntervalMs:P(t.expectedIntervalMs,"expectedIntervalMs",100,72e5)}}case"samples":{k(t,["type","mode","records"],"samples");let e=A(t.mode,["live","replay"],"samples.mode"),r=$(t.records,"samples.records",1,32).map((e,t)=>d(e,`records[${t}]`)),n=new Set;for(let e of r){let t=`${e.runId}\0${e.sequence}`;if(n.has(t))throw Error("invalid samples: duplicate record in batch");n.add(t)}return{type:"samples",mode:e,records:r}}case"inventory":return k(t,["type","capturedAt","inventory"],"inventory"),{type:"inventory",capturedAt:x(t.capturedAt,"capturedAt"),inventory:c(t.inventory)};case"status":return k(t,["type","capturedAt","delivery","failures"],"status"),{type:"status",capturedAt:x(t.capturedAt,"capturedAt"),delivery:function(e){let t=b(e,"delivery");if(k(t,["pendingRecords","pendingBytes","oldestPendingCapturedAt","inFlightRecords","droppedRecords","replaying","lastAckAt"],"delivery"),"boolean"!=typeof t.replaying)throw Error("invalid delivery: replaying");let r=(e,t)=>P(e,t,0,Number.MAX_SAFE_INTEGER);return{pendingRecords:r(t.pendingRecords,"pendingRecords"),pendingBytes:r(t.pendingBytes,"pendingBytes"),oldestPendingCapturedAt:v(t.oldestPendingCapturedAt,e=>x(e,"oldestPendingCapturedAt")),inFlightRecords:r(t.inFlightRecords,"inFlightRecords"),droppedRecords:r(t.droppedRecords,"droppedRecords"),replaying:t.replaying,lastAckAt:v(t.lastAckAt,e=>x(e,"lastAckAt"))}}(t.delivery),failures:$(t.failures,"failures",0,32).map(e=>{let t=b(e,"failure");return k(t,["metric","resourceId","reason"],"failure"),{metric:B(t.metric,"metric",1,64),resourceId:null===t.resourceId?null:I(t.resourceId),reason:B(t.reason,"reason",0,256)}})};case"detail.result":return k(t,["type","subscriptionId","capturedAt","snapshot"],"detail.result"),{type:"detail.result",subscriptionId:E(t.subscriptionId,"subscriptionId"),capturedAt:x(t.capturedAt,"capturedAt"),snapshot:function(e){let t=b(e,"process snapshot");if(k(t,["totalProcesses","truncated","inaccessible","processes"],"process snapshot"),"boolean"!=typeof t.truncated)throw Error("invalid process snapshot: truncated");let r=(e,t,r)=>v(e,e=>S(e,t,0,r));return{totalProcesses:P(t.totalProcesses,"totalProcesses",0,1e7),truncated:t.truncated,inaccessible:P(t.inaccessible,"inaccessible",0,1e7),processes:$(t.processes,"processes",0,6e3).map(e=>{let t=b(e,"process");k(t,["pid","ppid","startTicks","name","user","state","cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec","threads","unit"],"process",["command"]);let i={pid:P(t.pid,"pid",0,0x80000000),ppid:P(t.ppid,"ppid",0,0x80000000),startTicks:P(t.startTicks,"startTicks",0,Number.MAX_SAFE_INTEGER),name:B(t.name,"name",0,256),user:v(t.user,e=>B(e,"user",0,64)),state:B(t.state,"state",0,16),cpuPercent:r(t.cpuPercent,"cpuPercent",100*n),memoryRssBytes:v(t.memoryRssBytes,e=>P(e,"memoryRssBytes",0,Number.MAX_SAFE_INTEGER)),gpuMemoryBytes:v(t.gpuMemoryBytes,e=>P(e,"gpuMemoryBytes",0,Number.MAX_SAFE_INTEGER)),ioReadBytesPerSec:r(t.ioReadBytesPerSec,"ioReadBytesPerSec",1e13),ioWriteBytesPerSec:r(t.ioWriteBytesPerSec,"ioWriteBytesPerSec",1e13),threads:v(t.threads,e=>P(e,"threads",0,1e7)),unit:v(t.unit,e=>B(e,"unit",1,256))};return w(t,"command")&&(i.command=B(t.command,"command",0,4096)),i})}}(t.snapshot)};case"detail.ended":return k(t,["type","subscriptionId","reason"],"detail.ended"),{type:"detail.ended",subscriptionId:E(t.subscriptionId,"subscriptionId"),reason:A(t.reason,["expired","cancelled","withheld","unsupported","busy","failed"],"detail.ended.reason")};default:throw Error(`invalid collector message: unsupported type ${M(t.type)}`)}}function d(e,t="record"){let r=b(e,t);k(r,["collectorId","runId","bootId","sequence","capturedAt","kind","payload"],t);let i={collectorId:E(r.collectorId,"collectorId"),runId:E(r.runId,"runId"),bootId:B(r.bootId,"bootId",0,128),sequence:P(r.sequence,"sequence",0,Number.MAX_SAFE_INTEGER),capturedAt:x(r.capturedAt,"capturedAt")};if("metrics"===r.kind){let e;return{...i,kind:"metrics",payload:(k(e=b(r.payload,"metrics payload"),[...o],"metrics payload"),{cpu:y(e.cpu,"cpu",e=>{k(e,["status","usagePercent","perCore"],"cpu",["temperatureC","powerWatts","iowaitPercent","pressureSomePercent"]);let t={status:"ok",usagePercent:S(e.usagePercent,"usagePercent",0,100),perCore:$(e.perCore,"perCore",0,n).map(e=>null===e?null:S(e,"perCore",0,100))},r=g(e,"temperatureC",e=>S(e,"temperatureC",-50,200));void 0!==r&&(t.temperatureC=r);let i=g(e,"powerWatts",e=>S(e,"powerWatts",0,1e4));void 0!==i&&(t.powerWatts=i);let s=g(e,"iowaitPercent",e=>S(e,"iowaitPercent",0,100));void 0!==s&&(t.iowaitPercent=s);let a=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));return void 0!==a&&(t.pressureSomePercent=a),t}),memory:y(e.memory,"memory",m),swap:y(e.swap,"swap",p),gpus:y(e.gpus,"gpus",e=>(k(e,["status","devices"],"gpus"),{status:"ok",devices:h($(e.devices,"gpus.devices",0,16).map(e=>f(e,"gpu",(e,t)=>{k(e,["id","status","utilizationPercent","memoryUsedBytes","memoryTotalBytes","temperatureC","powerWatts"],"gpu");let r=v(e.memoryUsedBytes,e=>P(e,"memoryUsedBytes",0,Number.MAX_SAFE_INTEGER)),n=v(e.memoryTotalBytes,e=>P(e,"memoryTotalBytes",0,Number.MAX_SAFE_INTEGER));if(null!==r&&null!==n&&r>n)throw Error("invalid gpu: memoryUsedBytes exceeds total");return{id:t,status:"ok",utilizationPercent:v(e.utilizationPercent,e=>S(e,"utilizationPercent",0,100)),memoryUsedBytes:r,memoryTotalBytes:n,temperatureC:v(e.temperatureC,e=>S(e,"temperatureC",-50,200)),powerWatts:v(e.powerWatts,e=>S(e,"powerWatts",0,1e4))}})))})),disks:y(e.disks,"disks",e=>{k(e,["status","filesystems","devices"],"disks",["pressureSomePercent","pressureFullPercent"]);let t={status:"ok",filesystems:h($(e.filesystems,"filesystems",0,64).map(e=>f(e,"filesystem",(e,t)=>{k(e,["id","status","usedBytes","totalBytes"],"filesystem",["inodesUsed","inodesTotal"]);let r=p({status:"ok",usedBytes:e.usedBytes,totalBytes:e.totalBytes}),n={id:t,status:"ok",usedBytes:r.usedBytes,totalBytes:r.totalBytes},i=g(e,"inodesUsed",e=>P(e,"inodesUsed",0,Number.MAX_SAFE_INTEGER));void 0!==i&&(n.inodesUsed=i);let s=g(e,"inodesTotal",e=>P(e,"inodesTotal",0,Number.MAX_SAFE_INTEGER));if(void 0!==s&&(n.inodesTotal=s),null!=i&&null!=s&&i>s)throw Error("invalid filesystem: inodesUsed exceeds inodesTotal");return n}))),devices:h($(e.devices,"disk devices",0,64).map(e=>f(e,"disk",(e,t)=>{k(e,["id","status","readBytesPerSec","writeBytesPerSec"],"disk",["readLatencyMs","writeLatencyMs","ioUtilizationPercent"]);let r={id:t,status:"ok",readBytesPerSec:S(e.readBytesPerSec,"readBytesPerSec",0,1e13),writeBytesPerSec:S(e.writeBytesPerSec,"writeBytesPerSec",0,1e13)},n=g(e,"readLatencyMs",e=>S(e,"readLatencyMs",0,864e5));void 0!==n&&(r.readLatencyMs=n);let i=g(e,"writeLatencyMs",e=>S(e,"writeLatencyMs",0,864e5));void 0!==i&&(r.writeLatencyMs=i);let s=g(e,"ioUtilizationPercent",e=>S(e,"ioUtilizationPercent",0,100));return void 0!==s&&(r.ioUtilizationPercent=s),r})))},r=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==r&&(t.pressureSomePercent=r);let n=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==n&&(t.pressureFullPercent=n),t}),network:y(e.network,"network",e=>(k(e,["status","interfaces"],"network"),{status:"ok",interfaces:h($(e.interfaces,"interfaces",0,64).map(e=>f(e,"interface",(e,t)=>(k(e,["id","status","rxBytesPerSec","txBytesPerSec"],"interface"),{id:t,status:"ok",rxBytesPerSec:S(e.rxBytesPerSec,"rxBytesPerSec",0,1e13),txBytesPerSec:S(e.txBytesPerSec,"txBytesPerSec",0,1e13)}))))}))})}}if("gap"===r.kind){let e=b(r.payload,`${t}.payload`);k(e,["fromCapturedAt","toCapturedAt","droppedRecords","reason"],"gap payload");let n=x(e.fromCapturedAt,"fromCapturedAt"),s=x(e.toCapturedAt,"toCapturedAt");if(Date.parse(n)>Date.parse(s))throw Error("invalid gap: fromCapturedAt after toCapturedAt");return{...i,kind:"gap",payload:{fromCapturedAt:n,toCapturedAt:s,droppedRecords:P(e.droppedRecords,"droppedRecords",1,Number.MAX_SAFE_INTEGER),reason:A(e.reason,u,"gap.reason")}}}throw Error(`invalid ${t}: unsupported kind ${M(r.kind)}`)}function c(e){let t=b(e,"inventory");k(t,["os","cpu","memory","gpus","filesystems","disks","network","capabilities"],"inventory");let r=b(t.os,"inventory.os");k(r,["platform","release","distro","arch"],"inventory.os");let i=b(t.cpu,"inventory.cpu");k(i,["model","logicalCores"],"inventory.cpu");let s=b(t.memory,"inventory.memory");k(s,["totalBytes","swapTotalBytes"],"inventory.memory");let a=b(t.capabilities,"inventory.capabilities"),u=[...o,"processes"];k(a,[...u],"inventory.capabilities");let l={};for(let e of u){let t=b(a[e],`capability ${e}`);k(t,["status"],`capability ${e}`,["reason"]);let r={status:A(t.status,["supported","unsupported","withheld"],`capability ${e}`)};w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),l[e]=r}let d=(e,t)=>v(e,e=>P(e,t,0,Number.MAX_SAFE_INTEGER));return{os:{platform:B(r.platform,"platform",0,64),release:B(r.release,"release",0,256),distro:v(r.distro,e=>B(e,"distro",0,256)),arch:B(r.arch,"arch",0,64)},cpu:{model:v(i.model,e=>B(e,"model",0,256)),logicalCores:P(i.logicalCores,"logicalCores",0,n)},memory:{totalBytes:d(s.totalBytes,"totalBytes"),swapTotalBytes:d(s.swapTotalBytes,"swapTotalBytes")},gpus:h($(t.gpus,"inventory.gpus",0,16).map(e=>{let t=b(e,"gpu inventory");k(t,["id","name","vendor","pciBusId","telemetry","memoryTotalBytes"],"gpu inventory",["reason"]);let r={id:I(t.id),name:B(t.name,"name",0,256),vendor:A(t.vendor,["nvidia","amd","intel","aspeed","other"],"vendor"),pciBusId:v(t.pciBusId,e=>B(e,"pciBusId",1,64)),telemetry:A(t.telemetry,["supported","unsupported"],"telemetry"),memoryTotalBytes:d(t.memoryTotalBytes,"memoryTotalBytes")};return w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),r})),filesystems:h($(t.filesystems,"inventory.filesystems",0,64).map(e=>{let t=b(e,"filesystem inventory");return k(t,["id","mountPoint","device","fsType","totalBytes"],"filesystem inventory"),{id:I(t.id),mountPoint:B(t.mountPoint,"mountPoint",1,256),device:B(t.device,"device",0,256),fsType:B(t.fsType,"fsType",0,64),totalBytes:d(t.totalBytes,"totalBytes")}})),disks:h($(t.disks,"inventory.disks",0,64).map(e=>{let t=b(e,"disk inventory");if(k(t,["id","name","model","rotational","sizeBytes"],"disk inventory"),null!==t.rotational&&"boolean"!=typeof t.rotational)throw Error("invalid disk inventory: rotational");return{id:I(t.id),name:B(t.name,"name",1,64),model:v(t.model,e=>B(e,"model",0,256)),rotational:t.rotational,sizeBytes:d(t.sizeBytes,"sizeBytes")}})),network:h($(t.network,"inventory.network",0,64).map(e=>{let t=b(e,"interface inventory");if(k(t,["id","name","mac","addresses","virtual","state","speedMbps"],"interface inventory"),"boolean"!=typeof t.virtual)throw Error("invalid interface inventory: virtual");return{id:I(t.id),name:B(t.name,"name",1,64),mac:v(t.mac,e=>B(e,"mac",1,64)),addresses:$(t.addresses,"addresses",0,32).map(e=>{let t=b(e,"address");k(t,["family","address","prefix"],"address");let r=A(t.family,["ipv4","ipv6"],"family");return{family:r,address:B(t.address,"address",2,64),prefix:P(t.prefix,"prefix",0,"ipv4"===r?32:128)}}),virtual:t.virtual,state:A(t.state,["up","down","unknown"],"state"),speedMbps:v(t.speedMbps,e=>P(e,"speedMbps",0,1e7))}})),capabilities:l}}function p(e){k(e,["status","usedBytes","totalBytes"],"usage");let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid usage: usedBytes exceeds totalBytes");return{status:"ok",usedBytes:r,totalBytes:t}}function m(e){k(e,["status","usedBytes","totalBytes"],"memory",["pressureSomePercent","pressureFullPercent"]);let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid memory: usedBytes exceeds totalBytes");let n={status:"ok",usedBytes:r,totalBytes:t},i=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==i&&(n.pressureSomePercent=i);let s=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==s&&(n.pressureFullPercent=s),n}function y(e,t,r){let n=b(e,t);if("ok"===n.status)return r(n);if("unavailable"===n.status)return k(n,["status","reason"],t),{status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function f(e,t,r){let n=b(e,t),i=I(n.id);if("ok"===n.status)return r(n,i);if("unavailable"===n.status)return k(n,["id","status","reason"],t),{id:i,status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function h(e){let t=new Set;for(let r of e){if(t.has(r.id))throw Error(`invalid resource list: duplicate id ${M(r.id)}`);t.add(r.id)}return e}function v(e,t){return null===e?null:t(e)}function g(e,t,r){if(w(e,t))return v(e[t],r)}function b(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${M(e)}`);return e}function k(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(w(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function w(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $(e,t,r,n){if(!Array.isArray(e))throw Error(`invalid ${t}: expected array`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function A(e,t,r){if("string"!=typeof e||!t.includes(e))throw Error(`invalid ${r}: unexpected value ${M(e)}`);return e}function B(e,t,r,n){if("string"!=typeof e)throw Error(`invalid ${t}: expected string, got ${M(e)}`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function E(e,t){return B(e,t,1,128)}function I(e){return B(e,"resource id",1,256)}function P(e,t,r,n){if("number"!=typeof e||!Number.isSafeInteger(e))throw Error(`invalid ${t}: expected safe integer, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function S(e,t,r,n){if("number"!=typeof e||!Number.isFinite(e))throw Error(`invalid ${t}: expected finite number, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function x(e,t){let r=B(e,t,1,64),n=Date.parse(r);if(!Number.isFinite(n)||n<i||n>s)throw Error(`invalid ${t}: not a parseable timestamp`);return r}function M(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}function T(e){let t=C(e,"hub snapshot");_(t,["hubRunId","machines"],"hub snapshot");let r=j(t.hubRunId,"hubRunId","hub snapshot");if(!Array.isArray(t.machines))throw Error("invalid snapshot machines");let n=new Set;return{hubRunId:r,machines:t.machines.map(e=>{let t=C(e,"machine");_(t,["machineId","collectorId","hostname","connected","lastReceivedAt"],"machine",["expectedIntervalMs","metrics","inventory","delivery","displayName","tags"]);let r=j(t.machineId,"machineId","machine");if(n.has(r))throw Error("duplicate snapshot machine");n.add(r);let i=j(t.collectorId,"collectorId","machine"),s=z(t.hostname,"hostname","machine",0,N);if("boolean"!=typeof t.connected)throw Error("invalid machine connection state");let a=null===t.lastReceivedAt?null:D(t.lastReceivedAt,"lastReceivedAt","machine"),o={},u=L(t,"expectedIntervalMs")?function(e,t,r){if(null===e)return null;if(void 0===e)throw Error(`invalid ${r}: ${t} must not be undefined`);var n=e,i=t,s=r;if("number"!=typeof n||!Number.isSafeInteger(n))throw Error(`invalid ${s}: ${i} must be a safe integer, got ${G(n)}`);if(n<100||n>72e5)throw Error(`invalid ${s}: ${i} ${n} outside ${100}..${72e5}`);return n}(t.expectedIntervalMs,"expectedIntervalMs","machine"):void 0;if(L(t,"metrics")){let{receivedAt:e,...r}=C(t.metrics,"received metrics"),n=d(r);if("metrics"!==n.kind||n.collectorId!==i)throw Error("conflicting machine metrics");if(o.metrics={...n,receivedAt:D(e,"receivedAt","metrics")},o.metrics.receivedAt!==a)throw Error("conflicting metrics receipt time")}if(L(t,"inventory")&&(o.inventory=c(t.inventory)),L(t,"delivery")){let e=l(t.delivery);if("status"!==e.type)throw Error("invalid delivery status");o.delivery=e}if(L(t,"displayName")&&(o.displayName=null===t.displayName?null:z(t.displayName,"displayName","machine",0,128)),L(t,"tags")){if(!Array.isArray(t.tags)||t.tags.length>32)throw Error("invalid machine tags");o.tags=t.tags.map(e=>z(e,"tag","machine",1,64))}return{machineId:r,collectorId:i,hostname:s,connected:t.connected,lastReceivedAt:a,...void 0===u?{}:{expectedIntervalMs:u},...o}})}}let N=255,R=Date.parse("2000-01-01T00:00:00Z"),F=Date.parse("2200-01-01T00:00:00Z");function C(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${G(e)}`);return e}function _(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(L(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function j(e,t,r){return z(e,t,r,1,128)}function z(e,t,r,n,i){if("string"!=typeof e)throw Error(`invalid ${r}: ${t} must be a string, got ${G(e)}`);if(e.length<n||e.length>i)throw Error(`invalid ${r}: ${t} length ${e.length} outside ${n}..${i}`);return e}function D(e,t,r){let n=z(e,t,r,1,64),i=Date.parse(n);if(!Number.isFinite(i)||i<R||i>F)throw Error(`invalid ${r}: ${t} is not a parseable timestamp`);return n}function G(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}},4334:(e,t,r)=>{r.d(t,{K:()=>o,g:()=>s});var n=r(5887),i=r(7586);function s(e,t){let r=new Map;for(let s of t.machines){let a=s.metrics;if(!a)continue;let o=`${t.hubRunId}\0${a.collectorId}\0${a.runId}\0${a.sequence}`,u=e.get(s.machineId)??[],l=u.at(-1);if(l?.sampleId===o){r.set(s.machineId,u);continue}let d=o.slice(0,o.lastIndexOf("\0")+1),c=l?.sampleId.startsWith(d)?u:[],p=a.payload.memory;r.set(s.machineId,[...c,{sampleId:o,receivedAtLocal:Date.parse(a.receivedAt),cpuPercent:"ok"===a.payload.cpu.status?a.payload.cpu.usagePercent:null,memoryPercent:"ok"===p.status&&p.totalBytes>0?100*p.usedBytes/p.totalBytes:null,gapThresholdMs:(0,i.Cj)(s.expectedIntervalMs)}].slice(-n.yY))}return r}function a(e){return"number"==typeof e.gapThresholdMs&&Number.isFinite(e.gapThresholdMs)&&e.gapThresholdMs>0?e.gapThresholdMs:n.vz}function o(e,t=600,r=140){let i;if(e.length<2)return null;let s=e[0].receivedAtLocal,u=Math.max(1e3,e.at(-1).receivedAtLocal-s),l="";for(let o of e){if(null===o.cpuPercent){i=void 0;continue}let e=4+(o.receivedAtLocal-s)/u*(t-8),d=r-4-o.cpuPercent/100*(r-8),c=i?Math.min(a(i),a(o)):n.vz,p=i&&o.receivedAtLocal>=i.receivedAtLocal&&o.receivedAtLocal-i.receivedAtLocal<c;l+=`${p?"L":"M"}${e.toFixed(2)},${d.toFixed(2)} `,i=o}return l.trim()||null}},5887:(e,t,r)=>{r.d(t,{mq:()=>i,vz:()=>n,yY:()=>s});let n=15e3,i=9e4,s=180},7586:(e,t,r)=>{r.d(t,{$:()=>s,A4:()=>d,Cj:()=>i,F2:()=>m,L_:()=>p,fv:()=>c,l9:()=>u,nV:()=>l,vj:()=>a,z3:()=>o});var n=r(5887);function i(e){return null==e||"number"!=typeof e||!Number.isFinite(e)||e<=0?n.vz:Math.max(n.vz,3*e)}function s(e){if(null==e||!Number.isFinite(e)||e<0)return"—";if(e<6e4){let t=e/1e3;return Number.isInteger(t)?`${t} s`:`${t.toFixed(1)} s`}if(e<36e5){let t=e/6e4;return Number.isInteger(t)?`${t} min`:`${t.toFixed(1)} min`}let t=e/36e5;return Number.isInteger(t)?`${t} h`:`${t.toFixed(1)} h`}function a(e,t,r=i(e.expectedIntervalMs)){return function(e,t,r=n.vz){if(null===e)return"unknown";let i=Date.parse(e);return Number.isFinite(i)?t-i>=r?"stale":"live":"unknown"}(e.lastReceivedAt,t,r)}function o(e){if(null==e||!Number.isFinite(e)||e<0)return"—";let t=["B","KiB","MiB","GiB","TiB"],r=e,n=0;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return 0===n?`${Math.round(r)} B`:`${r.toFixed(1)} ${t[n]}`}function u(e){return null!=e&&Number.isFinite(e)?`${e.toFixed(1)}%`:"—"}function l(e){if(null===e||!Number.isFinite(e))return"—";let t=Math.round(Math.max(0,e)/1e3);if(t<60)return`${t}s ago`;let r=Math.floor(t/60);if(r<60){let e=t%60;return 0===e?`${r}m ago`:`${r}m ${e}s ago`}let n=Math.floor(r/60);if(n<24){let e=r%60;return 0===e?`${n}h ago`:`${n}h ${e}m ago`}let i=Math.floor(n/24),s=n%24;return 0===s?`${i}d ago`:`${i}d ${s}h ago`}function d(e,t){if(null===e)return null;let r=Date.parse(e);return Number.isFinite(r)?t-r:null}function c(e){switch(e){case"ok":return"Live";case"degraded":return"Degraded";case"stale":return"Stale";case"disconnected":return"Disconnected";case"unseen":return"No sample yet"}}function p(e,t=n.mq){let r=e.metrics;if(!r)return{kind:"unknown"};let i=Date.parse(r.capturedAt),s=Date.parse(r.receivedAt);if(!Number.isFinite(i)||!Number.isFinite(s))return{kind:"unknown"};let a=i-s;return a>t?{kind:"ahead",skewMs:a}:a<-t?{kind:"behind",skewMs:-a}:{kind:"none"}}function m(e,t,r=i(e.expectedIntervalMs)){return{freshness:a(e,t,r),attention:function(e,t,r=i(e.expectedIntervalMs)){var n;let s=a(e,t,r);return e.metrics&&"unknown"!==s?"stale"===s?"stale":(n=e.metrics)&&("unavailable"===n.payload.cpu.status||"unavailable"===n.payload.memory.status)?"degraded":e.connected?"ok":"disconnected":"unseen"}(e,t,r),connection:e.connected?"connected":"disconnected",skew:p(e),thresholdMs:r}}},9939:(e,t,r)=>{r.d(t,{LiveProvider:()=>g,M:()=>v});var n=r(5155),i=r(2115);async function s(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e)return e}}catch{}return e.statusText||null}function a(e){if(!e||"object"!=typeof e)return null;let t=e.username,r=e.csrfToken;if("string"!=typeof t||0===t.length||"string"!=typeof r||0===r.length)return null;let n=e.admin;return void 0!==n&&"boolean"!=typeof n?null:{username:t,csrfToken:r,...!0===n?{admin:!0}:{}}}async function o(){try{let e=await fetch("/api/auth/session",{cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{Accept:"application/json"}});if(e.ok){try{let t=a(await e.json());if(t)return{kind:"signed-in",user:t}}catch{}return{kind:"error",detail:"unexpected session response"}}if(401===e.status)return{kind:"signed-out"};if(503===e.status)return{kind:"auth-unavailable",detail:await s(e)};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}}async function u(e,t){try{let r=await fetch("/api/auth/login",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({username:e,password:t})});if(r.ok){try{let e=a(await r.json());if(e)return{kind:"signed-in",user:e}}catch{}return{kind:"error",detail:"unexpected sign-in response"}}if(401===r.status)return{kind:"invalid-credentials",detail:await s(r)};if(429===r.status)return{kind:"error",detail:"too many attempts — wait a moment and try again"};if(503===r.status)return{kind:"auth-unavailable",detail:await s(r)};return{kind:"error",detail:`unexpected status ${r.status}`}}catch{return{kind:"unreachable"}}}async function l(e){try{let t=await fetch("/api/auth/logout",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"X-CSRF-Token":e,Accept:"application/json"}});if(t.ok||401===t.status)return"ok";return t.status,{kind:"error",detail:`unexpected status ${t.status}`}}catch{return"unreachable"}}async function d(e=5e3){let t=new AbortController,r=setTimeout(()=>t.abort(),e);try{let e=await fetch("/api/live",{cache:"no-store",signal:t.signal,headers:{Accept:"text/event-stream"}});if(200===e.status)return{kind:"ok"};if(401===e.status)return{kind:"unauthorized"};if(403===e.status)return{kind:"forbidden"};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}finally{clearTimeout(r);try{t.abort()}catch{}}}var c=r(592);let p=["snapshot","update","reset"];class m{source=null;lastId=null;get lastEventId(){return this.lastId}get isOpen(){return null!==this.source&&2!==this.source.readyState}start(e,t){this.close();let r=new EventSource(e);this.source=r;let n=e=>n=>{if(this.source!==r||null===this.source)return;let i=n.lastEventId;"string"==typeof i&&i.length>0&&(this.lastId=i);try{t.onSnapshot((0,c.FZ)(JSON.parse(n.data)),e,i??"")}catch{this.close(),t.onError()}};for(let e of p)r.addEventListener(e,n(e));r.onerror=()=>{this.source===r&&(this.close(),t.onError())}}close(){this.source?.close(),this.source=null}}var y=r(4334);let f=[1e3,2e3,4e3,8e3,15e3],h=(0,i.createContext)(null);function v(){let e=(0,i.useContext)(h);if(!e)throw Error("useLive must be used inside <LiveProvider>");return e}function g({children:e}){let[t,r]=(0,i.useState)({kind:"restoring"}),[s,a]=(0,i.useState)("idle"),[c,p]=(0,i.useState)(null),[v,b]=(0,i.useState)([]),[k,w]=(0,i.useState)(null),[$,A]=(0,i.useState)(null),[B,E]=(0,i.useState)(null),[I,P]=(0,i.useState)(null),[S,x]=(0,i.useState)(new Map),M=(0,i.useRef)(!0),T=(0,i.useRef)(0),N=(0,i.useRef)(null),R=(0,i.useRef)(null),F=(0,i.useRef)(0),C=(0,i.useRef)(t),_=(0,i.useRef)(0),L=(0,i.useRef)(!1),j=(0,i.useRef)(!1),z=e=>{C.current=e,r(e)},D=()=>{null!==R.current&&(clearTimeout(R.current),R.current=null)},G=()=>{_.current+=1,T.current+=1,N.current?.close(),N.current=null,D()},X=()=>{L.current=!1,b([]),x(new Map),p(null),A(null),E(null),w(null)},O=e=>{let t=C.current;("signed-in"!==t.kind||t.user.csrfToken!==e.csrfToken)&&X(),z({kind:"signed-in",user:e})},U=()=>{if("signed-in"!==C.current.kind)return;G(),a(L.current?"reconnecting":"connecting");let e=new m;N.current=e,e.start("/api/live",{onSnapshot:(t,r,n)=>{M.current&&N.current===e&&(F.current=0,L.current=!0,p(t.hubRunId),b(t.machines),w(Date.now()),A(n||null),E(r),x(e=>(0,y.g)(e,t)),a("live"))},onError:()=>{M.current&&N.current===e&&W()}})},W=async()=>{G();let e=_.current;a("reconnecting");let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind)O(t.user);else if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}else if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}let r=Math.min(F.current+1,f.length+1);if(F.current=r,r>f.length){a("disconnected"),Z();return}a("reconnecting"),R.current=setTimeout(()=>{q()},f[r-1])},q=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await d();if(M.current&&e===_.current){if("forbidden"===t.kind){X(),a("no-permission");return}if("unauthorized"===t.kind){let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}}U()}},Z=()=>{D(),R.current=setTimeout(()=>{J()},3e4)},J=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await o();if(M.current&&e===_.current){if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}Z()}},K=async e=>{let t=_.current,r=await o();if(M.current&&T.current===e&&t===_.current){if("signed-in"===r.kind){O(r.user),F.current=0,U();return}if("signed-out"===r.kind){z({kind:"signed-out"}),a("idle");return}if("auth-unavailable"===r.kind){z({kind:"auth-unavailable",detail:r.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===r.kind?r.detail:null}),a("idle")}},Y=async(e,t)=>{G();let r=_.current,n=await u(e,t);return M.current&&r===_.current?("signed-in"===n.kind&&M.current&&(O(n.user),P(null),F.current=0,U()),n):{kind:"error",detail:"Session request superseded. Try again."}},Q=async()=>{let e=C.current;if("signed-in"!==e.kind||j.current)return;j.current=!0,G();let t=_.current;X(),a("idle");let r=await l(e.user.csrfToken);if(j.current=!1,!M.current||t!==_.current)return;if("ok"===r){z({kind:"signed-out"}),X(),a("idle"),P("Signed out.");return}let n=await o();if(M.current&&t===_.current){if("signed-in"===n.kind){O(n.user),P("Sign out failed — try again."),U();return}if("signed-out"===n.kind){z({kind:"signed-out"}),X(),a("idle"),P(null);return}if("auth-unavailable"===n.kind){z({kind:"auth-unavailable",detail:n.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===n.kind?n.detail:null}),a("idle")}};return(0,i.useEffect)(()=>(M.current=!0,T.current+=1,K(T.current),()=>{M.current=!1,G()}),[]),(0,n.jsx)(h.Provider,{value:{session:t,phase:s,hubRunId:c,machines:v,lastReceivedLocalMs:k,lastEventId:$,lastEventKind:B,notice:I,history:S,login:Y,signOut:Q,retryConnection:()=>{if(M.current&&!j.current){if("signed-in"===C.current.kind){F.current=0,q();return}T.current+=1,K(T.current)}},dismissNotice:()=>P(null)},children:e})}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[572],{3092:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},3612:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},5773:(e,s,t)=>{"use strict";t.d(s,{ConnectionsView:()=>A});var n=t(5155),a=t(8500),l=t.n(a),r=t(438),d=t(3092),i=t(3612),c=t(7233),x=t(4173),o=t(3440),m=t(940),u=t(802),h=t(6576),g=t(6582),f=t(7586),p=t(9939),j=t(7348),N=t(2241);function b(e){if(null===e)return"—";let s=new Date(e);return Number.isFinite(s.getTime())?s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"}):e}function v({capability:e}){var s;return(0,n.jsxs)("li",{className:"rounded-md border border-border bg-card-strong/30 px-2 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,n.jsx)("span",{className:`tnum rounded-full px-1.5 py-0.5 text-xs ${"supported"===(s=e.status)?"bg-ok-soft text-ok":"unsupported"===s?"bg-warn-soft text-warn":"border border-border text-muted-foreground"}`,children:e.status})]}),e.reason?(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.reason}):null]})}function y({view:e,now:s}){return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,n.jsxs)("span",{className:"tnum inline-flex items-center gap-1.5 text-sm",children:[(0,n.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected":"Disconnected"]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Interval ",null===e.cadenceMs?"unknown":(0,f.$)(e.cadenceMs)]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Updated ",(0,f.nV)((0,f.A4)(e.lastReceivedAt,s))]}),"stale"===e.freshness?(0,n.jsx)(h.vw,{text:"stale",title:`No update for over ${(0,f.$)(e.thresholdMs)}`}):"unknown"===e.freshness?(0,n.jsx)(h.vw,{text:"no sample",title:"No receipt timestamp is available yet"}):null]})}function w({view:e}){if(null===e.delivery)return(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Delivery status unavailable."});let s=e.delivery;return(0,n.jsxs)("dl",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.pendingRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog bytes"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:(0,f.z3)(s.pendingBytes)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"In-flight records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.inFlightRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Oldest pending"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(s.oldestPendingCapturedAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Last acknowledgment"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:null===s.lastAckAt?"No acknowledgment yet":b(s.lastAckAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Dropped / gap records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.droppedRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Replaying"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.replaying?"Yes":"No"})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Status captured"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(e.deliveryCapturedAt)})]})]})}function k({view:e,now:s}){return(0,n.jsx)(o.Z,{title:e.name,action:(0,n.jsx)(l(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"text-xs text-accent hover:underline",children:"Open machine"}),children:(0,n.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,n.jsx)(y,{view:e,now:s}),(0,n.jsxs)("section",{"aria-label":`${e.name} delivery`,children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Delivery"]}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)(w,{view:e})})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} collection failures`,className:"border-t border-border pt-4",children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:"Collection failures"}),null===e.delivery?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Failure status unavailable."}):0===e.failures.length?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"None"}):(0,n.jsx)("ul",{className:"mt-2 flex flex-col gap-1.5",children:e.failures.map((e,s)=>(0,n.jsxs)("li",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-foreground",children:e.metric}),e.resourceId?(0,n.jsxs)("span",{className:"tnum font-mono text-xs text-muted-foreground",children:[" \xb7 ",e.resourceId]}):null,(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" — ",e.reason]})]},`${e.metric}\0${e.resourceId??""}\0${e.reason}\0${s}`))})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} capabilities`,className:"border-t border-border pt-4",children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(d.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Capabilities"]}),null===e.capabilities?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Capabilities unavailable."}):(0,n.jsx)("ul",{className:"mt-2 grid gap-1.5 sm:grid-cols-2 xl:grid-cols-3",children:e.capabilities.map(e=>(0,n.jsx)(v,{capability:e},e.key))})]})]})})}function A(){let{phase:e,machines:s,session:t}=(0,p.M)(),a=(0,g.x)(),r=(0,j.c)(),d=(0,N.cy)(s,r);return(0,n.jsx)(x.G,{title:"Connections",headerRight:(0,n.jsxs)(n.Fragment,{children:["signed-in"===t.kind&&t.user.admin?(0,n.jsxs)(l(),{href:"/administration#collectors",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs hover:bg-card-strong",children:[(0,n.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Add machine"]}):null,(0,n.jsx)(m.$E,{}),(0,n.jsx)(u.B,{})]}),children:a||(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.E,{}),("live"===e||"reconnecting"===e||"disconnected"===e)&&0===s.length?(0,n.jsx)(o.Z,{title:"No collectors",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"No collectors are connected to this hub in your authorized scope."})}):null,0===d.length&&"connecting"===e?(0,n.jsx)(o.Z,{title:"Waiting for collector status",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"Waiting for the first snapshot…"})}):null,d.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:"mb-4 text-sm font-medium tracking-tight",children:"Collectors"}),(0,n.jsx)("div",{className:"grid gap-5 xl:grid-cols-[repeat(auto-fit,minmax(30rem,1fr))]",children:d.map(e=>(0,n.jsx)(k,{view:e,now:r},e.machineId))})]}):null]})})}},6351:(e,s,t)=>{Promise.resolve().then(t.bind(t,5773))}},e=>{e.O(0,[944,939,103,130,441,794,358],()=>e(e.s=6351)),_N_E=e.O()}]);
|