A UPS in the map: read over NUT or SNMP, alerts, shutdown order
New UPS integration (NUT or SNMP v2c, read only). Monitoring -> UPS shows charge, runtime, load and mains voltage with history and the times mains power was lost. Mains lost and a nearly empty battery are critical alerts; battery to be replaced and a heavy load are warnings. The UPS is a node in the dependency map and counts as down while on battery, so servers that go offline with it are folded under its alert; the page lists what is on it in the order to shut it down. /metrics series and docs added. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3cb3e4988f
commit
232a5661ab
38 files changed
+8049
-16
No files matched your search
@@ -552,6 +552,7 @@ export const integrationTypes = [
|
||||
"unifi",
|
||||
"npm",
|
||||
"homeassistant",
|
||||
"ups",
|
||||
] as const;
|
||||
export type IntegrationType = (typeof integrationTypes)[number];
|
||||
|
||||
@@ -1158,6 +1159,48 @@ export const haReadings = sqliteTable(
|
||||
(t) => [index("ha_readings_lookup_idx").on(t.integrationId, t.entityId, t.at)],
|
||||
);
|
||||
|
||||
// ─── UPS ────────────────────────────────────────────────────────────────────
|
||||
|
||||
// How a UPS (an integration of type "ups", read over NUT or SNMP by services/upsSync.ts) is right now: one row each, replaced at every read. `updatedAt` is the last
|
||||
// read that worked; `onBatterySince` is when mains power was lost, kept until it is back.
|
||||
export const upsState = sqliteTable("ups_state", {
|
||||
integrationId: integer("integration_id")
|
||||
.primaryKey()
|
||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||
model: text("model"),
|
||||
manufacturer: text("manufacturer"),
|
||||
statusText: text("status_text").notNull(),
|
||||
onBattery: integer("on_battery", { mode: "boolean" }).notNull().default(false),
|
||||
lowBattery: integer("low_battery", { mode: "boolean" }).notNull().default(false),
|
||||
replaceBattery: integer("replace_battery", { mode: "boolean" }).notNull().default(false),
|
||||
overload: integer("overload", { mode: "boolean" }).notNull().default(false),
|
||||
charge: real("charge"),
|
||||
runtimeSeconds: integer("runtime_seconds"),
|
||||
loadPercent: real("load_percent"),
|
||||
inputVoltage: real("input_voltage"),
|
||||
outputVoltage: real("output_voltage"),
|
||||
onBatterySince: text("on_battery_since"), // ISO
|
||||
updatedAt: text("updated_at").notNull(), // ISO
|
||||
});
|
||||
|
||||
// A UPS at a moment, for the charts: one every five minutes, and every minute while it runs on battery. Kept 35 days.
|
||||
export const upsReadings = sqliteTable(
|
||||
"ups_readings",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
integrationId: integer("integration_id")
|
||||
.notNull()
|
||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||
at: text("at").notNull(), // ISO
|
||||
charge: real("charge"),
|
||||
runtimeSeconds: integer("runtime_seconds"),
|
||||
loadPercent: real("load_percent"),
|
||||
inputVoltage: real("input_voltage"),
|
||||
onBattery: integer("on_battery", { mode: "boolean" }).notNull().default(false),
|
||||
},
|
||||
(t) => [index("ups_readings_lookup_idx").on(t.integrationId, t.at)],
|
||||
);
|
||||
|
||||
// ─── Notes and the to-do list ───────────────────────────────────────────────
|
||||
|
||||
// Free-form notes about a server or a network device — what is it, where does it sit, what did I do to it last time — one text per thing, drawn with the same small
|
||||
|
||||
Reference in new issue
Block a user