diff --git a/convex/machines.ts b/convex/machines.ts index 8a7fefb..b7b89a8 100644 --- a/convex/machines.ts +++ b/convex/machines.ts @@ -349,7 +349,7 @@ async function evaluatePostureAndMaybeRaise( const lastAtPrev = ensureFiniteNumber(prevMeta?.["lastPostureAt"]) ?? 0 await ctx.db.patch(machine._id, { metadata: mergeMetadata(machine.metadata, record), updatedAt: now }) - if ((process.env["MACHINE_ALERTS_CREATE_TICKETS"] ?? "true").toLowerCase() !== "true") return + if ((process.env["MACHINE_ALERTS_CREATE_TICKETS"] ?? "false").toLowerCase() !== "true") return if (lastAtPrev && now - lastAtPrev < 30 * 60 * 1000) return const subject = `Alerta de máquina: ${machine.hostname}` diff --git a/src/components/admin/machines/admin-machines-overview.tsx b/src/components/admin/machines/admin-machines-overview.tsx index 0f097e2..819f97e 100644 --- a/src/components/admin/machines/admin-machines-overview.tsx +++ b/src/components/admin/machines/admin-machines-overview.tsx @@ -534,6 +534,24 @@ const statusClasses: Record = { unknown: "border-slate-300 bg-slate-200 text-slate-700", } +const POSTURE_ALERT_LABELS: Record = { + CPU_HIGH: "CPU alta", + SERVICE_DOWN: "Serviço indisponível", + SMART_FAIL: "Falha SMART", +} + +function formatPostureAlertKind(raw?: string | null): string { + if (!raw) return "Alerta" + const normalized = raw.toUpperCase() + if (POSTURE_ALERT_LABELS[normalized]) { + return POSTURE_ALERT_LABELS[normalized] + } + return raw + .toLowerCase() + .replace(/_/g, " ") + .replace(/\b\w/g, (char) => char.toUpperCase()) +} + function formatRelativeTime(date?: Date | null) { if (!date) return "Nunca" try { @@ -1833,8 +1851,8 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
- {a?.message ?? a?.kind ?? "Alerta"} - {String(a?.kind ?? "ALERTA")} + {a?.message ?? formatPostureAlertKind(a?.kind)} + {formatPostureAlertKind(a?.kind)}
))}