Commit 9434f00
feat(agent): probe phase + startup capability table
Adds a lightweight version of the ProbeableGear mechanism from #60 §1.
Each gear self-reports whether its prerequisites are present; gears that
probe non-Available are skipped entirely (no Initialize, no Start, no
routes, no collectors/streamers). After the probe phase the manager
writes a summary table to stderr — readable in the systemd journal —
so operators can see at startup which gears are running on this host
and which aren't:
Gear probe summary:
GEAR STATUS REASON
certificates enabled
haproxy enabled
logs enabled
metrics enabled
security disabled neither fail2ban-client nor nft found on PATH
traffic enabled
updates enabled
Framework changes (internal/framework/gear/):
- Add ProbeStatus enum: available, not_installed, inaccessible, disabled
- Add ProbeResult struct + helper constructors (ProbeAvailable, etc.)
- Add ProbeableGear sub-interface; gears that don't implement it default
to Available, so the migration is incremental
- Add Manager.ProbeAll, ProbeResults, isLoaded; Initialize/Start/
RegisterRoutes/startCollectors/startStreamers/setupEventHandlers all
skip non-Available gears silently (the table already explained why)
- Inject tableWriter so tests can capture the rendered output
Per-gear probes:
- certificates: certbot or acme.sh on PATH/common paths (side-effect-free
variant of the existing detectCertbot)
- haproxy: stats URL, stats socket existence, or haproxy binary present
(with distinct inaccessible reason when the socket path is set but
missing — operator's fix differs from "install HAProxy")
- logs: journalctl or tail on PATH
- metrics: /proc/stat readable (containerized agents without /proc bind-
mounted land here as inaccessible)
- security: fail2ban-client or nft on PATH
- traffic: same surface as haproxy (stick tables go over the same socket)
- updates: any of apt-get/apt/dnf/yum/zypper/apk on PATH
Tests cover lifecycle skip behavior, default-Available for non-probeable
gears, the snapshot copy semantics of ProbeResults, and table formatting
(headers, alignment, reasons surfaced only for disabled rows). 9 tests
pass under -race.
Refs #60
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 667268d commit 9434f00
12 files changed
Lines changed: 739 additions & 12 deletions
File tree
- gearbox-agent
- cmd/gearbox-agent
- internal
- framework/gear
- gears
- certs
- haproxy
- logs
- metrics
- security
- traffic
- updates
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
392 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
393 | 400 | | |
394 | 401 | | |
395 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
0 commit comments