@sonde/packs 0.1.0 → 0.1.1
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 +6 -0
- package/.turbo/turbo-test.log +814 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +10 -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 +420 -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 +290 -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 +70 -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 +1121 -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 +733 -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 +257 -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 +242 -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/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 +557 -0
- package/src/integrations/graph.test.ts +478 -0
- package/src/integrations/graph.ts +413 -0
- package/src/integrations/httpbin.ts +72 -0
- package/src/integrations/nutanix.test.ts +1508 -0
- package/src/integrations/nutanix.ts +1460 -0
- package/src/integrations/proxmox.test.ts +1020 -0
- package/src/integrations/proxmox.ts +989 -0
- package/src/integrations/servicenow.test.ts +314 -0
- package/src/integrations/servicenow.ts +285 -0
- package/src/integrations/splunk.test.ts +440 -0
- package/src/integrations/splunk.ts +356 -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/types.ts +62 -0
- package/src/validation.ts +21 -1
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,989 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FetchFn,
|
|
3
|
+
IntegrationConfig,
|
|
4
|
+
IntegrationCredentials,
|
|
5
|
+
IntegrationPack,
|
|
6
|
+
IntegrationProbeHandler,
|
|
7
|
+
} from '@sonde/shared';
|
|
8
|
+
|
|
9
|
+
// --- Auth helpers ---
|
|
10
|
+
|
|
11
|
+
/** Build Proxmox PVEAPIToken auth header */
|
|
12
|
+
export function buildAuthHeaders(credentials: IntegrationCredentials): Record<string, string> {
|
|
13
|
+
const tokenId = credentials.credentials.tokenId ?? '';
|
|
14
|
+
const tokenSecret = credentials.credentials.tokenSecret ?? '';
|
|
15
|
+
return { Authorization: `PVEAPIToken=${tokenId}=${tokenSecret}` };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// --- Proxmox REST helper ---
|
|
19
|
+
|
|
20
|
+
function proxmoxUrl(endpoint: string, path: string, params?: Record<string, string>): string {
|
|
21
|
+
const base = `${endpoint.replace(/\/$/, '')}/api2/json${path}`;
|
|
22
|
+
const url = new URL(base);
|
|
23
|
+
if (params) {
|
|
24
|
+
for (const [key, value] of Object.entries(params)) {
|
|
25
|
+
url.searchParams.set(key, value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return url.toString();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** GET a Proxmox API endpoint, returns parsed JSON */
|
|
32
|
+
export async function proxmoxGet(
|
|
33
|
+
path: string,
|
|
34
|
+
config: IntegrationConfig,
|
|
35
|
+
credentials: IntegrationCredentials,
|
|
36
|
+
fetchFn: FetchFn,
|
|
37
|
+
params?: Record<string, string>,
|
|
38
|
+
): Promise<unknown> {
|
|
39
|
+
const url = proxmoxUrl(config.endpoint, path, params);
|
|
40
|
+
const headers: Record<string, string> = {
|
|
41
|
+
Accept: 'application/json',
|
|
42
|
+
...buildAuthHeaders(credentials),
|
|
43
|
+
...config.headers,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const res = await fetchFn(url, { headers });
|
|
47
|
+
if (!res.ok) throw new Error(`Proxmox API returned ${res.status}: ${res.statusText}`);
|
|
48
|
+
return res.json();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// --- Node resolver ---
|
|
52
|
+
|
|
53
|
+
/** Resolve which node a VM/container lives on by querying cluster resources */
|
|
54
|
+
export async function resolveNode(
|
|
55
|
+
vmid: number,
|
|
56
|
+
config: IntegrationConfig,
|
|
57
|
+
credentials: IntegrationCredentials,
|
|
58
|
+
fetchFn: FetchFn,
|
|
59
|
+
): Promise<{ node: string; type: 'qemu' | 'lxc' }> {
|
|
60
|
+
const data = (await proxmoxGet('/cluster/resources', config, credentials, fetchFn, {
|
|
61
|
+
type: 'vm',
|
|
62
|
+
})) as { data?: Array<{ vmid?: number; node?: string; type?: string }> };
|
|
63
|
+
|
|
64
|
+
const entry = (data.data ?? []).find((r) => r.vmid === vmid);
|
|
65
|
+
if (!entry || !entry.node) {
|
|
66
|
+
throw new Error(`VM/container ${vmid} not found in cluster`);
|
|
67
|
+
}
|
|
68
|
+
return { node: entry.node, type: entry.type as 'qemu' | 'lxc' };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// --- Probe handlers ---
|
|
72
|
+
|
|
73
|
+
const clusterStatus: IntegrationProbeHandler = async (_params, config, credentials, fetchFn) => {
|
|
74
|
+
const data = (await proxmoxGet('/cluster/status', config, credentials, fetchFn)) as {
|
|
75
|
+
data?: Array<{
|
|
76
|
+
name?: string;
|
|
77
|
+
type?: string;
|
|
78
|
+
online?: number;
|
|
79
|
+
ip?: string;
|
|
80
|
+
quorate?: number;
|
|
81
|
+
nodeid?: number;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const entries = data.data ?? [];
|
|
86
|
+
const clusterEntry = entries.find((e) => e.type === 'cluster');
|
|
87
|
+
const nodeEntries = entries.filter((e) => e.type === 'node');
|
|
88
|
+
|
|
89
|
+
const warnings: string[] = [];
|
|
90
|
+
if (clusterEntry && !clusterEntry.quorate) {
|
|
91
|
+
warnings.push('Cluster has lost quorum');
|
|
92
|
+
}
|
|
93
|
+
for (const n of nodeEntries) {
|
|
94
|
+
if (!n.online) {
|
|
95
|
+
warnings.push(`Node ${n.name} is offline`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
clusterName: clusterEntry?.name ?? null,
|
|
101
|
+
quorate: !!clusterEntry?.quorate,
|
|
102
|
+
nodes: nodeEntries.map((n) => ({
|
|
103
|
+
name: n.name,
|
|
104
|
+
online: !!n.online,
|
|
105
|
+
ip: n.ip ?? null,
|
|
106
|
+
type: n.type,
|
|
107
|
+
})),
|
|
108
|
+
warnings,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const clusterHaStatus: IntegrationProbeHandler = async (_params, config, credentials, fetchFn) => {
|
|
113
|
+
const [statusData, resourcesData] = await Promise.all([
|
|
114
|
+
proxmoxGet('/cluster/ha/status/current', config, credentials, fetchFn) as Promise<{
|
|
115
|
+
data?: Array<{ id?: string; type?: string; status?: string; node?: string; state?: string }>;
|
|
116
|
+
}>,
|
|
117
|
+
proxmoxGet('/cluster/ha/resources', config, credentials, fetchFn) as Promise<{
|
|
118
|
+
data?: Array<{
|
|
119
|
+
sid?: string;
|
|
120
|
+
state?: string;
|
|
121
|
+
node?: string;
|
|
122
|
+
type?: string;
|
|
123
|
+
group?: string;
|
|
124
|
+
status?: string;
|
|
125
|
+
}>;
|
|
126
|
+
}>,
|
|
127
|
+
]);
|
|
128
|
+
|
|
129
|
+
const statusEntries = statusData.data ?? [];
|
|
130
|
+
const managerEntry = statusEntries.find((e) => e.type === 'manager' || e.id === 'manager');
|
|
131
|
+
const resources = resourcesData.data ?? [];
|
|
132
|
+
|
|
133
|
+
const warnings: string[] = [];
|
|
134
|
+
for (const r of resources) {
|
|
135
|
+
if (r.state === 'error' || r.state === 'fence') {
|
|
136
|
+
warnings.push(`HA resource ${r.sid} in ${r.state} state`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
managerStatus: managerEntry?.status ?? managerEntry?.state ?? null,
|
|
142
|
+
resources: resources.map((r) => ({
|
|
143
|
+
sid: r.sid,
|
|
144
|
+
state: r.state,
|
|
145
|
+
node: r.node,
|
|
146
|
+
type: r.type,
|
|
147
|
+
group: r.group ?? null,
|
|
148
|
+
})),
|
|
149
|
+
warnings,
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const nodesList: IntegrationProbeHandler = async (_params, config, credentials, fetchFn) => {
|
|
154
|
+
const data = (await proxmoxGet('/nodes', config, credentials, fetchFn)) as {
|
|
155
|
+
data?: Array<{
|
|
156
|
+
node?: string;
|
|
157
|
+
status?: string;
|
|
158
|
+
uptime?: number;
|
|
159
|
+
cpu?: number;
|
|
160
|
+
maxcpu?: number;
|
|
161
|
+
mem?: number;
|
|
162
|
+
maxmem?: number;
|
|
163
|
+
loadavg?: string;
|
|
164
|
+
}>;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const nodes = data.data ?? [];
|
|
168
|
+
const warnings: string[] = [];
|
|
169
|
+
|
|
170
|
+
for (const n of nodes) {
|
|
171
|
+
if (n.status === 'offline') {
|
|
172
|
+
warnings.push(`Node ${n.node} is offline`);
|
|
173
|
+
}
|
|
174
|
+
if (n.cpu != null && n.cpu > 0.9) {
|
|
175
|
+
warnings.push(`Node ${n.node} CPU at ${Math.round(n.cpu * 100)}%`);
|
|
176
|
+
}
|
|
177
|
+
if (n.mem != null && n.maxmem != null && n.maxmem > 0 && n.mem / n.maxmem > 0.9) {
|
|
178
|
+
warnings.push(`Node ${n.node} memory at ${Math.round((n.mem / n.maxmem) * 100)}%`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
nodes: nodes.map((n) => ({
|
|
184
|
+
node: n.node,
|
|
185
|
+
status: n.status,
|
|
186
|
+
uptime: n.uptime ?? 0,
|
|
187
|
+
cpu: n.cpu ?? 0,
|
|
188
|
+
maxcpu: n.maxcpu ?? 0,
|
|
189
|
+
mem: n.mem ?? 0,
|
|
190
|
+
maxmem: n.maxmem ?? 0,
|
|
191
|
+
loadavg: n.loadavg ?? null,
|
|
192
|
+
})),
|
|
193
|
+
warnings,
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const nodeStorage: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
198
|
+
const node = params?.node as string;
|
|
199
|
+
if (!node) throw new Error('node parameter is required');
|
|
200
|
+
|
|
201
|
+
const data = (await proxmoxGet(`/nodes/${node}/storage`, config, credentials, fetchFn)) as {
|
|
202
|
+
data?: Array<{
|
|
203
|
+
storage?: string;
|
|
204
|
+
type?: string;
|
|
205
|
+
total?: number;
|
|
206
|
+
used?: number;
|
|
207
|
+
avail?: number;
|
|
208
|
+
shared?: number;
|
|
209
|
+
enabled?: number;
|
|
210
|
+
active?: number;
|
|
211
|
+
}>;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const storages = data.data ?? [];
|
|
215
|
+
const warnings: string[] = [];
|
|
216
|
+
|
|
217
|
+
for (const s of storages) {
|
|
218
|
+
if (s.total && s.used && s.total > 0 && s.used / s.total > 0.85) {
|
|
219
|
+
warnings.push(`Storage ${s.storage} is ${Math.round((s.used / s.total) * 100)}% used`);
|
|
220
|
+
}
|
|
221
|
+
if (s.enabled === 0) {
|
|
222
|
+
warnings.push(`Storage ${s.storage} is disabled`);
|
|
223
|
+
}
|
|
224
|
+
if (s.active === 0 && s.enabled !== 0) {
|
|
225
|
+
warnings.push(`Storage ${s.storage} is inactive`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
storages: storages.map((s) => ({
|
|
231
|
+
storage: s.storage,
|
|
232
|
+
type: s.type,
|
|
233
|
+
total: s.total ?? 0,
|
|
234
|
+
used: s.used ?? 0,
|
|
235
|
+
avail: s.avail ?? 0,
|
|
236
|
+
shared: !!s.shared,
|
|
237
|
+
enabled: s.enabled !== 0,
|
|
238
|
+
active: s.active !== 0,
|
|
239
|
+
})),
|
|
240
|
+
warnings,
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const vmStatus: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
245
|
+
const vmid = params?.vmid as number;
|
|
246
|
+
if (vmid == null) throw new Error('vmid parameter is required');
|
|
247
|
+
|
|
248
|
+
const data = (await proxmoxGet('/cluster/resources', config, credentials, fetchFn, {
|
|
249
|
+
type: 'vm',
|
|
250
|
+
})) as {
|
|
251
|
+
data?: Array<{
|
|
252
|
+
vmid?: number;
|
|
253
|
+
name?: string;
|
|
254
|
+
status?: string;
|
|
255
|
+
node?: string;
|
|
256
|
+
type?: string;
|
|
257
|
+
uptime?: number;
|
|
258
|
+
cpu?: number;
|
|
259
|
+
mem?: number;
|
|
260
|
+
maxmem?: number;
|
|
261
|
+
lock?: string;
|
|
262
|
+
hastate?: string;
|
|
263
|
+
}>;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const vm = (data.data ?? []).find((r) => r.vmid === vmid);
|
|
267
|
+
if (!vm) throw new Error(`VM/container ${vmid} not found in cluster`);
|
|
268
|
+
|
|
269
|
+
const warnings: string[] = [];
|
|
270
|
+
if (vm.status === 'stopped') {
|
|
271
|
+
warnings.push('VM is stopped');
|
|
272
|
+
}
|
|
273
|
+
if (vm.lock) {
|
|
274
|
+
warnings.push(`VM has lock: ${vm.lock}`);
|
|
275
|
+
}
|
|
276
|
+
if (vm.hastate && vm.hastate !== 'managed' && vm.hastate !== 'started') {
|
|
277
|
+
warnings.push(`HA state: ${vm.hastate}`);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
vmid: vm.vmid,
|
|
282
|
+
name: vm.name,
|
|
283
|
+
status: vm.status,
|
|
284
|
+
node: vm.node,
|
|
285
|
+
type: vm.type,
|
|
286
|
+
uptime: vm.uptime ?? 0,
|
|
287
|
+
cpu: vm.cpu ?? 0,
|
|
288
|
+
mem: vm.mem ?? 0,
|
|
289
|
+
maxmem: vm.maxmem ?? 0,
|
|
290
|
+
lock: vm.lock ?? null,
|
|
291
|
+
hastate: vm.hastate ?? null,
|
|
292
|
+
warnings,
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const vmConfig: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
297
|
+
const vmid = params?.vmid as number;
|
|
298
|
+
if (vmid == null) throw new Error('vmid parameter is required');
|
|
299
|
+
|
|
300
|
+
let node = params?.node as string | undefined;
|
|
301
|
+
if (!node) {
|
|
302
|
+
const resolved = await resolveNode(vmid, config, credentials, fetchFn);
|
|
303
|
+
node = resolved.node;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const data = (await proxmoxGet(
|
|
307
|
+
`/nodes/${node}/qemu/${vmid}/config`,
|
|
308
|
+
config,
|
|
309
|
+
credentials,
|
|
310
|
+
fetchFn,
|
|
311
|
+
)) as { data?: Record<string, unknown> };
|
|
312
|
+
|
|
313
|
+
const cfg = data.data ?? {};
|
|
314
|
+
const diskKeys = ['scsi', 'ide', 'virtio', 'sata', 'efidisk', 'tpmstate'];
|
|
315
|
+
const disks: Array<{ key: string; storage: string; format: string; size: string }> = [];
|
|
316
|
+
|
|
317
|
+
for (const [key, value] of Object.entries(cfg)) {
|
|
318
|
+
if (typeof value !== 'string') continue;
|
|
319
|
+
const matchesDisk = diskKeys.some((prefix) => key.startsWith(prefix));
|
|
320
|
+
if (!matchesDisk) continue;
|
|
321
|
+
|
|
322
|
+
// Parse: "local-lvm:vm-100-disk-0,size=32G" or "local:iso/file.iso,media=cdrom"
|
|
323
|
+
const colonIdx = value.indexOf(':');
|
|
324
|
+
if (colonIdx === -1) continue;
|
|
325
|
+
|
|
326
|
+
const storage = value.slice(0, colonIdx);
|
|
327
|
+
const rest = value.slice(colonIdx + 1);
|
|
328
|
+
const commaIdx = rest.indexOf(',');
|
|
329
|
+
const volPart = commaIdx > -1 ? rest.slice(0, commaIdx) : rest;
|
|
330
|
+
const optsPart = commaIdx > -1 ? rest.slice(commaIdx + 1) : '';
|
|
331
|
+
|
|
332
|
+
// Extract format from volume name or options
|
|
333
|
+
let format = 'raw';
|
|
334
|
+
if (volPart.endsWith('.qcow2')) format = 'qcow2';
|
|
335
|
+
else if (volPart.endsWith('.vmdk')) format = 'vmdk';
|
|
336
|
+
else if (optsPart.includes('format=qcow2')) format = 'qcow2';
|
|
337
|
+
else if (optsPart.includes('format=vmdk')) format = 'vmdk';
|
|
338
|
+
else if (optsPart.includes('format=raw')) format = 'raw';
|
|
339
|
+
|
|
340
|
+
// Extract size
|
|
341
|
+
const sizeMatch = optsPart.match(/size=(\S+)/);
|
|
342
|
+
const size = sizeMatch?.[1] ?? '';
|
|
343
|
+
|
|
344
|
+
disks.push({ key, storage, format, size });
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const warnings: string[] = [];
|
|
348
|
+
// Warn if local storage on potentially HA-managed VM
|
|
349
|
+
for (const d of disks) {
|
|
350
|
+
if (d.storage === 'local' || d.storage === 'local-lvm') {
|
|
351
|
+
warnings.push(`Disk ${d.key} uses local storage (${d.storage}) — not shared for HA`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
vmid,
|
|
357
|
+
node,
|
|
358
|
+
config: cfg,
|
|
359
|
+
disks,
|
|
360
|
+
warnings,
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const vmSnapshots: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
365
|
+
const vmid = params?.vmid as number;
|
|
366
|
+
if (vmid == null) throw new Error('vmid parameter is required');
|
|
367
|
+
|
|
368
|
+
let node = params?.node as string | undefined;
|
|
369
|
+
if (!node) {
|
|
370
|
+
const resolved = await resolveNode(vmid, config, credentials, fetchFn);
|
|
371
|
+
node = resolved.node;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const data = (await proxmoxGet(
|
|
375
|
+
`/nodes/${node}/qemu/${vmid}/snapshot`,
|
|
376
|
+
config,
|
|
377
|
+
credentials,
|
|
378
|
+
fetchFn,
|
|
379
|
+
)) as {
|
|
380
|
+
data?: Array<{
|
|
381
|
+
name?: string;
|
|
382
|
+
description?: string;
|
|
383
|
+
snaptime?: number;
|
|
384
|
+
parent?: string;
|
|
385
|
+
}>;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
const snapshots = (data.data ?? []).filter((s) => s.name !== 'current');
|
|
389
|
+
const now = Date.now() / 1000;
|
|
390
|
+
const sevenDays = 7 * 24 * 60 * 60;
|
|
391
|
+
|
|
392
|
+
const warnings: string[] = [];
|
|
393
|
+
for (const s of snapshots) {
|
|
394
|
+
if (s.snaptime && now - s.snaptime > sevenDays) {
|
|
395
|
+
warnings.push(`Snapshot "${s.name}" is older than 7 days`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return {
|
|
400
|
+
vmid,
|
|
401
|
+
node,
|
|
402
|
+
snapshots: snapshots.map((s) => ({
|
|
403
|
+
name: s.name,
|
|
404
|
+
description: s.description ?? '',
|
|
405
|
+
snaptime: s.snaptime ?? null,
|
|
406
|
+
parent: s.parent ?? null,
|
|
407
|
+
})),
|
|
408
|
+
warnings,
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
const storageContent: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
413
|
+
const node = params?.node as string;
|
|
414
|
+
const storage = params?.storage as string;
|
|
415
|
+
if (!node) throw new Error('node parameter is required');
|
|
416
|
+
if (!storage) throw new Error('storage parameter is required');
|
|
417
|
+
|
|
418
|
+
const vmidFilter = params?.vmid as number | undefined;
|
|
419
|
+
|
|
420
|
+
const data = (await proxmoxGet(
|
|
421
|
+
`/nodes/${node}/storage/${storage}/content`,
|
|
422
|
+
config,
|
|
423
|
+
credentials,
|
|
424
|
+
fetchFn,
|
|
425
|
+
)) as {
|
|
426
|
+
data?: Array<{
|
|
427
|
+
volid?: string;
|
|
428
|
+
vmid?: number;
|
|
429
|
+
size?: number;
|
|
430
|
+
format?: string;
|
|
431
|
+
}>;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
let volumes = data.data ?? [];
|
|
435
|
+
if (vmidFilter != null) {
|
|
436
|
+
volumes = volumes.filter((v) => v.vmid === vmidFilter);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return {
|
|
440
|
+
volumes: volumes.map((v) => ({
|
|
441
|
+
volid: v.volid,
|
|
442
|
+
vmid: v.vmid ?? null,
|
|
443
|
+
size: v.size ?? 0,
|
|
444
|
+
format: v.format ?? null,
|
|
445
|
+
})),
|
|
446
|
+
count: volumes.length,
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
const clusterTasks: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
451
|
+
const vmidFilter = params?.vmid as number | undefined;
|
|
452
|
+
const limit = (params?.limit as number) || 50;
|
|
453
|
+
|
|
454
|
+
const data = (await proxmoxGet('/cluster/tasks', config, credentials, fetchFn)) as {
|
|
455
|
+
data?: Array<{
|
|
456
|
+
upid?: string;
|
|
457
|
+
type?: string;
|
|
458
|
+
status?: string;
|
|
459
|
+
starttime?: number;
|
|
460
|
+
endtime?: number;
|
|
461
|
+
node?: string;
|
|
462
|
+
user?: string;
|
|
463
|
+
id?: string;
|
|
464
|
+
}>;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
let tasks = data.data ?? [];
|
|
468
|
+
|
|
469
|
+
if (vmidFilter != null) {
|
|
470
|
+
const vmidStr = String(vmidFilter);
|
|
471
|
+
tasks = tasks.filter((t) => t.id === vmidStr);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
tasks = tasks.slice(0, limit);
|
|
475
|
+
|
|
476
|
+
const warnings: string[] = [];
|
|
477
|
+
for (const t of tasks) {
|
|
478
|
+
if (t.status && t.status !== 'OK' && t.status !== '' && t.endtime) {
|
|
479
|
+
warnings.push(`Task ${t.type} on ${t.node} failed: ${t.status}`);
|
|
480
|
+
}
|
|
481
|
+
if (t.type === 'qmigrate' && !t.endtime) {
|
|
482
|
+
warnings.push(`Migration in progress on ${t.node}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return {
|
|
487
|
+
tasks: tasks.map((t) => ({
|
|
488
|
+
upid: t.upid,
|
|
489
|
+
type: t.type,
|
|
490
|
+
status: t.status ?? null,
|
|
491
|
+
starttime: t.starttime ?? null,
|
|
492
|
+
endtime: t.endtime ?? null,
|
|
493
|
+
node: t.node,
|
|
494
|
+
user: t.user ?? null,
|
|
495
|
+
})),
|
|
496
|
+
warnings,
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
const nodeLvm: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
501
|
+
const node = params?.node as string;
|
|
502
|
+
if (!node) throw new Error('node parameter is required');
|
|
503
|
+
|
|
504
|
+
const data = (await proxmoxGet(`/nodes/${node}/disks/lvm`, config, credentials, fetchFn)) as {
|
|
505
|
+
data?: Array<{
|
|
506
|
+
name?: string;
|
|
507
|
+
size?: number;
|
|
508
|
+
free?: number;
|
|
509
|
+
pvs?: number;
|
|
510
|
+
lvs?: number;
|
|
511
|
+
children?: unknown[];
|
|
512
|
+
}>;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
const volumeGroups = data.data ?? [];
|
|
516
|
+
const warnings: string[] = [];
|
|
517
|
+
|
|
518
|
+
for (const vg of volumeGroups) {
|
|
519
|
+
if (vg.free != null && vg.free === 0) {
|
|
520
|
+
warnings.push(`Volume group ${vg.name} has no free space`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return {
|
|
525
|
+
volumeGroups: volumeGroups.map((vg) => ({
|
|
526
|
+
name: vg.name,
|
|
527
|
+
size: vg.size ?? 0,
|
|
528
|
+
free: vg.free ?? 0,
|
|
529
|
+
pvs: vg.pvs ?? 0,
|
|
530
|
+
lvs: vg.lvs ?? 0,
|
|
531
|
+
})),
|
|
532
|
+
warnings,
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
const lxcStatus: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
537
|
+
const vmid = params?.vmid as number;
|
|
538
|
+
if (vmid == null) throw new Error('vmid parameter is required');
|
|
539
|
+
|
|
540
|
+
let node = params?.node as string | undefined;
|
|
541
|
+
if (!node) {
|
|
542
|
+
const resolved = await resolveNode(vmid, config, credentials, fetchFn);
|
|
543
|
+
if (resolved.type !== 'lxc') {
|
|
544
|
+
throw new Error(`VMID ${vmid} is not an LXC container (type: ${resolved.type})`);
|
|
545
|
+
}
|
|
546
|
+
node = resolved.node;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const data = (await proxmoxGet(
|
|
550
|
+
`/nodes/${node}/lxc/${vmid}/status/current`,
|
|
551
|
+
config,
|
|
552
|
+
credentials,
|
|
553
|
+
fetchFn,
|
|
554
|
+
)) as {
|
|
555
|
+
data?: {
|
|
556
|
+
vmid?: number;
|
|
557
|
+
name?: string;
|
|
558
|
+
status?: string;
|
|
559
|
+
uptime?: number;
|
|
560
|
+
cpu?: number;
|
|
561
|
+
mem?: number;
|
|
562
|
+
maxmem?: number;
|
|
563
|
+
disk?: number;
|
|
564
|
+
maxdisk?: number;
|
|
565
|
+
swap?: number;
|
|
566
|
+
maxswap?: number;
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
const ct = data.data ?? {};
|
|
571
|
+
const warnings: string[] = [];
|
|
572
|
+
if (ct.status === 'stopped') {
|
|
573
|
+
warnings.push('Container is stopped');
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return {
|
|
577
|
+
vmid: ct.vmid ?? vmid,
|
|
578
|
+
name: ct.name ?? null,
|
|
579
|
+
status: ct.status ?? null,
|
|
580
|
+
node,
|
|
581
|
+
uptime: ct.uptime ?? 0,
|
|
582
|
+
cpu: ct.cpu ?? 0,
|
|
583
|
+
mem: ct.mem ?? 0,
|
|
584
|
+
maxmem: ct.maxmem ?? 0,
|
|
585
|
+
disk: ct.disk ?? 0,
|
|
586
|
+
maxdisk: ct.maxdisk ?? 0,
|
|
587
|
+
swap: ct.swap ?? 0,
|
|
588
|
+
maxswap: ct.maxswap ?? 0,
|
|
589
|
+
warnings,
|
|
590
|
+
};
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
const lxcConfig: IntegrationProbeHandler = async (params, config, credentials, fetchFn) => {
|
|
594
|
+
const vmid = params?.vmid as number;
|
|
595
|
+
if (vmid == null) throw new Error('vmid parameter is required');
|
|
596
|
+
|
|
597
|
+
let node = params?.node as string | undefined;
|
|
598
|
+
if (!node) {
|
|
599
|
+
const resolved = await resolveNode(vmid, config, credentials, fetchFn);
|
|
600
|
+
node = resolved.node;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const data = (await proxmoxGet(
|
|
604
|
+
`/nodes/${node}/lxc/${vmid}/config`,
|
|
605
|
+
config,
|
|
606
|
+
credentials,
|
|
607
|
+
fetchFn,
|
|
608
|
+
)) as { data?: Record<string, unknown> };
|
|
609
|
+
|
|
610
|
+
const cfg = data.data ?? {};
|
|
611
|
+
|
|
612
|
+
// Parse rootfs: "local-lvm:subvol-200-disk-0,size=8G"
|
|
613
|
+
let rootfs: { storage: string; size: string } | null = null;
|
|
614
|
+
if (typeof cfg.rootfs === 'string') {
|
|
615
|
+
const colonIdx = (cfg.rootfs as string).indexOf(':');
|
|
616
|
+
if (colonIdx > -1) {
|
|
617
|
+
const storage = (cfg.rootfs as string).slice(0, colonIdx);
|
|
618
|
+
const rest = (cfg.rootfs as string).slice(colonIdx + 1);
|
|
619
|
+
const sizeMatch = rest.match(/size=(\S+)/);
|
|
620
|
+
rootfs = { storage, size: sizeMatch?.[1] ?? '' };
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// Parse mp0–mp9 mountpoints
|
|
625
|
+
const mountpoints: Array<{ key: string; storage: string; mountpoint: string; size: string }> = [];
|
|
626
|
+
for (const [key, value] of Object.entries(cfg)) {
|
|
627
|
+
if (!/^mp\d+$/.test(key) || typeof value !== 'string') continue;
|
|
628
|
+
const colonIdx = value.indexOf(':');
|
|
629
|
+
if (colonIdx === -1) continue;
|
|
630
|
+
|
|
631
|
+
const storage = value.slice(0, colonIdx);
|
|
632
|
+
const rest = value.slice(colonIdx + 1);
|
|
633
|
+
const mpMatch = rest.match(/mp=([^,]+)/);
|
|
634
|
+
const sizeMatch = rest.match(/size=(\S+)/);
|
|
635
|
+
mountpoints.push({
|
|
636
|
+
key,
|
|
637
|
+
storage,
|
|
638
|
+
mountpoint: mpMatch?.[1] ?? '',
|
|
639
|
+
size: sizeMatch?.[1] ?? '',
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
const warnings: string[] = [];
|
|
644
|
+
|
|
645
|
+
return {
|
|
646
|
+
vmid,
|
|
647
|
+
node,
|
|
648
|
+
config: cfg,
|
|
649
|
+
rootfs,
|
|
650
|
+
mountpoints,
|
|
651
|
+
warnings,
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
const clusterResources: IntegrationProbeHandler = async (_params, config, credentials, fetchFn) => {
|
|
656
|
+
const data = (await proxmoxGet('/cluster/resources', config, credentials, fetchFn, {
|
|
657
|
+
type: 'vm',
|
|
658
|
+
})) as {
|
|
659
|
+
data?: Array<{
|
|
660
|
+
vmid?: number;
|
|
661
|
+
name?: string;
|
|
662
|
+
node?: string;
|
|
663
|
+
type?: string;
|
|
664
|
+
status?: string;
|
|
665
|
+
uptime?: number;
|
|
666
|
+
cpu?: number;
|
|
667
|
+
mem?: number;
|
|
668
|
+
maxmem?: number;
|
|
669
|
+
hastate?: string;
|
|
670
|
+
lock?: string;
|
|
671
|
+
}>;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
const resources = data.data ?? [];
|
|
675
|
+
return {
|
|
676
|
+
resources: resources.map((r) => ({
|
|
677
|
+
vmid: r.vmid,
|
|
678
|
+
name: r.name ?? null,
|
|
679
|
+
node: r.node,
|
|
680
|
+
type: r.type,
|
|
681
|
+
status: r.status,
|
|
682
|
+
uptime: r.uptime ?? 0,
|
|
683
|
+
cpu: r.cpu ?? 0,
|
|
684
|
+
mem: r.mem ?? 0,
|
|
685
|
+
maxmem: r.maxmem ?? 0,
|
|
686
|
+
hastate: r.hastate ?? null,
|
|
687
|
+
lock: r.lock ?? null,
|
|
688
|
+
})),
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const cephStatus: IntegrationProbeHandler = async (_params, config, credentials, fetchFn) => {
|
|
693
|
+
let statusData: {
|
|
694
|
+
data?: {
|
|
695
|
+
health?: { status?: string };
|
|
696
|
+
osdmap?: { osdmap?: { num_osds?: number; num_up_osds?: number; num_in_osds?: number } };
|
|
697
|
+
pgmap?: {
|
|
698
|
+
pgs_by_state?: Array<{ state_name?: string; count?: number }>;
|
|
699
|
+
bytes_total?: number;
|
|
700
|
+
bytes_used?: number;
|
|
701
|
+
bytes_avail?: number;
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
try {
|
|
707
|
+
statusData = (await proxmoxGet(
|
|
708
|
+
'/cluster/ceph/status',
|
|
709
|
+
config,
|
|
710
|
+
credentials,
|
|
711
|
+
fetchFn,
|
|
712
|
+
)) as typeof statusData;
|
|
713
|
+
} catch (err) {
|
|
714
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
715
|
+
if (msg.includes('404') || msg.includes('501')) {
|
|
716
|
+
return {
|
|
717
|
+
available: false,
|
|
718
|
+
health: null,
|
|
719
|
+
warnings: ['Ceph is not configured on this cluster'],
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
throw err;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const ceph = statusData.data ?? {};
|
|
726
|
+
const osdmap = ceph.osdmap?.osdmap ?? {};
|
|
727
|
+
const pgmap = ceph.pgmap ?? {};
|
|
728
|
+
const health = ceph.health?.status ?? 'unknown';
|
|
729
|
+
|
|
730
|
+
const warnings: string[] = [];
|
|
731
|
+
if (health !== 'HEALTH_OK') {
|
|
732
|
+
warnings.push(`Ceph health: ${health}`);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
const osdCount = osdmap.num_osds ?? 0;
|
|
736
|
+
const osdUp = osdmap.num_up_osds ?? 0;
|
|
737
|
+
if (osdCount > 0 && osdUp < osdCount) {
|
|
738
|
+
warnings.push(`${osdCount - osdUp} OSD(s) down`);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// Try to get OSD details from first node
|
|
742
|
+
let osds: Array<{ id: number; name: string; status: string }> = [];
|
|
743
|
+
try {
|
|
744
|
+
// Get nodes list to find first available node
|
|
745
|
+
const nodesData = (await proxmoxGet('/nodes', config, credentials, fetchFn)) as {
|
|
746
|
+
data?: Array<{ node?: string; status?: string }>;
|
|
747
|
+
};
|
|
748
|
+
const firstNode = (nodesData.data ?? []).find((n) => n.status === 'online');
|
|
749
|
+
if (firstNode?.node) {
|
|
750
|
+
const osdData = (await proxmoxGet(
|
|
751
|
+
`/nodes/${firstNode.node}/ceph/osd`,
|
|
752
|
+
config,
|
|
753
|
+
credentials,
|
|
754
|
+
fetchFn,
|
|
755
|
+
)) as {
|
|
756
|
+
data?: Array<{ id?: number; name?: string; status?: string; in?: number; up?: number }>;
|
|
757
|
+
};
|
|
758
|
+
osds = (osdData.data ?? []).map((o) => ({
|
|
759
|
+
id: o.id ?? 0,
|
|
760
|
+
name: o.name ?? `osd.${o.id ?? 0}`,
|
|
761
|
+
status: o.up ? 'up' : 'down',
|
|
762
|
+
}));
|
|
763
|
+
}
|
|
764
|
+
} catch {
|
|
765
|
+
// OSD detail is best-effort
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
return {
|
|
769
|
+
available: true,
|
|
770
|
+
health,
|
|
771
|
+
osdCount,
|
|
772
|
+
osdUp,
|
|
773
|
+
osdIn: osdmap.num_in_osds ?? 0,
|
|
774
|
+
pgStates: (pgmap.pgs_by_state ?? []).map((p) => ({
|
|
775
|
+
state: p.state_name,
|
|
776
|
+
count: p.count,
|
|
777
|
+
})),
|
|
778
|
+
usage: {
|
|
779
|
+
total: pgmap.bytes_total ?? 0,
|
|
780
|
+
used: pgmap.bytes_used ?? 0,
|
|
781
|
+
avail: pgmap.bytes_avail ?? 0,
|
|
782
|
+
},
|
|
783
|
+
osds,
|
|
784
|
+
warnings,
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
// --- Pack definition ---
|
|
789
|
+
|
|
790
|
+
export const proxmoxPack: IntegrationPack = {
|
|
791
|
+
manifest: {
|
|
792
|
+
name: 'proxmox',
|
|
793
|
+
type: 'integration',
|
|
794
|
+
version: '0.1.0',
|
|
795
|
+
description: 'Proxmox VE cluster — nodes, VMs, containers, storage, Ceph, and HA status',
|
|
796
|
+
requires: { groups: [], files: [], commands: [] },
|
|
797
|
+
probes: [
|
|
798
|
+
{
|
|
799
|
+
name: 'cluster.status',
|
|
800
|
+
description: 'Cluster status including quorum and node health',
|
|
801
|
+
capability: 'observe',
|
|
802
|
+
params: {},
|
|
803
|
+
timeout: 15000,
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
name: 'cluster.ha.status',
|
|
807
|
+
description: 'HA manager status and resource states',
|
|
808
|
+
capability: 'observe',
|
|
809
|
+
params: {},
|
|
810
|
+
timeout: 15000,
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
name: 'nodes.list',
|
|
814
|
+
description: 'List all nodes with CPU, memory, and status',
|
|
815
|
+
capability: 'observe',
|
|
816
|
+
params: {},
|
|
817
|
+
timeout: 15000,
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
name: 'node.storage',
|
|
821
|
+
description: 'Storage pools for a specific node',
|
|
822
|
+
capability: 'observe',
|
|
823
|
+
params: {
|
|
824
|
+
node: { type: 'string', description: 'Node name', required: true },
|
|
825
|
+
},
|
|
826
|
+
timeout: 15000,
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
name: 'vm.status',
|
|
830
|
+
description: 'VM status by VMID (searches cluster-wide)',
|
|
831
|
+
capability: 'observe',
|
|
832
|
+
params: {
|
|
833
|
+
vmid: { type: 'number', description: 'VM ID', required: true },
|
|
834
|
+
},
|
|
835
|
+
timeout: 15000,
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
name: 'vm.config',
|
|
839
|
+
description: 'VM configuration with parsed disk entries',
|
|
840
|
+
capability: 'observe',
|
|
841
|
+
params: {
|
|
842
|
+
vmid: { type: 'number', description: 'VM ID', required: true },
|
|
843
|
+
node: {
|
|
844
|
+
type: 'string',
|
|
845
|
+
description: 'Node name (auto-resolved if omitted)',
|
|
846
|
+
required: false,
|
|
847
|
+
},
|
|
848
|
+
},
|
|
849
|
+
timeout: 15000,
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
name: 'vm.snapshots',
|
|
853
|
+
description: 'VM snapshots with age warnings',
|
|
854
|
+
capability: 'observe',
|
|
855
|
+
params: {
|
|
856
|
+
vmid: { type: 'number', description: 'VM ID', required: true },
|
|
857
|
+
node: {
|
|
858
|
+
type: 'string',
|
|
859
|
+
description: 'Node name (auto-resolved if omitted)',
|
|
860
|
+
required: false,
|
|
861
|
+
},
|
|
862
|
+
},
|
|
863
|
+
timeout: 15000,
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
name: 'storage.content',
|
|
867
|
+
description: 'List volumes in a storage pool',
|
|
868
|
+
capability: 'observe',
|
|
869
|
+
params: {
|
|
870
|
+
node: { type: 'string', description: 'Node name', required: true },
|
|
871
|
+
storage: { type: 'string', description: 'Storage ID', required: true },
|
|
872
|
+
vmid: {
|
|
873
|
+
type: 'number',
|
|
874
|
+
description: 'Filter by VM ID',
|
|
875
|
+
required: false,
|
|
876
|
+
},
|
|
877
|
+
},
|
|
878
|
+
timeout: 15000,
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
name: 'cluster.tasks',
|
|
882
|
+
description: 'Recent cluster tasks with failure detection',
|
|
883
|
+
capability: 'observe',
|
|
884
|
+
params: {
|
|
885
|
+
vmid: {
|
|
886
|
+
type: 'number',
|
|
887
|
+
description: 'Filter by VM ID',
|
|
888
|
+
required: false,
|
|
889
|
+
},
|
|
890
|
+
limit: {
|
|
891
|
+
type: 'number',
|
|
892
|
+
description: 'Max results (default: 50)',
|
|
893
|
+
required: false,
|
|
894
|
+
},
|
|
895
|
+
},
|
|
896
|
+
timeout: 15000,
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
name: 'node.lvm',
|
|
900
|
+
description: 'LVM volume groups on a node',
|
|
901
|
+
capability: 'observe',
|
|
902
|
+
params: {
|
|
903
|
+
node: { type: 'string', description: 'Node name', required: true },
|
|
904
|
+
},
|
|
905
|
+
timeout: 15000,
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
name: 'lxc.status',
|
|
909
|
+
description: 'LXC container status with resource usage',
|
|
910
|
+
capability: 'observe',
|
|
911
|
+
params: {
|
|
912
|
+
vmid: { type: 'number', description: 'Container VMID', required: true },
|
|
913
|
+
node: {
|
|
914
|
+
type: 'string',
|
|
915
|
+
description: 'Node name (auto-resolved if omitted)',
|
|
916
|
+
required: false,
|
|
917
|
+
},
|
|
918
|
+
},
|
|
919
|
+
timeout: 15000,
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
name: 'lxc.config',
|
|
923
|
+
description: 'LXC container configuration with parsed mountpoints',
|
|
924
|
+
capability: 'observe',
|
|
925
|
+
params: {
|
|
926
|
+
vmid: { type: 'number', description: 'Container VMID', required: true },
|
|
927
|
+
node: {
|
|
928
|
+
type: 'string',
|
|
929
|
+
description: 'Node name (auto-resolved if omitted)',
|
|
930
|
+
required: false,
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
timeout: 15000,
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
name: 'ceph.status',
|
|
937
|
+
description: 'Ceph cluster health, OSD status, and usage',
|
|
938
|
+
capability: 'observe',
|
|
939
|
+
params: {},
|
|
940
|
+
timeout: 30000,
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
name: 'cluster.resources',
|
|
944
|
+
description: 'List all VMs and containers across the cluster',
|
|
945
|
+
capability: 'observe',
|
|
946
|
+
params: {},
|
|
947
|
+
timeout: 15000,
|
|
948
|
+
},
|
|
949
|
+
],
|
|
950
|
+
runbook: {
|
|
951
|
+
category: 'virtualization',
|
|
952
|
+
probes: ['cluster.status', 'nodes.list', 'ceph.status'],
|
|
953
|
+
parallel: true,
|
|
954
|
+
},
|
|
955
|
+
},
|
|
956
|
+
|
|
957
|
+
handlers: {
|
|
958
|
+
'cluster.status': clusterStatus,
|
|
959
|
+
'cluster.ha.status': clusterHaStatus,
|
|
960
|
+
'nodes.list': nodesList,
|
|
961
|
+
'node.storage': nodeStorage,
|
|
962
|
+
'vm.status': vmStatus,
|
|
963
|
+
'vm.config': vmConfig,
|
|
964
|
+
'vm.snapshots': vmSnapshots,
|
|
965
|
+
'storage.content': storageContent,
|
|
966
|
+
'cluster.tasks': clusterTasks,
|
|
967
|
+
'node.lvm': nodeLvm,
|
|
968
|
+
'lxc.status': lxcStatus,
|
|
969
|
+
'lxc.config': lxcConfig,
|
|
970
|
+
'ceph.status': cephStatus,
|
|
971
|
+
'cluster.resources': clusterResources,
|
|
972
|
+
},
|
|
973
|
+
|
|
974
|
+
testConnection: async (config, credentials, fetchFn) => {
|
|
975
|
+
try {
|
|
976
|
+
const url = proxmoxUrl(config.endpoint, '/version');
|
|
977
|
+
const headers: Record<string, string> = {
|
|
978
|
+
Accept: 'application/json',
|
|
979
|
+
...buildAuthHeaders(credentials),
|
|
980
|
+
...config.headers,
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
const res = await fetchFn(url, { headers });
|
|
984
|
+
return res.ok;
|
|
985
|
+
} catch {
|
|
986
|
+
return false;
|
|
987
|
+
}
|
|
988
|
+
},
|
|
989
|
+
};
|