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
@@ -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