@sonde/packs 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test.log +53 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +19 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/citrix.d.ts +13 -0
- package/dist/integrations/citrix.d.ts.map +1 -0
- package/dist/integrations/citrix.js +415 -0
- package/dist/integrations/citrix.js.map +1 -0
- package/dist/integrations/citrix.test.d.ts +2 -0
- package/dist/integrations/citrix.test.d.ts.map +1 -0
- package/dist/integrations/citrix.test.js +464 -0
- package/dist/integrations/citrix.test.js.map +1 -0
- package/dist/integrations/graph.d.ts +9 -0
- package/dist/integrations/graph.d.ts.map +1 -0
- package/dist/integrations/graph.js +285 -0
- package/dist/integrations/graph.js.map +1 -0
- package/dist/integrations/graph.test.d.ts +2 -0
- package/dist/integrations/graph.test.d.ts.map +1 -0
- package/dist/integrations/graph.test.js +356 -0
- package/dist/integrations/graph.test.js.map +1 -0
- package/dist/integrations/httpbin.d.ts +3 -0
- package/dist/integrations/httpbin.d.ts.map +1 -0
- package/dist/integrations/httpbin.js +65 -0
- package/dist/integrations/httpbin.js.map +1 -0
- package/dist/integrations/nutanix.d.ts +18 -0
- package/dist/integrations/nutanix.d.ts.map +1 -0
- package/dist/integrations/nutanix.js +1116 -0
- package/dist/integrations/nutanix.js.map +1 -0
- package/dist/integrations/nutanix.test.d.ts +2 -0
- package/dist/integrations/nutanix.test.d.ts.map +1 -0
- package/dist/integrations/nutanix.test.js +978 -0
- package/dist/integrations/nutanix.test.js.map +1 -0
- package/dist/integrations/proxmox.d.ts +12 -0
- package/dist/integrations/proxmox.d.ts.map +1 -0
- package/dist/integrations/proxmox.js +728 -0
- package/dist/integrations/proxmox.js.map +1 -0
- package/dist/integrations/proxmox.test.d.ts +2 -0
- package/dist/integrations/proxmox.test.d.ts.map +1 -0
- package/dist/integrations/proxmox.test.js +697 -0
- package/dist/integrations/proxmox.test.js.map +1 -0
- package/dist/integrations/servicenow.d.ts +3 -0
- package/dist/integrations/servicenow.d.ts.map +1 -0
- package/dist/integrations/servicenow.js +251 -0
- package/dist/integrations/servicenow.js.map +1 -0
- package/dist/integrations/servicenow.test.d.ts +2 -0
- package/dist/integrations/servicenow.test.d.ts.map +1 -0
- package/dist/integrations/servicenow.test.js +217 -0
- package/dist/integrations/servicenow.test.js.map +1 -0
- package/dist/integrations/splunk.d.ts +9 -0
- package/dist/integrations/splunk.d.ts.map +1 -0
- package/dist/integrations/splunk.js +237 -0
- package/dist/integrations/splunk.js.map +1 -0
- package/dist/integrations/splunk.test.d.ts +2 -0
- package/dist/integrations/splunk.test.d.ts.map +1 -0
- package/dist/integrations/splunk.test.js +323 -0
- package/dist/integrations/splunk.test.js.map +1 -0
- package/dist/mysql/index.d.ts +3 -0
- package/dist/mysql/index.d.ts.map +1 -0
- package/dist/mysql/index.js +13 -0
- package/dist/mysql/index.js.map +1 -0
- package/dist/mysql/manifest.d.ts +3 -0
- package/dist/mysql/manifest.d.ts.map +1 -0
- package/dist/mysql/manifest.js +69 -0
- package/dist/mysql/manifest.js.map +1 -0
- package/dist/mysql/probes/databases-list.d.ts +13 -0
- package/dist/mysql/probes/databases-list.d.ts.map +1 -0
- package/dist/mysql/probes/databases-list.js +31 -0
- package/dist/mysql/probes/databases-list.js.map +1 -0
- package/dist/mysql/probes/databases-list.test.d.ts +2 -0
- package/dist/mysql/probes/databases-list.test.d.ts.map +1 -0
- package/dist/mysql/probes/databases-list.test.js +54 -0
- package/dist/mysql/probes/databases-list.test.js.map +1 -0
- package/dist/mysql/probes/processlist.d.ts +18 -0
- package/dist/mysql/probes/processlist.d.ts.map +1 -0
- package/dist/mysql/probes/processlist.js +36 -0
- package/dist/mysql/probes/processlist.js.map +1 -0
- package/dist/mysql/probes/processlist.test.d.ts +2 -0
- package/dist/mysql/probes/processlist.test.d.ts.map +1 -0
- package/dist/mysql/probes/processlist.test.js +41 -0
- package/dist/mysql/probes/processlist.test.js.map +1 -0
- package/dist/mysql/probes/status.d.ts +14 -0
- package/dist/mysql/probes/status.d.ts.map +1 -0
- package/dist/mysql/probes/status.js +40 -0
- package/dist/mysql/probes/status.js.map +1 -0
- package/dist/mysql/probes/status.test.d.ts +2 -0
- package/dist/mysql/probes/status.test.d.ts.map +1 -0
- package/dist/mysql/probes/status.test.js +43 -0
- package/dist/mysql/probes/status.test.js.map +1 -0
- package/dist/nginx/index.d.ts +3 -0
- package/dist/nginx/index.d.ts.map +1 -0
- package/dist/nginx/index.js +13 -0
- package/dist/nginx/index.js.map +1 -0
- package/dist/nginx/manifest.d.ts +3 -0
- package/dist/nginx/manifest.d.ts.map +1 -0
- package/dist/nginx/manifest.js +68 -0
- package/dist/nginx/manifest.js.map +1 -0
- package/dist/nginx/probes/access-log-tail.d.ts +9 -0
- package/dist/nginx/probes/access-log-tail.d.ts.map +1 -0
- package/dist/nginx/probes/access-log-tail.js +14 -0
- package/dist/nginx/probes/access-log-tail.js.map +1 -0
- package/dist/nginx/probes/access-log-tail.test.d.ts +2 -0
- package/dist/nginx/probes/access-log-tail.test.d.ts.map +1 -0
- package/dist/nginx/probes/access-log-tail.test.js +40 -0
- package/dist/nginx/probes/access-log-tail.test.js.map +1 -0
- package/dist/nginx/probes/config-test.d.ts +8 -0
- package/dist/nginx/probes/config-test.d.ts.map +1 -0
- package/dist/nginx/probes/config-test.js +18 -0
- package/dist/nginx/probes/config-test.js.map +1 -0
- package/dist/nginx/probes/config-test.test.d.ts +2 -0
- package/dist/nginx/probes/config-test.test.d.ts.map +1 -0
- package/dist/nginx/probes/config-test.test.js +35 -0
- package/dist/nginx/probes/config-test.test.js.map +1 -0
- package/dist/nginx/probes/error-log-tail.d.ts +9 -0
- package/dist/nginx/probes/error-log-tail.d.ts.map +1 -0
- package/dist/nginx/probes/error-log-tail.js +14 -0
- package/dist/nginx/probes/error-log-tail.js.map +1 -0
- package/dist/nginx/probes/error-log-tail.test.d.ts +2 -0
- package/dist/nginx/probes/error-log-tail.test.d.ts.map +1 -0
- package/dist/nginx/probes/error-log-tail.test.js +34 -0
- package/dist/nginx/probes/error-log-tail.test.js.map +1 -0
- package/dist/postgres/index.d.ts +3 -0
- package/dist/postgres/index.d.ts.map +1 -0
- package/dist/postgres/index.js +13 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/postgres/manifest.d.ts +3 -0
- package/dist/postgres/manifest.d.ts.map +1 -0
- package/dist/postgres/manifest.js +90 -0
- package/dist/postgres/manifest.js.map +1 -0
- package/dist/postgres/probes/connections-active.d.ts +17 -0
- package/dist/postgres/probes/connections-active.d.ts.map +1 -0
- package/dist/postgres/probes/connections-active.js +37 -0
- package/dist/postgres/probes/connections-active.js.map +1 -0
- package/dist/postgres/probes/connections-active.test.d.ts +2 -0
- package/dist/postgres/probes/connections-active.test.d.ts.map +1 -0
- package/dist/postgres/probes/connections-active.test.js +36 -0
- package/dist/postgres/probes/connections-active.test.js.map +1 -0
- package/dist/postgres/probes/databases-list.d.ts +14 -0
- package/dist/postgres/probes/databases-list.d.ts.map +1 -0
- package/dist/postgres/probes/databases-list.js +34 -0
- package/dist/postgres/probes/databases-list.js.map +1 -0
- package/dist/postgres/probes/databases-list.test.d.ts +2 -0
- package/dist/postgres/probes/databases-list.test.d.ts.map +1 -0
- package/dist/postgres/probes/databases-list.test.js +49 -0
- package/dist/postgres/probes/databases-list.test.js.map +1 -0
- package/dist/postgres/probes/query-slow.d.ts +17 -0
- package/dist/postgres/probes/query-slow.d.ts.map +1 -0
- package/dist/postgres/probes/query-slow.js +37 -0
- package/dist/postgres/probes/query-slow.js.map +1 -0
- package/dist/postgres/probes/query-slow.test.d.ts +2 -0
- package/dist/postgres/probes/query-slow.test.d.ts.map +1 -0
- package/dist/postgres/probes/query-slow.test.js +30 -0
- package/dist/postgres/probes/query-slow.test.js.map +1 -0
- package/dist/proxmox/index.d.ts +3 -0
- package/dist/proxmox/index.d.ts.map +1 -0
- package/dist/proxmox/index.js +23 -0
- package/dist/proxmox/index.js.map +1 -0
- package/dist/proxmox/manifest.d.ts +3 -0
- package/dist/proxmox/manifest.d.ts.map +1 -0
- package/dist/proxmox/manifest.js +75 -0
- package/dist/proxmox/manifest.js.map +1 -0
- package/dist/proxmox/probes/ceph-status.d.ts +36 -0
- package/dist/proxmox/probes/ceph-status.d.ts.map +1 -0
- package/dist/proxmox/probes/ceph-status.js +71 -0
- package/dist/proxmox/probes/ceph-status.js.map +1 -0
- package/dist/proxmox/probes/ceph-status.test.d.ts +2 -0
- package/dist/proxmox/probes/ceph-status.test.d.ts.map +1 -0
- package/dist/proxmox/probes/ceph-status.test.js +115 -0
- package/dist/proxmox/probes/ceph-status.test.js.map +1 -0
- package/dist/proxmox/probes/cluster-config.d.ts +31 -0
- package/dist/proxmox/probes/cluster-config.d.ts.map +1 -0
- package/dist/proxmox/probes/cluster-config.js +72 -0
- package/dist/proxmox/probes/cluster-config.js.map +1 -0
- package/dist/proxmox/probes/cluster-config.test.d.ts +2 -0
- package/dist/proxmox/probes/cluster-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/cluster-config.test.js +107 -0
- package/dist/proxmox/probes/cluster-config.test.js.map +1 -0
- package/dist/proxmox/probes/ha-status.d.ts +18 -0
- package/dist/proxmox/probes/ha-status.d.ts.map +1 -0
- package/dist/proxmox/probes/ha-status.js +38 -0
- package/dist/proxmox/probes/ha-status.js.map +1 -0
- package/dist/proxmox/probes/ha-status.test.d.ts +2 -0
- package/dist/proxmox/probes/ha-status.test.d.ts.map +1 -0
- package/dist/proxmox/probes/ha-status.test.js +66 -0
- package/dist/proxmox/probes/ha-status.test.js.map +1 -0
- package/dist/proxmox/probes/lvm.d.ts +35 -0
- package/dist/proxmox/probes/lvm.d.ts.map +1 -0
- package/dist/proxmox/probes/lvm.js +75 -0
- package/dist/proxmox/probes/lvm.js.map +1 -0
- package/dist/proxmox/probes/lvm.test.d.ts +2 -0
- package/dist/proxmox/probes/lvm.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lvm.test.js +128 -0
- package/dist/proxmox/probes/lvm.test.js.map +1 -0
- package/dist/proxmox/probes/lxc-config.d.ts +29 -0
- package/dist/proxmox/probes/lxc-config.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-config.js +67 -0
- package/dist/proxmox/probes/lxc-config.js.map +1 -0
- package/dist/proxmox/probes/lxc-config.test.d.ts +2 -0
- package/dist/proxmox/probes/lxc-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-config.test.js +77 -0
- package/dist/proxmox/probes/lxc-config.test.js.map +1 -0
- package/dist/proxmox/probes/lxc-list.d.ts +20 -0
- package/dist/proxmox/probes/lxc-list.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-list.js +49 -0
- package/dist/proxmox/probes/lxc-list.js.map +1 -0
- package/dist/proxmox/probes/lxc-list.test.d.ts +2 -0
- package/dist/proxmox/probes/lxc-list.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-list.test.js +51 -0
- package/dist/proxmox/probes/lxc-list.test.js.map +1 -0
- package/dist/proxmox/probes/vm-config.d.ts +21 -0
- package/dist/proxmox/probes/vm-config.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-config.js +58 -0
- package/dist/proxmox/probes/vm-config.js.map +1 -0
- package/dist/proxmox/probes/vm-config.test.d.ts +2 -0
- package/dist/proxmox/probes/vm-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-config.test.js +80 -0
- package/dist/proxmox/probes/vm-config.test.js.map +1 -0
- package/dist/proxmox/probes/vm-locks.d.ts +16 -0
- package/dist/proxmox/probes/vm-locks.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-locks.js +35 -0
- package/dist/proxmox/probes/vm-locks.js.map +1 -0
- package/dist/proxmox/probes/vm-locks.test.d.ts +2 -0
- package/dist/proxmox/probes/vm-locks.test.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-locks.test.js +54 -0
- package/dist/proxmox/probes/vm-locks.test.js.map +1 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +13 -0
- package/dist/redis/index.js.map +1 -0
- package/dist/redis/manifest.d.ts +3 -0
- package/dist/redis/manifest.d.ts.map +1 -0
- package/dist/redis/manifest.js +51 -0
- package/dist/redis/manifest.js.map +1 -0
- package/dist/redis/probes/info.d.ts +15 -0
- package/dist/redis/probes/info.d.ts.map +1 -0
- package/dist/redis/probes/info.js +32 -0
- package/dist/redis/probes/info.js.map +1 -0
- package/dist/redis/probes/info.test.d.ts +2 -0
- package/dist/redis/probes/info.test.d.ts.map +1 -0
- package/dist/redis/probes/info.test.js +64 -0
- package/dist/redis/probes/info.test.js.map +1 -0
- package/dist/redis/probes/keys-count.d.ts +13 -0
- package/dist/redis/probes/keys-count.d.ts.map +1 -0
- package/dist/redis/probes/keys-count.js +24 -0
- package/dist/redis/probes/keys-count.js.map +1 -0
- package/dist/redis/probes/keys-count.test.d.ts +2 -0
- package/dist/redis/probes/keys-count.test.d.ts.map +1 -0
- package/dist/redis/probes/keys-count.test.js +37 -0
- package/dist/redis/probes/keys-count.test.js.map +1 -0
- package/dist/redis/probes/memory-usage.d.ts +16 -0
- package/dist/redis/probes/memory-usage.d.ts.map +1 -0
- package/dist/redis/probes/memory-usage.js +31 -0
- package/dist/redis/probes/memory-usage.js.map +1 -0
- package/dist/redis/probes/memory-usage.test.d.ts +2 -0
- package/dist/redis/probes/memory-usage.test.d.ts.map +1 -0
- package/dist/redis/probes/memory-usage.test.js +48 -0
- package/dist/redis/probes/memory-usage.test.js.map +1 -0
- package/dist/runbooks/nutanix.d.ts +3 -0
- package/dist/runbooks/nutanix.d.ts.map +1 -0
- package/dist/runbooks/nutanix.js +619 -0
- package/dist/runbooks/nutanix.js.map +1 -0
- package/dist/runbooks/nutanix.test.d.ts +2 -0
- package/dist/runbooks/nutanix.test.d.ts.map +1 -0
- package/dist/runbooks/nutanix.test.js +971 -0
- package/dist/runbooks/nutanix.test.js.map +1 -0
- package/dist/runbooks/proxmox.d.ts +3 -0
- package/dist/runbooks/proxmox.d.ts.map +1 -0
- package/dist/runbooks/proxmox.js +451 -0
- package/dist/runbooks/proxmox.js.map +1 -0
- package/dist/runbooks/proxmox.test.d.ts +2 -0
- package/dist/runbooks/proxmox.test.d.ts.map +1 -0
- package/dist/runbooks/proxmox.test.js +700 -0
- package/dist/runbooks/proxmox.test.js.map +1 -0
- package/dist/signatures.d.ts +2 -0
- package/dist/signatures.d.ts.map +1 -0
- package/dist/signatures.js +2 -0
- package/dist/signatures.js.map +1 -0
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +2 -0
- package/dist/system/index.js.map +1 -1
- package/dist/system/manifest.d.ts.map +1 -1
- package/dist/system/manifest.js +19 -1
- package/dist/system/manifest.js.map +1 -1
- package/dist/system/probes/ping.d.ts +20 -0
- package/dist/system/probes/ping.d.ts.map +1 -0
- package/dist/system/probes/ping.js +54 -0
- package/dist/system/probes/ping.js.map +1 -0
- package/dist/system/probes/ping.test.d.ts +2 -0
- package/dist/system/probes/ping.test.d.ts.map +1 -0
- package/dist/system/probes/ping.test.js +127 -0
- package/dist/system/probes/ping.test.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +6 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +10 -1
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +60 -6
- package/src/integrations/citrix.test.ts +592 -0
- package/src/integrations/citrix.ts +553 -0
- package/src/integrations/graph.test.ts +478 -0
- package/src/integrations/graph.ts +409 -0
- package/src/integrations/httpbin.ts +68 -0
- package/src/integrations/nutanix.test.ts +1508 -0
- package/src/integrations/nutanix.ts +1456 -0
- package/src/integrations/proxmox.test.ts +1020 -0
- package/src/integrations/proxmox.ts +985 -0
- package/src/integrations/servicenow.test.ts +314 -0
- package/src/integrations/servicenow.ts +280 -0
- package/src/integrations/splunk.test.ts +440 -0
- package/src/integrations/splunk.ts +352 -0
- package/src/mysql/index.ts +14 -0
- package/src/mysql/manifest.ts +70 -0
- package/src/mysql/probes/databases-list.test.ts +62 -0
- package/src/mysql/probes/databases-list.ts +45 -0
- package/src/mysql/probes/processlist.test.ts +47 -0
- package/src/mysql/probes/processlist.ts +55 -0
- package/src/mysql/probes/status.test.ts +50 -0
- package/src/mysql/probes/status.ts +56 -0
- package/src/nginx/index.ts +14 -0
- package/src/nginx/manifest.ts +69 -0
- package/src/nginx/probes/access-log-tail.test.ts +51 -0
- package/src/nginx/probes/access-log-tail.ts +23 -0
- package/src/nginx/probes/config-test.test.ts +47 -0
- package/src/nginx/probes/config-test.ts +24 -0
- package/src/nginx/probes/error-log-tail.test.ts +44 -0
- package/src/nginx/probes/error-log-tail.ts +23 -0
- package/src/postgres/index.ts +14 -0
- package/src/postgres/manifest.ts +91 -0
- package/src/postgres/probes/connections-active.test.ts +42 -0
- package/src/postgres/probes/connections-active.ts +55 -0
- package/src/postgres/probes/databases-list.test.ts +57 -0
- package/src/postgres/probes/databases-list.ts +49 -0
- package/src/postgres/probes/query-slow.test.ts +37 -0
- package/src/postgres/probes/query-slow.ts +55 -0
- package/src/proxmox/index.ts +24 -0
- package/src/proxmox/manifest.ts +76 -0
- package/src/proxmox/probes/ceph-status.test.ts +126 -0
- package/src/proxmox/probes/ceph-status.ts +116 -0
- package/src/proxmox/probes/cluster-config.test.ts +118 -0
- package/src/proxmox/probes/cluster-config.ts +97 -0
- package/src/proxmox/probes/ha-status.test.ts +76 -0
- package/src/proxmox/probes/ha-status.ts +56 -0
- package/src/proxmox/probes/lvm.test.ts +140 -0
- package/src/proxmox/probes/lvm.ts +121 -0
- package/src/proxmox/probes/lxc-config.test.ts +89 -0
- package/src/proxmox/probes/lxc-config.ts +90 -0
- package/src/proxmox/probes/lxc-list.test.ts +60 -0
- package/src/proxmox/probes/lxc-list.ts +67 -0
- package/src/proxmox/probes/vm-config.test.ts +93 -0
- package/src/proxmox/probes/vm-config.ts +77 -0
- package/src/proxmox/probes/vm-locks.test.ts +63 -0
- package/src/proxmox/probes/vm-locks.ts +49 -0
- package/src/redis/index.ts +14 -0
- package/src/redis/manifest.ts +52 -0
- package/src/redis/probes/info.test.ts +73 -0
- package/src/redis/probes/info.ts +46 -0
- package/src/redis/probes/keys-count.test.ts +44 -0
- package/src/redis/probes/keys-count.ts +38 -0
- package/src/redis/probes/memory-usage.test.ts +54 -0
- package/src/redis/probes/memory-usage.ts +46 -0
- package/src/runbooks/nutanix.test.ts +1138 -0
- package/src/runbooks/nutanix.ts +941 -0
- package/src/runbooks/proxmox.test.ts +838 -0
- package/src/runbooks/proxmox.ts +626 -0
- package/src/signatures.ts +1 -0
- package/src/system/index.ts +2 -0
- package/src/system/manifest.ts +21 -1
- package/src/system/probes/ping.test.ts +163 -0
- package/src/system/probes/ping.ts +89 -0
- package/src/types.ts +62 -0
- package/src/validation.ts +21 -1
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import type { RunProbe, RunbookContext, RunbookProbeResult } from '../types.js';
|
|
3
|
+
import { proxmoxDiagnosticRunbooks } from './proxmox.js';
|
|
4
|
+
|
|
5
|
+
// --- Test helpers ---
|
|
6
|
+
|
|
7
|
+
function getHandler(category: string) {
|
|
8
|
+
const def = proxmoxDiagnosticRunbooks.find((r) => r.category === category);
|
|
9
|
+
if (!def) throw new Error(`No runbook for category "${category}"`);
|
|
10
|
+
return def.handler;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function mockResult(
|
|
14
|
+
probe: string,
|
|
15
|
+
data: unknown,
|
|
16
|
+
status: 'success' | 'error' | 'timeout' = 'success',
|
|
17
|
+
error?: string,
|
|
18
|
+
): RunbookProbeResult {
|
|
19
|
+
return { probe, status, data, durationMs: 10, error };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Create a mock runProbe that returns canned data keyed by probe name */
|
|
23
|
+
function createMockRunProbe(
|
|
24
|
+
responses: Record<
|
|
25
|
+
string,
|
|
26
|
+
{ data?: unknown; status?: 'success' | 'error' | 'timeout'; error?: string }
|
|
27
|
+
>,
|
|
28
|
+
): RunProbe {
|
|
29
|
+
return async (probe: string, _params?: Record<string, unknown>, _agent?: string) => {
|
|
30
|
+
const key = probe;
|
|
31
|
+
const response = responses[key];
|
|
32
|
+
if (!response) {
|
|
33
|
+
return mockResult(probe, undefined, 'error', `No mock for probe ${probe}`);
|
|
34
|
+
}
|
|
35
|
+
return mockResult(probe, response.data, response.status ?? 'success', response.error);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const defaultContext: RunbookContext = { connectedAgents: [] };
|
|
40
|
+
|
|
41
|
+
// --- Healthy cluster data fixtures ---
|
|
42
|
+
|
|
43
|
+
const healthyClusterStatus = {
|
|
44
|
+
clusterName: 'prod',
|
|
45
|
+
quorate: true,
|
|
46
|
+
nodes: [
|
|
47
|
+
{ name: 'pve01', online: true },
|
|
48
|
+
{ name: 'pve02', online: true },
|
|
49
|
+
],
|
|
50
|
+
warnings: [],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const healthyHaStatus = {
|
|
54
|
+
managerStatus: 'active',
|
|
55
|
+
resources: [{ sid: 'vm:100', state: 'started', node: 'pve01', type: 'vm' }],
|
|
56
|
+
warnings: [],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const healthyVmStatus = {
|
|
60
|
+
vmid: 100,
|
|
61
|
+
name: 'web-01',
|
|
62
|
+
status: 'running',
|
|
63
|
+
node: 'pve01',
|
|
64
|
+
type: 'qemu',
|
|
65
|
+
uptime: 86400,
|
|
66
|
+
cpu: 0.1,
|
|
67
|
+
mem: 2e9,
|
|
68
|
+
maxmem: 4e9,
|
|
69
|
+
lock: null,
|
|
70
|
+
hastate: 'managed',
|
|
71
|
+
warnings: [],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const healthyVmConfig = {
|
|
75
|
+
vmid: 100,
|
|
76
|
+
node: 'pve01',
|
|
77
|
+
config: {},
|
|
78
|
+
disks: [{ key: 'scsi0', storage: 'ceph-pool', format: 'raw', size: '32G' }],
|
|
79
|
+
warnings: [],
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const healthyNodeStorage = {
|
|
83
|
+
storages: [
|
|
84
|
+
{
|
|
85
|
+
storage: 'local',
|
|
86
|
+
type: 'dir',
|
|
87
|
+
total: 100e9,
|
|
88
|
+
used: 40e9,
|
|
89
|
+
avail: 60e9,
|
|
90
|
+
shared: false,
|
|
91
|
+
enabled: true,
|
|
92
|
+
active: true,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
storage: 'local-lvm',
|
|
96
|
+
type: 'lvmthin',
|
|
97
|
+
total: 500e9,
|
|
98
|
+
used: 100e9,
|
|
99
|
+
avail: 400e9,
|
|
100
|
+
shared: false,
|
|
101
|
+
enabled: true,
|
|
102
|
+
active: true,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
storage: 'ceph-pool',
|
|
106
|
+
type: 'rbd',
|
|
107
|
+
total: 1e12,
|
|
108
|
+
used: 200e9,
|
|
109
|
+
avail: 800e9,
|
|
110
|
+
shared: true,
|
|
111
|
+
enabled: true,
|
|
112
|
+
active: true,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
warnings: [],
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const emptyTasks = { tasks: [], warnings: [] };
|
|
119
|
+
|
|
120
|
+
// =============================================================================
|
|
121
|
+
// proxmox-vm-health tests
|
|
122
|
+
// =============================================================================
|
|
123
|
+
|
|
124
|
+
describe('proxmox-vm-health', () => {
|
|
125
|
+
const handler = getHandler('proxmox-vm');
|
|
126
|
+
|
|
127
|
+
it('healthy QEMU VM — all probes good', async () => {
|
|
128
|
+
const runProbe = createMockRunProbe({
|
|
129
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
130
|
+
'proxmox.cluster.ha.status': { data: healthyHaStatus },
|
|
131
|
+
'proxmox.vm.status': { data: healthyVmStatus },
|
|
132
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
133
|
+
'proxmox.vm.config': { data: healthyVmConfig },
|
|
134
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
138
|
+
|
|
139
|
+
expect(result.category).toBe('proxmox-vm');
|
|
140
|
+
expect(result.findings).toHaveLength(1);
|
|
141
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
142
|
+
expect(result.findings[0]?.title).toContain('VM 100 is healthy');
|
|
143
|
+
expect(result.summary.probesRun).toBeGreaterThanOrEqual(6);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('healthy LXC container — routes to lxc.config', async () => {
|
|
147
|
+
const lxcVmStatus = { ...healthyVmStatus, vmid: 200, type: 'lxc', name: 'ct-db' };
|
|
148
|
+
const lxcConfig = {
|
|
149
|
+
vmid: 200,
|
|
150
|
+
node: 'pve01',
|
|
151
|
+
config: {},
|
|
152
|
+
rootfs: { storage: 'ceph-pool', size: '8G' },
|
|
153
|
+
mountpoints: [],
|
|
154
|
+
warnings: [],
|
|
155
|
+
};
|
|
156
|
+
const haNoResources = { ...healthyHaStatus, resources: [] };
|
|
157
|
+
|
|
158
|
+
const calls: string[] = [];
|
|
159
|
+
const runProbe: RunProbe = async (probe, _params, _agent) => {
|
|
160
|
+
calls.push(probe);
|
|
161
|
+
const responses: Record<string, unknown> = {
|
|
162
|
+
'proxmox.cluster.status': healthyClusterStatus,
|
|
163
|
+
'proxmox.cluster.ha.status': haNoResources,
|
|
164
|
+
'proxmox.vm.status': lxcVmStatus,
|
|
165
|
+
'proxmox.cluster.tasks': emptyTasks,
|
|
166
|
+
'proxmox.lxc.config': lxcConfig,
|
|
167
|
+
'proxmox.node.storage': healthyNodeStorage,
|
|
168
|
+
};
|
|
169
|
+
return mockResult(probe, responses[probe]);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const result = await handler({ vmid: 200 }, runProbe, defaultContext);
|
|
173
|
+
|
|
174
|
+
expect(calls).toContain('proxmox.lxc.config');
|
|
175
|
+
expect(calls).not.toContain('proxmox.vm.config');
|
|
176
|
+
expect(result.findings.some((f) => f.severity === 'info')).toBe(true);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('HA error state — critical finding with ha-manager remediation', async () => {
|
|
180
|
+
const haError = {
|
|
181
|
+
...healthyHaStatus,
|
|
182
|
+
resources: [{ sid: 'vm:100', state: 'error', node: 'pve01', type: 'vm' }],
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const runProbe = createMockRunProbe({
|
|
186
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
187
|
+
'proxmox.cluster.ha.status': { data: haError },
|
|
188
|
+
'proxmox.vm.status': { data: healthyVmStatus },
|
|
189
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
190
|
+
'proxmox.vm.config': { data: healthyVmConfig },
|
|
191
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
195
|
+
|
|
196
|
+
const critical = result.findings.filter((f) => f.severity === 'critical');
|
|
197
|
+
expect(critical.length).toBeGreaterThanOrEqual(1);
|
|
198
|
+
const haFinding = critical.find((f) => f.title.includes('HA error'));
|
|
199
|
+
expect(haFinding).toBeDefined();
|
|
200
|
+
expect(haFinding?.remediation).toContain('ha-manager set vm:100 --state disabled');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('VM locked — warning with unlock remediation', async () => {
|
|
204
|
+
const lockedVm = { ...healthyVmStatus, lock: 'backup' };
|
|
205
|
+
const haNoResources = { ...healthyHaStatus, resources: [] };
|
|
206
|
+
|
|
207
|
+
const runProbe = createMockRunProbe({
|
|
208
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
209
|
+
'proxmox.cluster.ha.status': { data: haNoResources },
|
|
210
|
+
'proxmox.vm.status': { data: lockedVm },
|
|
211
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
212
|
+
'proxmox.vm.config': { data: healthyVmConfig },
|
|
213
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
217
|
+
|
|
218
|
+
const warning = result.findings.find((f) => f.title.includes('stale lock'));
|
|
219
|
+
expect(warning).toBeDefined();
|
|
220
|
+
expect(warning?.severity).toBe('warning');
|
|
221
|
+
expect(warning?.remediation).toContain('qm unlock 100');
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('local storage + HA — critical finding with qm move-disk', async () => {
|
|
225
|
+
const localConfig = {
|
|
226
|
+
...healthyVmConfig,
|
|
227
|
+
disks: [{ key: 'scsi0', storage: 'local-lvm', format: 'raw', size: '32G' }],
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const runProbe = createMockRunProbe({
|
|
231
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
232
|
+
'proxmox.cluster.ha.status': { data: healthyHaStatus },
|
|
233
|
+
'proxmox.vm.status': { data: healthyVmStatus },
|
|
234
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
235
|
+
'proxmox.vm.config': { data: localConfig },
|
|
236
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
240
|
+
|
|
241
|
+
const critical = result.findings.find((f) =>
|
|
242
|
+
f.title.includes('local storage but is HA-managed'),
|
|
243
|
+
);
|
|
244
|
+
expect(critical).toBeDefined();
|
|
245
|
+
expect(critical?.severity).toBe('critical');
|
|
246
|
+
expect(critical?.remediation).toContain('qm move-disk 100 scsi0 ceph-pool --delete');
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('storage inaccessible — critical finding', async () => {
|
|
250
|
+
const inactiveStorage = {
|
|
251
|
+
storages: [
|
|
252
|
+
...healthyNodeStorage.storages.map((s) =>
|
|
253
|
+
s.storage === 'ceph-pool' ? { ...s, active: false } : s,
|
|
254
|
+
),
|
|
255
|
+
],
|
|
256
|
+
warnings: [],
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const runProbe = createMockRunProbe({
|
|
260
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
261
|
+
'proxmox.cluster.ha.status': { data: healthyHaStatus },
|
|
262
|
+
'proxmox.vm.status': { data: healthyVmStatus },
|
|
263
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
264
|
+
'proxmox.vm.config': { data: healthyVmConfig },
|
|
265
|
+
'proxmox.node.storage': { data: inactiveStorage },
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
269
|
+
|
|
270
|
+
const critical = result.findings.find((f) => f.title.includes('not accessible'));
|
|
271
|
+
expect(critical).toBeDefined();
|
|
272
|
+
expect(critical?.severity).toBe('critical');
|
|
273
|
+
expect(critical?.remediation).toContain('LVM/NFS');
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('failed recent tasks — warning finding', async () => {
|
|
277
|
+
const failedTasks = {
|
|
278
|
+
tasks: [
|
|
279
|
+
{
|
|
280
|
+
type: 'qmstart',
|
|
281
|
+
status: 'ERROR: start failed',
|
|
282
|
+
node: 'pve01',
|
|
283
|
+
starttime: 1000,
|
|
284
|
+
endtime: 1010,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
warnings: [],
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const haNoResources = { ...healthyHaStatus, resources: [] };
|
|
291
|
+
const runProbe = createMockRunProbe({
|
|
292
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
293
|
+
'proxmox.cluster.ha.status': { data: haNoResources },
|
|
294
|
+
'proxmox.vm.status': { data: healthyVmStatus },
|
|
295
|
+
'proxmox.cluster.tasks': { data: failedTasks },
|
|
296
|
+
'proxmox.vm.config': { data: healthyVmConfig },
|
|
297
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
301
|
+
|
|
302
|
+
const warning = result.findings.find((f) => f.title.includes('task failures'));
|
|
303
|
+
expect(warning).toBeDefined();
|
|
304
|
+
expect(warning?.severity).toBe('warning');
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('VM not found — handles error gracefully', async () => {
|
|
308
|
+
const runProbe = createMockRunProbe({
|
|
309
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
310
|
+
'proxmox.cluster.ha.status': { data: healthyHaStatus },
|
|
311
|
+
'proxmox.vm.status': { status: 'error', error: 'VM/container 999 not found' },
|
|
312
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
const result = await handler({ vmid: 999 }, runProbe, defaultContext);
|
|
316
|
+
|
|
317
|
+
expect(result.findings).toHaveLength(1);
|
|
318
|
+
expect(result.findings[0]?.severity).toBe('critical');
|
|
319
|
+
expect(result.findings[0]?.title).toContain('not found');
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('agent available — calls agent probe when node matches', async () => {
|
|
323
|
+
const haNoResources = { ...healthyHaStatus, resources: [] };
|
|
324
|
+
const calls: Array<{ probe: string; agent?: string }> = [];
|
|
325
|
+
const runProbe: RunProbe = async (probe, _params, agent) => {
|
|
326
|
+
calls.push({ probe, agent });
|
|
327
|
+
const responses: Record<string, unknown> = {
|
|
328
|
+
'proxmox.cluster.status': healthyClusterStatus,
|
|
329
|
+
'proxmox.cluster.ha.status': haNoResources,
|
|
330
|
+
'proxmox.vm.status': healthyVmStatus,
|
|
331
|
+
'proxmox.cluster.tasks': emptyTasks,
|
|
332
|
+
'proxmox.vm.config': healthyVmConfig,
|
|
333
|
+
'proxmox.node.storage': healthyNodeStorage,
|
|
334
|
+
'proxmox-node.local.lvm': { volumeGroups: [], warnings: [] },
|
|
335
|
+
};
|
|
336
|
+
return mockResult(probe, responses[probe]);
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const ctx: RunbookContext = { connectedAgents: ['pve01'] };
|
|
340
|
+
await handler({ vmid: 100 }, runProbe, ctx);
|
|
341
|
+
|
|
342
|
+
const agentCall = calls.find((c) => c.probe === 'proxmox-node.local.lvm');
|
|
343
|
+
expect(agentCall).toBeDefined();
|
|
344
|
+
expect(agentCall?.agent).toBe('pve01');
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('agent unavailable — skips agent probe silently', async () => {
|
|
348
|
+
const haNoResources = { ...healthyHaStatus, resources: [] };
|
|
349
|
+
const calls: string[] = [];
|
|
350
|
+
const runProbe: RunProbe = async (probe) => {
|
|
351
|
+
calls.push(probe);
|
|
352
|
+
const responses: Record<string, unknown> = {
|
|
353
|
+
'proxmox.cluster.status': healthyClusterStatus,
|
|
354
|
+
'proxmox.cluster.ha.status': haNoResources,
|
|
355
|
+
'proxmox.vm.status': healthyVmStatus,
|
|
356
|
+
'proxmox.cluster.tasks': emptyTasks,
|
|
357
|
+
'proxmox.vm.config': healthyVmConfig,
|
|
358
|
+
'proxmox.node.storage': healthyNodeStorage,
|
|
359
|
+
};
|
|
360
|
+
return mockResult(probe, responses[probe]);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
364
|
+
|
|
365
|
+
expect(calls).not.toContain('proxmox-node.local.lvm');
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it('VM stopped — warning finding', async () => {
|
|
369
|
+
const stoppedVm = { ...healthyVmStatus, status: 'stopped' };
|
|
370
|
+
const haNoResources = { ...healthyHaStatus, resources: [] };
|
|
371
|
+
|
|
372
|
+
const runProbe = createMockRunProbe({
|
|
373
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
374
|
+
'proxmox.cluster.ha.status': { data: haNoResources },
|
|
375
|
+
'proxmox.vm.status': { data: stoppedVm },
|
|
376
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
377
|
+
'proxmox.vm.config': { data: healthyVmConfig },
|
|
378
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
382
|
+
|
|
383
|
+
const warning = result.findings.find((f) => f.title.includes('stopped'));
|
|
384
|
+
expect(warning).toBeDefined();
|
|
385
|
+
expect(warning?.severity).toBe('warning');
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it('quorum lost — critical finding', async () => {
|
|
389
|
+
const noQuorum = { ...healthyClusterStatus, quorate: false };
|
|
390
|
+
const haNoResources = { ...healthyHaStatus, resources: [] };
|
|
391
|
+
|
|
392
|
+
const runProbe = createMockRunProbe({
|
|
393
|
+
'proxmox.cluster.status': { data: noQuorum },
|
|
394
|
+
'proxmox.cluster.ha.status': { data: haNoResources },
|
|
395
|
+
'proxmox.vm.status': { data: healthyVmStatus },
|
|
396
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
397
|
+
'proxmox.vm.config': { data: healthyVmConfig },
|
|
398
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
const result = await handler({ vmid: 100 }, runProbe, defaultContext);
|
|
402
|
+
|
|
403
|
+
const critical = result.findings.find((f) => f.title.includes('quorum'));
|
|
404
|
+
expect(critical).toBeDefined();
|
|
405
|
+
expect(critical?.severity).toBe('critical');
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// =============================================================================
|
|
410
|
+
// proxmox-cluster-health tests
|
|
411
|
+
// =============================================================================
|
|
412
|
+
|
|
413
|
+
describe('proxmox-cluster-health', () => {
|
|
414
|
+
const handler = getHandler('proxmox-cluster');
|
|
415
|
+
|
|
416
|
+
const healthyNodesList = {
|
|
417
|
+
nodes: [
|
|
418
|
+
{ node: 'pve01', status: 'online', cpu: 0.25, mem: 4e9, maxmem: 16e9 },
|
|
419
|
+
{ node: 'pve02', status: 'online', cpu: 0.3, mem: 6e9, maxmem: 16e9 },
|
|
420
|
+
],
|
|
421
|
+
warnings: [],
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
it('healthy cluster — no issues', async () => {
|
|
425
|
+
const runProbe = createMockRunProbe({
|
|
426
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
427
|
+
'proxmox.nodes.list': { data: healthyNodesList },
|
|
428
|
+
'proxmox.cluster.ha.status': { data: { ...healthyHaStatus, resources: [] } },
|
|
429
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
430
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
434
|
+
|
|
435
|
+
expect(result.category).toBe('proxmox-cluster');
|
|
436
|
+
// All findings should be info or no critical/warning
|
|
437
|
+
const issues = result.findings.filter((f) => f.severity !== 'info');
|
|
438
|
+
expect(issues).toHaveLength(0);
|
|
439
|
+
expect(result.summary.summaryText).toContain('2 nodes online');
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('offline node — critical finding', async () => {
|
|
443
|
+
const nodeWithOffline = {
|
|
444
|
+
nodes: [
|
|
445
|
+
{ node: 'pve01', status: 'online', cpu: 0.25, mem: 4e9, maxmem: 16e9 },
|
|
446
|
+
{ node: 'pve02', status: 'offline', cpu: 0, mem: 0, maxmem: 16e9 },
|
|
447
|
+
],
|
|
448
|
+
warnings: [],
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const runProbe = createMockRunProbe({
|
|
452
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
453
|
+
'proxmox.nodes.list': { data: nodeWithOffline },
|
|
454
|
+
'proxmox.cluster.ha.status': { data: { ...healthyHaStatus, resources: [] } },
|
|
455
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
456
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
460
|
+
|
|
461
|
+
const critical = result.findings.find(
|
|
462
|
+
(f) => f.title.includes('pve02') && f.title.includes('offline'),
|
|
463
|
+
);
|
|
464
|
+
expect(critical).toBeDefined();
|
|
465
|
+
expect(critical?.severity).toBe('critical');
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('high CPU — warning per node', async () => {
|
|
469
|
+
const highCpuNodes = {
|
|
470
|
+
nodes: [{ node: 'pve01', status: 'online', cpu: 0.95, mem: 4e9, maxmem: 16e9 }],
|
|
471
|
+
warnings: [],
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
const runProbe = createMockRunProbe({
|
|
475
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
476
|
+
'proxmox.nodes.list': { data: highCpuNodes },
|
|
477
|
+
'proxmox.cluster.ha.status': { data: { ...healthyHaStatus, resources: [] } },
|
|
478
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
479
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
483
|
+
|
|
484
|
+
const warning = result.findings.find((f) => f.title.includes('CPU') && f.title.includes('95%'));
|
|
485
|
+
expect(warning).toBeDefined();
|
|
486
|
+
expect(warning?.severity).toBe('warning');
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it('high memory — warning per node', async () => {
|
|
490
|
+
const highMemNodes = {
|
|
491
|
+
nodes: [{ node: 'pve01', status: 'online', cpu: 0.2, mem: 15e9, maxmem: 16e9 }],
|
|
492
|
+
warnings: [],
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
const runProbe = createMockRunProbe({
|
|
496
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
497
|
+
'proxmox.nodes.list': { data: highMemNodes },
|
|
498
|
+
'proxmox.cluster.ha.status': { data: { ...healthyHaStatus, resources: [] } },
|
|
499
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
500
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
504
|
+
|
|
505
|
+
const warning = result.findings.find(
|
|
506
|
+
(f) => f.title.includes('memory') && f.title.includes('94%'),
|
|
507
|
+
);
|
|
508
|
+
expect(warning).toBeDefined();
|
|
509
|
+
expect(warning?.severity).toBe('warning');
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('HA resources in error — critical with remediation', async () => {
|
|
513
|
+
const haError = {
|
|
514
|
+
resources: [{ sid: 'vm:100', state: 'error', node: 'pve01' }],
|
|
515
|
+
warnings: [],
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const runProbe = createMockRunProbe({
|
|
519
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
520
|
+
'proxmox.nodes.list': { data: healthyNodesList },
|
|
521
|
+
'proxmox.cluster.ha.status': { data: haError },
|
|
522
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
523
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
527
|
+
|
|
528
|
+
const critical = result.findings.find((f) => f.title.includes('vm:100'));
|
|
529
|
+
expect(critical).toBeDefined();
|
|
530
|
+
expect(critical?.severity).toBe('critical');
|
|
531
|
+
expect(critical?.remediation).toContain('ha-manager set vm:100 --state disabled');
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it('storage > 85% — warning per storage', async () => {
|
|
535
|
+
const fullStorage = {
|
|
536
|
+
storages: [
|
|
537
|
+
{
|
|
538
|
+
storage: 'local',
|
|
539
|
+
type: 'dir',
|
|
540
|
+
total: 100e9,
|
|
541
|
+
used: 90e9,
|
|
542
|
+
avail: 10e9,
|
|
543
|
+
shared: false,
|
|
544
|
+
enabled: true,
|
|
545
|
+
active: true,
|
|
546
|
+
},
|
|
547
|
+
],
|
|
548
|
+
warnings: [],
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
const runProbe = createMockRunProbe({
|
|
552
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
553
|
+
'proxmox.nodes.list': {
|
|
554
|
+
data: {
|
|
555
|
+
nodes: [{ node: 'pve01', status: 'online', cpu: 0.1, mem: 4e9, maxmem: 16e9 }],
|
|
556
|
+
warnings: [],
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
'proxmox.cluster.ha.status': { data: { resources: [], warnings: [] } },
|
|
560
|
+
'proxmox.cluster.tasks': { data: emptyTasks },
|
|
561
|
+
'proxmox.node.storage': { data: fullStorage },
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
565
|
+
|
|
566
|
+
const warning = result.findings.find(
|
|
567
|
+
(f) => f.title.includes('local') && f.title.includes('90%'),
|
|
568
|
+
);
|
|
569
|
+
expect(warning).toBeDefined();
|
|
570
|
+
expect(warning?.severity).toBe('warning');
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
it('failed tasks in last 24h — warning per task', async () => {
|
|
574
|
+
const now = Math.floor(Date.now() / 1000);
|
|
575
|
+
const recentFailedTasks = {
|
|
576
|
+
tasks: [
|
|
577
|
+
{
|
|
578
|
+
type: 'qmstart',
|
|
579
|
+
status: 'ERROR: failed',
|
|
580
|
+
node: 'pve01',
|
|
581
|
+
starttime: now - 3600,
|
|
582
|
+
endtime: now - 3500,
|
|
583
|
+
},
|
|
584
|
+
],
|
|
585
|
+
warnings: [],
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
const runProbe = createMockRunProbe({
|
|
589
|
+
'proxmox.cluster.status': { data: healthyClusterStatus },
|
|
590
|
+
'proxmox.nodes.list': { data: healthyNodesList },
|
|
591
|
+
'proxmox.cluster.ha.status': { data: { resources: [], warnings: [] } },
|
|
592
|
+
'proxmox.cluster.tasks': { data: recentFailedTasks },
|
|
593
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
597
|
+
|
|
598
|
+
const warning = result.findings.find((f) => f.title.includes('Failed task'));
|
|
599
|
+
expect(warning).toBeDefined();
|
|
600
|
+
expect(warning?.severity).toBe('warning');
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it('per-node storage iteration — probes run for each node', async () => {
|
|
604
|
+
const calls: string[] = [];
|
|
605
|
+
const runProbe: RunProbe = async (probe, params) => {
|
|
606
|
+
const key = params?.node ? `${probe}:${params.node}` : probe;
|
|
607
|
+
calls.push(key);
|
|
608
|
+
const responses: Record<string, unknown> = {
|
|
609
|
+
'proxmox.cluster.status': healthyClusterStatus,
|
|
610
|
+
'proxmox.nodes.list': healthyNodesList,
|
|
611
|
+
'proxmox.cluster.ha.status': { resources: [], warnings: [] },
|
|
612
|
+
'proxmox.cluster.tasks': emptyTasks,
|
|
613
|
+
'proxmox.node.storage': healthyNodeStorage,
|
|
614
|
+
};
|
|
615
|
+
return mockResult(probe, responses[probe]);
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
await handler({}, runProbe, defaultContext);
|
|
619
|
+
|
|
620
|
+
// Should have storage calls for both pve01 and pve02
|
|
621
|
+
expect(calls.filter((c) => c.startsWith('proxmox.node.storage'))).toHaveLength(2);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
// =============================================================================
|
|
626
|
+
// proxmox-storage-audit tests
|
|
627
|
+
// =============================================================================
|
|
628
|
+
|
|
629
|
+
describe('proxmox-storage-audit', () => {
|
|
630
|
+
const handler = getHandler('proxmox-storage');
|
|
631
|
+
|
|
632
|
+
it('no HA VMs — info finding', async () => {
|
|
633
|
+
const noHa = { resources: [], warnings: [] };
|
|
634
|
+
const resources = {
|
|
635
|
+
resources: [{ vmid: 100, name: 'web-01', node: 'pve01', type: 'qemu', status: 'running' }],
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
const runProbe = createMockRunProbe({
|
|
639
|
+
'proxmox.cluster.resources': { data: resources },
|
|
640
|
+
'proxmox.cluster.ha.status': { data: noHa },
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
644
|
+
|
|
645
|
+
expect(result.findings).toHaveLength(1);
|
|
646
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
647
|
+
expect(result.findings[0]?.title).toContain('No HA-managed VMs');
|
|
648
|
+
expect(result.summary.summaryText).toContain('0 HA-managed VMs');
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
it('all shared storage — info finding', async () => {
|
|
652
|
+
const resources = {
|
|
653
|
+
resources: [{ vmid: 100, name: 'web-01', node: 'pve01', type: 'qemu', status: 'running' }],
|
|
654
|
+
};
|
|
655
|
+
const haStatus = {
|
|
656
|
+
resources: [{ sid: 'vm:100', state: 'started', node: 'pve01' }],
|
|
657
|
+
warnings: [],
|
|
658
|
+
};
|
|
659
|
+
const sharedConfig = {
|
|
660
|
+
vmid: 100,
|
|
661
|
+
node: 'pve01',
|
|
662
|
+
config: {},
|
|
663
|
+
disks: [{ key: 'scsi0', storage: 'ceph-pool', format: 'raw', size: '32G' }],
|
|
664
|
+
warnings: [],
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
const runProbe = createMockRunProbe({
|
|
668
|
+
'proxmox.cluster.resources': { data: resources },
|
|
669
|
+
'proxmox.cluster.ha.status': { data: haStatus },
|
|
670
|
+
'proxmox.vm.config': { data: sharedConfig },
|
|
671
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
675
|
+
|
|
676
|
+
expect(result.findings).toHaveLength(1);
|
|
677
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
678
|
+
expect(result.findings[0]?.title).toContain('shared storage');
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
it('local storage on HA QEMU VM — critical with qm move-disk', async () => {
|
|
682
|
+
const resources = {
|
|
683
|
+
resources: [{ vmid: 100, name: 'web-01', node: 'pve01', type: 'qemu', status: 'running' }],
|
|
684
|
+
};
|
|
685
|
+
const haStatus = {
|
|
686
|
+
resources: [{ sid: 'vm:100', state: 'started', node: 'pve01' }],
|
|
687
|
+
warnings: [],
|
|
688
|
+
};
|
|
689
|
+
const localConfig = {
|
|
690
|
+
vmid: 100,
|
|
691
|
+
node: 'pve01',
|
|
692
|
+
config: {},
|
|
693
|
+
disks: [{ key: 'scsi0', storage: 'local-lvm', format: 'raw', size: '32G' }],
|
|
694
|
+
warnings: [],
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
const runProbe = createMockRunProbe({
|
|
698
|
+
'proxmox.cluster.resources': { data: resources },
|
|
699
|
+
'proxmox.cluster.ha.status': { data: haStatus },
|
|
700
|
+
'proxmox.vm.config': { data: localConfig },
|
|
701
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
705
|
+
|
|
706
|
+
const critical = result.findings.find((f) => f.severity === 'critical');
|
|
707
|
+
expect(critical).toBeDefined();
|
|
708
|
+
expect(critical?.title).toContain('local storage');
|
|
709
|
+
expect(critical?.remediation).toContain('qm move-disk 100 scsi0 ceph-pool --delete');
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
it('local storage on HA LXC container — critical (checks rootfs)', async () => {
|
|
713
|
+
const resources = {
|
|
714
|
+
resources: [{ vmid: 200, name: 'ct-db', node: 'pve01', type: 'lxc', status: 'running' }],
|
|
715
|
+
};
|
|
716
|
+
const haStatus = {
|
|
717
|
+
resources: [{ sid: 'ct:200', state: 'started', node: 'pve01' }],
|
|
718
|
+
warnings: [],
|
|
719
|
+
};
|
|
720
|
+
const lxcConfig = {
|
|
721
|
+
vmid: 200,
|
|
722
|
+
node: 'pve01',
|
|
723
|
+
config: {},
|
|
724
|
+
rootfs: { storage: 'local-lvm', size: '8G' },
|
|
725
|
+
mountpoints: [{ key: 'mp0', storage: 'local-lvm', mountpoint: '/data', size: '20G' }],
|
|
726
|
+
warnings: [],
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
const runProbe = createMockRunProbe({
|
|
730
|
+
'proxmox.cluster.resources': { data: resources },
|
|
731
|
+
'proxmox.cluster.ha.status': { data: haStatus },
|
|
732
|
+
'proxmox.lxc.config': { data: lxcConfig },
|
|
733
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
737
|
+
|
|
738
|
+
const criticals = result.findings.filter((f) => f.severity === 'critical');
|
|
739
|
+
// Should flag both rootfs and mp0
|
|
740
|
+
expect(criticals.length).toBeGreaterThanOrEqual(2);
|
|
741
|
+
expect(criticals.some((f) => f.title.includes('rootfs'))).toBe(true);
|
|
742
|
+
expect(criticals.some((f) => f.title.includes('mp0'))).toBe(true);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
it('mixed — only flags local ones', async () => {
|
|
746
|
+
const resources = {
|
|
747
|
+
resources: [
|
|
748
|
+
{ vmid: 100, name: 'shared-vm', node: 'pve01', type: 'qemu', status: 'running' },
|
|
749
|
+
{ vmid: 101, name: 'local-vm', node: 'pve01', type: 'qemu', status: 'running' },
|
|
750
|
+
],
|
|
751
|
+
};
|
|
752
|
+
const haStatus = {
|
|
753
|
+
resources: [
|
|
754
|
+
{ sid: 'vm:100', state: 'started', node: 'pve01' },
|
|
755
|
+
{ sid: 'vm:101', state: 'started', node: 'pve01' },
|
|
756
|
+
],
|
|
757
|
+
warnings: [],
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
const calls: Array<{ probe: string; params?: Record<string, unknown> }> = [];
|
|
761
|
+
const runProbe: RunProbe = async (probe, params) => {
|
|
762
|
+
calls.push({ probe, params });
|
|
763
|
+
if (probe === 'proxmox.cluster.resources') return mockResult(probe, resources);
|
|
764
|
+
if (probe === 'proxmox.cluster.ha.status') return mockResult(probe, haStatus);
|
|
765
|
+
if (probe === 'proxmox.node.storage') return mockResult(probe, healthyNodeStorage);
|
|
766
|
+
if (probe === 'proxmox.vm.config') {
|
|
767
|
+
const vmid = params?.vmid as number;
|
|
768
|
+
if (vmid === 100) {
|
|
769
|
+
return mockResult(probe, {
|
|
770
|
+
disks: [{ key: 'scsi0', storage: 'ceph-pool', format: 'raw', size: '32G' }],
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
return mockResult(probe, {
|
|
774
|
+
disks: [{ key: 'scsi0', storage: 'local-lvm', format: 'raw', size: '32G' }],
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
return mockResult(probe, undefined, 'error', 'Unknown probe');
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
781
|
+
|
|
782
|
+
const criticals = result.findings.filter((f) => f.severity === 'critical');
|
|
783
|
+
expect(criticals).toHaveLength(1);
|
|
784
|
+
expect(criticals[0]?.title).toContain('101');
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
it('suggests shared storage name from available storages', async () => {
|
|
788
|
+
const resources = {
|
|
789
|
+
resources: [{ vmid: 100, name: 'web-01', node: 'pve01', type: 'qemu', status: 'running' }],
|
|
790
|
+
};
|
|
791
|
+
const haStatus = {
|
|
792
|
+
resources: [{ sid: 'vm:100', state: 'started', node: 'pve01' }],
|
|
793
|
+
warnings: [],
|
|
794
|
+
};
|
|
795
|
+
const localConfig = {
|
|
796
|
+
disks: [{ key: 'scsi0', storage: 'local-lvm', format: 'raw', size: '32G' }],
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
const runProbe = createMockRunProbe({
|
|
800
|
+
'proxmox.cluster.resources': { data: resources },
|
|
801
|
+
'proxmox.cluster.ha.status': { data: haStatus },
|
|
802
|
+
'proxmox.vm.config': { data: localConfig },
|
|
803
|
+
'proxmox.node.storage': { data: healthyNodeStorage },
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
807
|
+
|
|
808
|
+
const critical = result.findings.find((f) => f.severity === 'critical');
|
|
809
|
+
expect(critical?.remediation).toContain('ceph-pool');
|
|
810
|
+
});
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
// =============================================================================
|
|
814
|
+
// Definitions
|
|
815
|
+
// =============================================================================
|
|
816
|
+
|
|
817
|
+
describe('proxmoxDiagnosticRunbooks definitions', () => {
|
|
818
|
+
it('exports 3 runbook definitions', () => {
|
|
819
|
+
expect(proxmoxDiagnosticRunbooks).toHaveLength(3);
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
it('has correct categories', () => {
|
|
823
|
+
const categories = proxmoxDiagnosticRunbooks.map((r) => r.category);
|
|
824
|
+
expect(categories).toContain('proxmox-vm');
|
|
825
|
+
expect(categories).toContain('proxmox-cluster');
|
|
826
|
+
expect(categories).toContain('proxmox-storage');
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
it('proxmox-vm requires vmid param', () => {
|
|
830
|
+
const def = proxmoxDiagnosticRunbooks.find((r) => r.category === 'proxmox-vm');
|
|
831
|
+
expect(def?.params?.vmid?.required).toBe(true);
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
it('proxmox-storage has no required params', () => {
|
|
835
|
+
const def = proxmoxDiagnosticRunbooks.find((r) => r.category === 'proxmox-storage');
|
|
836
|
+
expect(def?.params).toBeUndefined();
|
|
837
|
+
});
|
|
838
|
+
});
|