feat: show which checker ran a check and what it is doing
ci / image (pull_request) Successful in 4m31s
ci / lint (pull_request) Successful in 4m38s
ci / build (pull_request) Successful in 6m33s
ci / test (pull_request) Successful in 8m27s

Every recent check on a monitor page names and links the checker
instance that ran it. The checker page shows whether it is active, its
version, the checks it runs right now and has queued, and the viewer's
latest results on it, refreshing every five seconds. Platform checkers
serve all organizations, so other organizations' work appears only as a
count. Checks in progress are tracked in Redis between handing out a job
and receiving its result.

Closes #82

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 12:54:57 +01:00
1 parent 53ff2a628d
commit 0c2155fdc2
15 files changed
+1909 -523

No files matched your search

+160
View File
@@ -0,0 +1,160 @@
package web
import (
"strconv"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
)
// CheckerView shows what a checker instance is doing.
type CheckerView struct {
ID string
Agent string
Region string
Platform bool
Release string
Started string
LastSeen string
Live bool
Queued int
Running []CheckerRun
OtherOrgs int
Checks int
Failed int
AvgLatency string
Recent []CheckerResult
Siblings []CheckerLink
}
// CheckerRun is a check in progress.
type CheckerRun struct {
MonitorURL string
Monitor string
For string
}
// CheckerResult is a finished check of the instance.
type CheckerResult struct {
Time string
MonitorURL string
Monitor string
OK bool
Latency string
Detail string
}
// CheckerLink points to a checker instance.
type CheckerLink struct {
URL string
Label string
}
templ CheckerPage(p Page, me Me, v CheckerView) {
@consoleShell(p, me) {
<div class="mb-8">
<h1 class="flex items-center gap-2.5 text-lg font-semibold">
if v.Live {
@statusDot(StatusUp)
} else {
@statusDot(StatusUnknown)
}
{ v.Agent }
<span class="font-mono text-sm font-normal text-muted">{ v.ID[:8] }</span>
</h1>
<p class="mt-1 text-sm text-muted">
{ v.Region } ·
if v.Platform {
{ i18n.T(ctx, "regions.platform") }
} else {
{ i18n.T(ctx, "regions.own") }
}
·
if v.Live {
{ i18n.T(ctx, "checkers.live") }
} else {
{ i18n.T(ctx, "checkers.gone") }
}
</p>
</div>
<dl class="mb-10 grid grid-cols-2 gap-px border border-rule bg-rule sm:grid-cols-4">
@checkerFact("checkers.running", strconv.Itoa(len(v.Running)+v.OtherOrgs))
@checkerFact("checkers.queued", strconv.Itoa(v.Queued))
@checkerFact("checkers.last_hour", strconv.Itoa(v.Checks)+" / "+strconv.Itoa(v.Failed)+" ✕")
@checkerFact("checkers.avg_latency", v.AvgLatency)
@checkerFact("checkers.release", v.Release)
@checkerFact("checkers.started", v.Started)
@checkerFact("checkers.last_seen", v.LastSeen)
@checkerFact("checkers.instance", v.ID)
</dl>
<section class="mb-10">
@sectionHeading("checkers.now")
if len(v.Running) == 0 && v.OtherOrgs == 0 {
<p class="text-sm text-muted">{ i18n.T(ctx, "checkers.idle") }</p>
} else {
<ul class="divide-y divide-rule border-y border-rule text-sm">
for _, r := range v.Running {
<li class="flex justify-between gap-4 py-1.5">
<a href={ templ.SafeURL(r.MonitorURL) } class="hover:underline">{ r.Monitor }</a>
<span class="font-mono text-xs text-muted">{ i18n.T(ctx, "checkers.for", "Duration", r.For) }</span>
</li>
}
if v.OtherOrgs > 0 {
<li class="py-1.5 text-xs text-muted">{ i18n.T(ctx, "checkers.others", "Count", v.OtherOrgs) }</li>
}
</ul>
}
<p class="mt-2 text-xs text-muted">{ i18n.T(ctx, "checkers.refresh_hint") }</p>
</section>
<section class="mb-10">
@sectionHeading("checkers.recent")
if len(v.Recent) == 0 {
<p class="text-sm text-muted">{ i18n.T(ctx, "checkers.no_recent") }</p>
} else {
<table class="w-full text-left text-sm">
<tbody class="divide-y divide-rule border-y border-rule">
for _, r := range v.Recent {
<tr>
<td class="py-1.5 pr-4 font-mono text-xs whitespace-nowrap text-muted">{ r.Time }</td>
<td class="py-1.5 pr-4"><a href={ templ.SafeURL(r.MonitorURL) } class="hover:underline">{ r.Monitor }</a></td>
<td class="py-1.5 pr-4">
if r.OK {
<span class="text-up">●</span>
} else {
<span class="text-down">●</span>
}
</td>
<td class="py-1.5 pr-4 font-mono text-xs">{ r.Latency }</td>
<td class="py-1.5 font-mono text-xs text-muted">{ r.Detail }</td>
</tr>
}
</tbody>
</table>
}
</section>
if len(v.Siblings) > 0 {
<section>
@sectionHeading("checkers.siblings")
<p class="flex flex-wrap gap-3 font-mono text-xs">
for _, sb := range v.Siblings {
<a href={ templ.SafeURL(sb.URL) } class="underline underline-offset-2">{ sb.Label }</a>
}
</p>
</section>
}
}
}
templ checkerFact(labelID, value string) {
<div class="bg-paper px-3 py-2">
<dt class="text-xs text-muted">{ i18n.T(ctx, labelID) }</dt>
<dd class="truncate font-mono text-sm" title={ value }>{ value }</dd>
</div>
}
templ checkerCell(l CheckerLink) {
if l.URL != "" {
<a href={ templ.SafeURL(l.URL) } class="hover:underline">{ l.Label }</a>
} else {
<span class="text-muted">{ l.Label }</span>
}
}