Host health from the Linux agent, agent self-update, and disk forecast in /metrics
- Linux agent v4: failed systemd services, SMART disk health, ZFS pool state, pacman updates; SMART/ZFS and self-update run in the ExecStartPre=-+ step outside the sandbox - Server: hosts' health stored (servers.host_health, migration 0029), alerts under a new "Failing services" kind plus disk/ZFS alerts, Host health card, Prometheus series - Agent self-update (Linux v4, Windows v3): admin switch on the Servers page, checksum-verified download, atomic replace; GET /api/agent/report/update - homelab_server_disk_days_to_full in /metrics - Tests (server, real PowerShell against a fake server) and docs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
540ab704b7
commit
5dc6cea69c
38 files changed
+3884
-73
No files matched your search
@@ -24,6 +24,7 @@ const SEVERITY: Record<AlertSeverity, { label: string; badge: string; rank: numb
|
||||
const CATEGORY_LABELS: Record<AlertCategory, string> = {
|
||||
offline: "Server down",
|
||||
disk: "Disk & storage",
|
||||
services: "Failing services",
|
||||
backup: "Backups",
|
||||
updates: "Updates",
|
||||
expiry: "Expiry",
|
||||
|
||||
@@ -18,6 +18,7 @@ import ServerActivity from "../components/ServerActivity";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import UptimeRibbon from "../components/UptimeRibbon";
|
||||
import RunsOn from "../components/RunsOn";
|
||||
import HostHealthCard from "../components/HostHealthCard";
|
||||
import RunPlaybook from "../components/RunPlaybook";
|
||||
import RunbookPanel from "../components/RunbookPanel";
|
||||
import UpdatesBadge from "../components/UpdatesBadge";
|
||||
@@ -783,7 +784,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
||||
<dd className="col-7">
|
||||
{agentVersionWords(server.agentVersion)}{" "}
|
||||
{agentState(server, detail.agentLatest) === "behind" ? (
|
||||
<span className="badge bg-yellow-lt text-yellow" title="Run its install command again to update it (Servers → Manage servers).">
|
||||
<span className="badge bg-yellow-lt text-yellow" title="Run its install command again to update it (Servers → Manage servers), or switch on automatic agent updates on the Servers page.">
|
||||
update available
|
||||
</span>
|
||||
) : (
|
||||
@@ -807,6 +808,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<HostHealthCard health={server.hostHealth} />
|
||||
{hardware.source === "agent" && <ServerTrends serverId={serverId} />}
|
||||
{(user.role === "admin" || user.role === "operator") && <ServerActivity serverId={serverId} />}
|
||||
<div className="card mb-3">
|
||||
|
||||
@@ -16,6 +16,7 @@ import { tagBadge, useTagColors } from "../utils/tags";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
import SaveViewButton from "../components/SaveViewButton";
|
||||
@@ -36,6 +37,8 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
// Until the first answer arrives there is nothing to say about "no servers", so show the page's shape instead of the empty message.
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [agentLatest, setAgentLatest] = useState<AgentLatest | null>(null);
|
||||
// Whether agents that are behind replace themselves (an administrator's switch).
|
||||
const [autoUpdate, setAutoUpdate] = useState<boolean | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [managingServers, setManagingServers] = useState(false);
|
||||
const [integrationColors, setIntegrationColors] = useState<Record<string, string>>({});
|
||||
@@ -76,6 +79,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
.then((res) => {
|
||||
setServers(res.servers);
|
||||
setAgentLatest(res.agentLatest);
|
||||
setAutoUpdate(res.agentAutoUpdate);
|
||||
})
|
||||
.catch((err) => setError(String(err)))
|
||||
.finally(() => setLoaded(true));
|
||||
@@ -85,6 +89,17 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
loadServers();
|
||||
}, [loadServers]);
|
||||
|
||||
async function changeAutoUpdate(value: boolean) {
|
||||
setAutoUpdate(value);
|
||||
try {
|
||||
await api.servers.setAgentAutoUpdate(value);
|
||||
toast.success(value ? "Agents that are behind will update themselves at their next run." : "Agents will no longer update themselves.");
|
||||
} catch (err) {
|
||||
setAutoUpdate(!value);
|
||||
toast.error(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
async function createServer(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
@@ -245,6 +260,21 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{isAdmin && autoUpdate !== null && servers.length > 0 && (
|
||||
<div className="card mb-3">
|
||||
<div className="card-body py-2">
|
||||
<label className="form-check form-switch mb-0">
|
||||
<input className="form-check-input" type="checkbox" checked={autoUpdate} onChange={(e) => void changeAutoUpdate(e.target.checked)} />
|
||||
<span className="form-check-label">Update agents automatically</span>
|
||||
</label>
|
||||
<div className="text-secondary small mt-1">
|
||||
An agent that is behind this app downloads the newer script from here, checks it against a checksum the server gives, and replaces itself at its next run. Off by default. An agent needs the
|
||||
update code to use it (Linux version 4 or later, Windows 3 or later); an older one needs its install command run once (Manage servers).
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{managingServers ? (
|
||||
<>
|
||||
<div className="card mb-3">
|
||||
|
||||
Reference in new issue
Block a user