feat: disable automatic machine alert tickets
This commit is contained in:
parent
7951bc25a3
commit
ac986410a3
2 changed files with 21 additions and 3 deletions
|
|
@ -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}`
|
||||
|
|
|
|||
|
|
@ -534,6 +534,24 @@ const statusClasses: Record<string, string> = {
|
|||
unknown: "border-slate-300 bg-slate-200 text-slate-700",
|
||||
}
|
||||
|
||||
const POSTURE_ALERT_LABELS: Record<string, string> = {
|
||||
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) {
|
|||
<div key={`alert-${i}`} className={cn("flex items-center justify-between rounded-md border px-3 py-2 text-sm",
|
||||
(a?.severity ?? "warning").toLowerCase() === "critical" ? "border-rose-500/20 bg-rose-500/10" : "border-amber-500/20 bg-amber-500/10")
|
||||
}>
|
||||
<span className="font-medium text-foreground">{a?.message ?? a?.kind ?? "Alerta"}</span>
|
||||
<Badge variant="outline">{String(a?.kind ?? "ALERTA")}</Badge>
|
||||
<span className="font-medium text-foreground">{a?.message ?? formatPostureAlertKind(a?.kind)}</span>
|
||||
<Badge variant="outline">{formatPostureAlertKind(a?.kind)}</Badge>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue