Heartbeats, Coming up and suggested checks; Operations menu tidied
Heartbeats: a cron job or script calls /api/heartbeat/<token> (and /start, /fail); the app alerts when the call is late or the job says it failed. Coming up: one agenda of everything dated (expiries, warranties, end of support, planned and recurring maintenance, restore tests, waiting updates), with a dashboard card and an iCalendar feed behind a share link. Suggested checks: web ports and certificates the app already knows about, added with a click. Menu: Incidents become Alerts -> History (old /incidents links redirect); new Monitoring group (Endpoints, Heartbeats, Uptime Kuma); osTicket under Automation, Admin Links under Infrastructure, Generator under Administration. Also makes the restore-test metrics test follow the real clock. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c05c847d17
commit
4e0c6927b2
44 files changed
+7092
-75
No files matched your search
@@ -23,6 +23,7 @@ import StatusStrip from "../components/StatusStrip";
|
||||
import SetupGuide, { type SetupStep } from "../components/SetupGuide";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { WidgetSkeleton } from "../components/Skeleton";
|
||||
import type { Agenda, Heartbeat } from "../api/client";
|
||||
|
||||
const DNS_TYPE_COLORS: Record<string, string> = {
|
||||
A: "#60a5fa",
|
||||
@@ -364,6 +365,8 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
const [serverError, setServerError] = useState<string | null>(null);
|
||||
const [domainList, setDomainList] = useState<DomainList | null>(null);
|
||||
const [endpointChecks, setEndpointChecks] = useState<EndpointCheck[] | null>(null);
|
||||
const [agenda, setAgenda] = useState<Agenda | null>(null);
|
||||
const [heartbeatList, setHeartbeatList] = useState<Heartbeat[] | null>(null);
|
||||
const [domainError, setDomainError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -371,6 +374,14 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
.list()
|
||||
.then((res) => setEndpointChecks(res.checks))
|
||||
.catch(() => setEndpointChecks([]));
|
||||
api.agenda
|
||||
.get(30)
|
||||
.then(setAgenda)
|
||||
.catch(() => setAgenda({ generatedAt: "", today: "", items: [], notes: [] }));
|
||||
api.heartbeats
|
||||
.list()
|
||||
.then((res) => setHeartbeatList(res.heartbeats))
|
||||
.catch(() => setHeartbeatList([]));
|
||||
api.domains
|
||||
.list()
|
||||
.then(setDomainList)
|
||||
@@ -614,11 +625,28 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
const endpointsDown = (endpointChecks ?? []).filter((c) => c.enabled && c.lastOk === false && c.consecutiveFailures >= c.failuresBeforeAlert);
|
||||
const endpointCerts = (endpointChecks ?? []).filter((c) => c.enabled && c.certExpiresAt && Math.floor((Date.parse(c.certExpiresAt) - Date.now()) / 86_400_000) <= c.warnDays).length;
|
||||
|
||||
// What is coming up: the nearest dated things (not "updates waiting", which has its own card), and whether any has already passed.
|
||||
// A schedule that repeats weekly is one line (its next time), not one a week.
|
||||
const seenSchedules = new Set<string>();
|
||||
const soon = (agenda?.items ?? []).filter((i) => {
|
||||
if (i.kind === "updates") return false;
|
||||
const schedule = /^schedule:(\d+):/.exec(i.id)?.[1];
|
||||
if (!schedule) return true;
|
||||
if (seenSchedules.has(schedule)) return false;
|
||||
seenSchedules.add(schedule);
|
||||
return true;
|
||||
});
|
||||
const soonPast = soon.filter((i) => i.daysLeft < 0).length;
|
||||
const soonWeek = soon.filter((i) => i.daysLeft >= 0 && i.daysLeft <= 7).length;
|
||||
// The jobs that report in: late, or said they failed.
|
||||
const beatsWrong = (heartbeatList ?? []).filter((h) => h.state === "late" || h.state === "failed");
|
||||
|
||||
// What has nothing set up yet. These get one list at the bottom instead of a grey "Not configured" card each.
|
||||
const notSetUp: { label: string; to: string; what: string }[] = [];
|
||||
if (dnsStats?.totalProviders === 0) notSetUp.push({ label: "DNS", to: "/dns", what: "connect a DNS provider to see zones and records" });
|
||||
if (secrets !== null && totalSecrets === 0) notSetUp.push({ label: "Secrets", to: "/secrets", what: "track when a token, certificate or password expires" });
|
||||
if (serverSummary?.total === 0) notSetUp.push({ label: "Servers", to: "/servers", what: "add a server and install its agent" });
|
||||
if (heartbeatList !== null && heartbeatList.length === 0) notSetUp.push({ label: "Heartbeats", to: "/heartbeats", what: "have a backup or cron job report in, so you hear when it doesn't run" });
|
||||
if (endpointChecks !== null && endpointChecks.length === 0) notSetUp.push({ label: "Endpoints", to: "/endpoints", what: "ask a web address, a port or a certificate whether it is fine" });
|
||||
if (domainList !== null && domains.length === 0) notSetUp.push({ label: "Domains", to: "/domains", what: "appear after a DNS zone is added and the daily check has run" });
|
||||
if (integrations !== null) {
|
||||
@@ -984,6 +1012,80 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
</>
|
||||
)}
|
||||
</WidgetCard>
|
||||
|
||||
<WidgetCard
|
||||
label="Coming up"
|
||||
badge={
|
||||
!agenda ? undefined : soonPast > 0 ? (
|
||||
<span className="badge bg-red-lt text-red">{soonPast} past their date</span>
|
||||
) : soonWeek > 0 ? (
|
||||
<span className="badge bg-yellow-lt text-yellow">{soonWeek} this week</span>
|
||||
) : (
|
||||
<span className="badge bg-green-lt text-green">Nothing soon</span>
|
||||
)
|
||||
}
|
||||
>
|
||||
{!agenda ? (
|
||||
<WidgetSkeleton />
|
||||
) : soon.length === 0 ? (
|
||||
<div className="text-secondary small">Nothing expires, ends or is planned in the next 30 days.</div>
|
||||
) : (
|
||||
<>
|
||||
{soon.slice(0, 5).map((i) => (
|
||||
<div key={i.id} className="d-flex gap-2 small mb-1">
|
||||
<span className={`flex-shrink-0 ${i.daysLeft < 0 ? "text-red" : i.daysLeft <= 7 ? "text-yellow" : "text-secondary"}`} style={{ minWidth: "5.5rem" }}>
|
||||
{i.daysLeft === 0 ? "today" : i.daysLeft === 1 ? "tomorrow" : i.daysLeft === -1 ? "yesterday" : i.daysLeft > 0 ? `in ${i.daysLeft} days` : `${-i.daysLeft} days ago`}
|
||||
</span>
|
||||
<Link to={i.link} className="text-break">
|
||||
{i.title}
|
||||
</Link>
|
||||
</div>
|
||||
))}
|
||||
{soon.length > 5 && <div className="text-secondary small">+{soon.length - 5} more</div>}
|
||||
</>
|
||||
)}
|
||||
<div className="text-secondary small mt-2">
|
||||
<Link to="/coming-up">Everything coming up</Link>
|
||||
</div>
|
||||
</WidgetCard>
|
||||
|
||||
<WidgetCard
|
||||
label="Heartbeats"
|
||||
hide={heartbeatList !== null && heartbeatList.length === 0}
|
||||
badge={
|
||||
!heartbeatList ? undefined : beatsWrong.length > 0 ? (
|
||||
<span className="badge bg-red-lt text-red">{beatsWrong.length} not reporting</span>
|
||||
) : (
|
||||
<span className="badge bg-green-lt text-green">All reporting</span>
|
||||
)
|
||||
}
|
||||
>
|
||||
{!heartbeatList ? (
|
||||
<WidgetSkeleton />
|
||||
) : (
|
||||
<>
|
||||
<div className="row g-2 mb-3">
|
||||
<div className="col-4">
|
||||
<MiniStat label="Jobs" value={heartbeatList.filter((h) => h.enabled).length} />
|
||||
</div>
|
||||
<div className="col-4">
|
||||
<MiniStat label="On time" value={heartbeatList.filter((h) => h.state === "up" || h.state === "running").length} />
|
||||
</div>
|
||||
<div className="col-4">
|
||||
<MiniStat label="Late or failed" value={beatsWrong.length} accent={beatsWrong.length > 0 ? "#ef4444" : undefined} />
|
||||
</div>
|
||||
</div>
|
||||
{beatsWrong.slice(0, 3).map((h) => (
|
||||
<div key={h.id} className="text-red small">
|
||||
{h.name} — {h.state === "failed" ? `said it failed${h.lastMessage ? `: ${h.lastMessage}` : ""}` : "hasn't reported in time"}
|
||||
</div>
|
||||
))}
|
||||
<div className="text-secondary small mt-2">
|
||||
<Link to="/heartbeats">All heartbeats</Link>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</WidgetCard>
|
||||
</div>
|
||||
|
||||
<SectionHeader
|
||||
|
||||
Reference in new issue
Block a user