A machine is titled by its own hostname, and follows a rename

The name a machine was added under stays its identity — the URL, its accent, what the hub's
API calls it — and is what the Machines page shows as 'Added as'. The hostname is read live
rather than at start-up, so renaming a machine reaches the console without a restart.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Mitchell-Johnson
2026-09-21 17:04:17 -07:00
co-authored by Claude Opus 5
parent ec94cb8bff
commit dbfe163a75
8 changed files with 66 additions and 31 deletions
+3 -3
View File
@@ -210,7 +210,7 @@ func (e *alertEngine) evaluate() {
}
}
qb, _ := json.Marshal(query)
machines := append([]string{e.s.host}, e.s.nodes.Names()...)
machines := append([]string{e.s.hostName()}, e.s.nodes.Names()...)
results := map[string]map[string]any{} // machine → ruleID → value | {id: value}
reach := map[string]bool{}
var wg sync.WaitGroup
@@ -221,7 +221,7 @@ func (e *alertEngine) evaluate() {
defer wg.Done()
var res map[string]any
ok := false
if m == e.s.host {
if m == e.s.hostName() {
if out, err := sensors.Shape(e.s.sensors.All(), qb, false); err == nil {
res, ok = out.(map[string]any)
}
@@ -515,6 +515,6 @@ func (s *Server) alertsTest(w http.ResponseWriter, _ *http.Request) {
jsonErr(w, 400, "no channels to test")
return
}
e.notify(channels, AlertEvent{T: time.Now().UnixMilli(), Kind: "firing", Rule: "Test alert", Machine: s.host, Sensor: "hamlab.test", Value: "this is only a test", Severity: "info"})
e.notify(channels, AlertEvent{T: time.Now().UnixMilli(), Kind: "firing", Rule: "Test alert", Machine: s.hostName(), Sensor: "hamlab.test", Value: "this is only a test", Severity: "info"})
w.WriteHeader(204)
}