-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add proxmox integration #1752
Changes from 1 commit
8e67ce9
f083905
9d0b07b
f9b0f82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import proxmoxApi from "proxmox-api"; | ||
|
||
import { Integration } from "../base/integration"; | ||
import type { HealthMonitoring } from "../interfaces/health-monitoring/healt-monitoring"; | ||
|
||
export class ProxmoxIntegration extends Integration { | ||
public async testConnectionAsync(): Promise<void> { | ||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // TODO: Can we improve this? | ||
const proxmox = this.getPromoxApi(); | ||
await proxmox.nodes.$get(); | ||
} | ||
|
||
public async getSystemInfoAsync(): Promise<HealthMonitoring> { | ||
const proxmox = this.getPromoxApi(); | ||
const resources = await proxmox.cluster.resources.$get(); | ||
|
||
let resourceSummary: ResourceSummary = { vms: [], lxcs: [], nodes: [], storage: [] }; | ||
resources.forEach((item) => { | ||
let resource: ResourceData = { | ||
id: item.id, | ||
cpu: item.cpu ? item.cpu : 0, | ||
maxCpu: item.maxcpu ? item.maxcpu : 0, | ||
maxMem: item.maxmem ? item.maxmem : 0, | ||
mem: item.mem ? item.mem : 0, | ||
name: item.name, | ||
node: item.node, | ||
status: item.status, | ||
running: false, | ||
type: item.type, | ||
uptime: item.uptime, | ||
vmId: item.vmid, | ||
netIn: item.netin, | ||
netOut: item.netout, | ||
diskRead: item.diskread, | ||
diskWrite: item.diskwrite, | ||
disk: item.disk, | ||
maxDisk: item.maxdisk, | ||
haState: item.hastate, | ||
storagePlugin: item.plugintype, | ||
storageShared: item.shared == 1, | ||
}; | ||
if (item.template == 0) { | ||
if (item.type === "qemu") { | ||
resource.running = resource.status === "running"; | ||
Check failure on line 44 in packages/integrations/src/proxmox/proxmox-integration.ts GitHub Actions / lint
|
||
resourceSummary.vms.push(resource); | ||
Check failure on line 45 in packages/integrations/src/proxmox/proxmox-integration.ts GitHub Actions / lint
|
||
} else if (item.type === "lxc") { | ||
resource.running = resource.status === "running"; | ||
resourceSummary.lxcs.push(resource); | ||
} | ||
} else if (item.type === "node") { | ||
resource.name = item.node; | ||
resource.running = resource.status === "online"; | ||
resourceSummary.nodes.push(resource); | ||
} else if (item.type === "storage") { | ||
resource.name = item.storage; | ||
resource.running = resource.status === "available"; | ||
resourceSummary.storage.push(resource); | ||
} | ||
}); | ||
} | ||
|
||
private getPromoxApi() { | ||
return proxmoxApi({ | ||
host: this.url("/").host, | ||
tokenID: `${this.getSecretValue("username")}@${this.getSecretValue("realm")}!${this.getSecretValue("tokenId")}`, | ||
tokenSecret: this.getSecretValue("apiKey"), | ||
}); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Check failure
Code scanning / CodeQL
Disabling certificate validation High
Copilot Autofix AI 27 days ago
To fix the problem, we need to ensure that TLS certificate validation is not disabled. Instead of setting
process.env.NODE_TLS_REJECT_UNAUTHORIZED
to "0", we should allow the default behavior of Node.js to validate certificates. If there is a need to handle self-signed certificates or certificates from a private CA, we should configure the application to trust those certificates explicitly.The best way to fix this without changing existing functionality is to remove the line that sets
process.env.NODE_TLS_REJECT_UNAUTHORIZED
to "0". If necessary, we can add logic to handle custom certificates securely.