Lightweight server monitoring with historical data, docker stats, and alerts.
consolidate migrations and add `triggeredDesc` for container health alert
henrygda4de2e87c445
diff --git a/internal/migrations/0_collections_snapshot_0_19_0_dev_2.go b/internal/migrations/0_collections_snapshot_0_19_0_dev_4.gosimilarity index 91%rename from internal/migrations/0_collections_snapshot_0_19_0_dev_2.gorename to internal/migrations/0_collections_snapshot_0_19_0_dev_4.goindex 54b4c7e21..73b89d2b5 100644--- a/internal/migrations/0_collections_snapshot_0_19_0_dev_2.go+++ b/internal/migrations/0_collections_snapshot_0_19_0_dev_4.go@@ -80,7 +80,10 @@ func init() {"LoadAvg5","LoadAvg15","Battery",- "ContainerHealth"+ "ContainerHealth",+ "SystemdFailed",+ "CPUIOWait",+ "CPUSteal"]},{@@ -1711,7 +1714,165 @@ func init() {"type": "base","updateRule": null,"viewRule": null- }+ },+ {+ "createRule": null,+ "deleteRule": null,+ "fields": [+ {+ "autogeneratePattern": "[a-z0-9]{15}",+ "hidden": false,+ "id": "text3208210256",+ "max": 15,+ "min": 15,+ "name": "id",+ "pattern": "^[a-z0-9]+$",+ "presentable": false,+ "primaryKey": true,+ "required": true,+ "system": true,+ "type": "text"+ },+ {+ "cascadeDelete": true,+ "collectionId": "2hz5ncl8tizk5nx",+ "hidden": false,+ "id": "relation1204987316",+ "maxSelect": 1,+ "minSelect": 0,+ "name": "system",+ "presentable": false,+ "required": true,+ "system": false,+ "type": "relation"+ },+ {+ "autogeneratePattern": "",+ "hidden": false,+ "id": "text7739291048",+ "max": 0,+ "min": 0,+ "name": "name",+ "pattern": "",+ "presentable": false,+ "primaryKey": false,+ "required": false,+ "system": false,+ "type": "text"+ },+ {+ "autogeneratePattern": "",+ "hidden": false,+ "id": "text5528164482",+ "max": 0,+ "min": 0,+ "name": "health",+ "pattern": "",+ "presentable": false,+ "primaryKey": false,+ "required": false,+ "system": false,+ "type": "text"+ },+ {+ "hidden": false,+ "id": "number8862034195",+ "max": null,+ "min": null,+ "name": "size",+ "onlyInt": true,+ "presentable": false,+ "required": false,+ "system": false,+ "type": "number"+ },+ {+ "hidden": false,+ "id": "number4418907321",+ "max": null,+ "min": null,+ "name": "alloc",+ "onlyInt": true,+ "presentable": false,+ "required": false,+ "system": false,+ "type": "number"+ },+ {+ "hidden": false,+ "id": "number2904183765",+ "max": null,+ "min": null,+ "name": "free",+ "onlyInt": true,+ "presentable": false,+ "required": false,+ "system": false,+ "type": "number"+ },+ {+ "hidden": false,+ "id": "json4466109723",+ "maxSize": 0,+ "name": "scrub",+ "presentable": false,+ "required": false,+ "system": false,+ "type": "json"+ },+ {+ "hidden": false,+ "id": "json9012873456",+ "maxSize": 0,+ "name": "vdevs",+ "presentable": false,+ "required": false,+ "system": false,+ "type": "json"+ },+ {+ "hidden": false,+ "id": "json7182045639",+ "maxSize": 0,+ "name": "datasets",+ "presentable": false,+ "required": false,+ "system": false,+ "type": "json"+ },+ {+ "hidden": false,+ "id": "date9274163058",+ "max": "",+ "min": "",+ "name": "details_updated",+ "presentable": false,+ "required": false,+ "system": false,+ "type": "date"+ },+ {+ "hidden": false,+ "id": "autodate3332085495",+ "name": "updated",+ "onCreate": true,+ "onUpdate": true,+ "presentable": false,+ "system": false,+ "type": "autodate"+ }+ ],+ "id": "pbc_8441057391",+ "indexes": [+ "CREATE INDEX ` + "`" + `idx_zfsPoolsSystem` + "`" + ` ON ` + "`" + `zfs_pools` + "`" + ` (` + "`" + `system` + "`" + `)"+ ],+ "listRule": null,+ "name": "zfs_pools",+ "system": false,+ "type": "base",+ "updateRule": null,+ "viewRule": null+ }]`err := app.ImportCollectionsByMarshaledJSON([]byte(jsonData), false)diff --git a/internal/migrations/1787356800_cpu_state_alerts.go b/internal/migrations/1787356800_cpu_state_alerts.godeleted file mode 100644index 706200362..000000000--- a/internal/migrations/1787356800_cpu_state_alerts.go+++ /dev/null@@ -1,36 +0,0 @@-package migrations--import (- "slices"-- "github.com/pocketbase/pocketbase/core"- m "github.com/pocketbase/pocketbase/migrations"-)--var cpuStateAlertNames = []string{"CPUIOWait", "CPUSteal"}--func init() {- m.Register(func(app core.App) error {- collection, err := app.FindCollectionByNameOrId("alerts")- if err != nil {- return err- }- field := collection.Fields.GetByName("name").(*core.SelectField)- for _, name := range cpuStateAlertNames {- if !slices.Contains(field.Values, name) {- field.Values = append(field.Values, name)- }- }- return app.Save(collection)- }, func(app core.App) error {- collection, err := app.FindCollectionByNameOrId("alerts")- if err != nil {- return err- }- field := collection.Fields.GetByName("name").(*core.SelectField)- field.Values = slices.DeleteFunc(field.Values, func(name string) bool {- return slices.Contains(cpuStateAlertNames, name)- })- return app.Save(collection)- })-}diff --git a/internal/migrations/1_add_systemd_failed_alert.go b/internal/migrations/1_add_systemd_failed_alert.godeleted file mode 100644index ca8f7810e..000000000--- a/internal/migrations/1_add_systemd_failed_alert.go+++ /dev/null@@ -1,44 +0,0 @@-package migrations--import (- "errors"- "slices"-- "github.com/pocketbase/pocketbase/core"- m "github.com/pocketbase/pocketbase/migrations"-)--// alertNameSystemdFailed is the alerts.name select value for the-// "failed systemd services" alert type.-const alertNameSystemdFailed = "SystemdFailed"--func init() {- m.Register(func(app core.App) error {- return updateAlertNameValues(app, func(values []string) []string {- if slices.Contains(values, alertNameSystemdFailed) {- return values- }- return append(values, alertNameSystemdFailed)- })- }, func(app core.App) error {- return updateAlertNameValues(app, func(values []string) []string {- return slices.DeleteFunc(values, func(value string) bool {- return value == alertNameSystemdFailed- })- })- })-}--// updateAlertNameValues applies fn to the values of the alerts.name select field and saves the collection.-func updateAlertNameValues(app core.App, fn func([]string) []string) error {- collection, err := app.FindCollectionByNameOrId("alerts")- if err != nil {- return err- }- field, ok := collection.Fields.GetByName("name").(*core.SelectField)- if !ok {- return errors.New("alerts.name is not a select field")- }- field.Values = fn(field.Values)- return app.Save(collection)-}diff --git a/internal/migrations/zfs_pools.go b/internal/migrations/zfs_pools.godeleted file mode 100644index a0c9c1bc9..000000000--- a/internal/migrations/zfs_pools.go+++ /dev/null@@ -1,184 +0,0 @@-package migrations--import (- "github.com/pocketbase/pocketbase/core"- m "github.com/pocketbase/pocketbase/migrations"-)--// Creates the zfs_pools collection for per-system ZFS pool detail data-// (pool health, capacity, scrub, vdevs, datasets). Upserts rather than-// deletes missing collections, so it is safe on fresh and existing installs.-func init() {- m.Register(func(app core.App) error {- // update collections- jsonData := `[- {- "createRule": null,- "deleteRule": null,- "fields": [- {- "autogeneratePattern": "[a-z0-9]{15}",- "hidden": false,- "id": "text3208210256",- "max": 15,- "min": 15,- "name": "id",- "pattern": "^[a-z0-9]+$",- "presentable": false,- "primaryKey": true,- "required": true,- "system": true,- "type": "text"- },- {- "cascadeDelete": true,- "collectionId": "2hz5ncl8tizk5nx",- "hidden": false,- "id": "relation1204987316",- "maxSelect": 1,- "minSelect": 0,- "name": "system",- "presentable": false,- "required": true,- "system": false,- "type": "relation"- },- {- "autogeneratePattern": "",- "hidden": false,- "id": "text7739291048",- "max": 0,- "min": 0,- "name": "name",- "pattern": "",- "presentable": false,- "primaryKey": false,- "required": false,- "system": false,- "type": "text"- },- {- "autogeneratePattern": "",- "hidden": false,- "id": "text5528164482",- "max": 0,- "min": 0,- "name": "health",- "pattern": "",- "presentable": false,- "primaryKey": false,- "required": false,- "system": false,- "type": "text"- },- {- "hidden": false,- "id": "number8862034195",- "max": null,- "min": null,- "name": "size",- "onlyInt": true,- "presentable": false,- "required": false,- "system": false,- "type": "number"- },- {- "hidden": false,- "id": "number4418907321",- "max": null,- "min": null,- "name": "alloc",- "onlyInt": true,- "presentable": false,- "required": false,- "system": false,- "type": "number"- },- {- "hidden": false,- "id": "number2904183765",- "max": null,- "min": null,- "name": "free",- "onlyInt": true,- "presentable": false,- "required": false,- "system": false,- "type": "number"- },- {- "hidden": false,- "id": "json4466109723",- "maxSize": 0,- "name": "scrub",- "presentable": false,- "required": false,- "system": false,- "type": "json"- },- {- "hidden": false,- "id": "json9012873456",- "maxSize": 0,- "name": "vdevs",- "presentable": false,- "required": false,- "system": false,- "type": "json"- },- {- "hidden": false,- "id": "json7182045639",- "maxSize": 0,- "name": "datasets",- "presentable": false,- "required": false,- "system": false,- "type": "json"- },- {- "hidden": false,- "id": "date9274163058",- "max": "",- "min": "",- "name": "details_updated",- "presentable": false,- "required": false,- "system": false,- "type": "date"- },- {- "hidden": false,- "id": "autodate3332085495",- "name": "updated",- "onCreate": true,- "onUpdate": true,- "presentable": false,- "system": false,- "type": "autodate"- }- ],- "id": "pbc_8441057391",- "indexes": [- "CREATE INDEX ` + "`" + `idx_zfsPoolsSystem` + "`" + ` ON ` + "`" + `zfs_pools` + "`" + ` (` + "`" + `system` + "`" + `)"- ],- "listRule": null,- "name": "zfs_pools",- "system": false,- "type": "base",- "updateRule": null,- "viewRule": null- }-]`-- err := app.ImportCollectionsByMarshaledJSON([]byte(jsonData), false)- if err != nil {- return err- }-- return nil- }, func(app core.App) error {- return nil- })-}diff --git a/internal/site/src/lib/alerts.ts b/internal/site/src/lib/alerts.tsindex 71ea0f88e..4196a1f28 100644--- a/internal/site/src/lib/alerts.ts+++ b/internal/site/src/lib/alerts.ts@@ -108,11 +108,10 @@ export const alertInfo: Record<string, AlertInfo> = {name: () => t`Container Health`,unit: "",icon: ContainerIcon,- desc: () => t`Triggers when a Docker container's health check reports unhealthy`,+ desc: () => t`Triggers when a container's health check reports unhealthy`,note: () =>t`Notifications may include recent container log excerpts.`,- /** "for x minutes" is appended to desc when only one value */- singleDesc: () => `${t`Container`} ${t`Unhealthy`}`,+ triggeredDesc: () => t`One or more containers are unhealthy`,},SystemdFailed: {name: () => t`Failed Services`,