feat(checks): vm-status probe + matrix cert dial-by-name
VMs declared monitoring [ping], but many block ICMP and lack a guest agent (haos), so ping was the wrong probe — a powered-on VM reported "down". Add a vm-status check: `qm status <pve_id>` on the VM's Proxmox host, which tests "powered on" without needing the VM's network at all. vm type monitoring is now [vm-status]. matrix.hubris.network is a public hostname (federation) resolving to netbird-vps, not served by the lab Caddy — so its cert-expiry check's dial=caddy IP failed. Drop the dial for matrix; it dials by name (DNS -> public) like wget already proved works.
This commit is contained in:
@@ -291,6 +291,8 @@ func executeCheck(ctx context.Context, pool *db.Pool, cd sqlcgen.ListEnabledChec
|
||||
return checkDisk(ctx, cd)
|
||||
case "cert-expiry":
|
||||
return checkCertExpiry(ctx, cd)
|
||||
case "vm-status":
|
||||
return checkVMStatus(ctx, pool, cd)
|
||||
case "ping":
|
||||
return checkPing(ctx, cd)
|
||||
case "ssh-script":
|
||||
@@ -613,6 +615,53 @@ func checkCertExpiry(ctx context.Context, cd sqlcgen.ListEnabledCheckDefsRow) ch
|
||||
return checkResult{health: "healthy", metrics: metrics}
|
||||
}
|
||||
|
||||
// checkVMStatus reports whether a VM is powered on, via `qm status <pve_id>`
|
||||
// run on its Proxmox host. This is the right reachability probe for a VM that
|
||||
// blocks ICMP (haos) and has no guest agent: it doesn't need the VM's network
|
||||
// at all — "status: running" means the VM is up. The command runs on the host
|
||||
// (not inside the VM), so it uses the host's address with identity wrap.
|
||||
func checkVMStatus(ctx context.Context, pool *db.Pool, cd sqlcgen.ListEnabledCheckDefsRow) checkResult {
|
||||
if cd.TargetID == nil {
|
||||
return checkResult{health: "unknown", evidence: "vm-status needs a target VM"}
|
||||
}
|
||||
var pveID, hostAttr string
|
||||
if err := pool.QueryRow(ctx,
|
||||
"SELECT attributes->>'pve_id', COALESCE(attributes->>'host','') FROM entities WHERE id = $1",
|
||||
*cd.TargetID).Scan(&pveID, &hostAttr); err != nil || pveID == "" {
|
||||
return checkResult{health: "unknown", signalKind: "vm-status",
|
||||
evidence: fmt.Sprintf("vm %s has no pve_id", cd.EntitySlug)}
|
||||
}
|
||||
hostSlug := remote.ResolveProxmoxHostSlug(ctx, pool, *cd.TargetID, hostAttr)
|
||||
addr, user, err := remote.ResolveHost(ctx, pool, hostSlug, sshUser)
|
||||
if err != nil {
|
||||
return checkResult{health: "down", signalKind: "vm-status",
|
||||
evidence: fmt.Sprintf("resolve proxmox host for %s: %v", cd.EntitySlug, err), err: err}
|
||||
}
|
||||
|
||||
timeout := time.Duration(cd.TimeoutS) * time.Second
|
||||
if timeout <= 0 {
|
||||
timeout = 15 * time.Second
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
|
||||
out, err := sshExec(ctx, addr, "22", user, "qm status "+pveID, timeout)
|
||||
if err != nil {
|
||||
return checkResult{health: "down", signalKind: "vm-status",
|
||||
evidence: fmt.Sprintf("qm status %s on %s: %v", pveID, addr, err), err: err}
|
||||
}
|
||||
// `qm status <id>` prints "status: running" (or stopped/paused).
|
||||
if strings.Contains(string(out), "status: running") {
|
||||
return checkResult{health: "healthy"}
|
||||
}
|
||||
trimmed := strings.TrimSpace(string(out))
|
||||
if trimmed == "" {
|
||||
trimmed = "(no output)"
|
||||
}
|
||||
return checkResult{health: "down", signalKind: "vm-status",
|
||||
evidence: fmt.Sprintf("%s not running: %s", cd.EntitySlug, trimmed)}
|
||||
}
|
||||
|
||||
// checkPing performs an ICMP ping check using the system ping command.
|
||||
func checkPing(ctx context.Context, cd sqlcgen.ListEnabledCheckDefsRow) checkResult {
|
||||
cfg := struct {
|
||||
|
||||
Reference in New Issue
Block a user