66 lines
1.7 KiB
PowerShell
66 lines
1.7 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
. "$PSScriptRoot\ProxmoxAgent.ps1"
|
|
|
|
$results = New-Object System.Collections.Generic.List[object]
|
|
|
|
function Add-Result {
|
|
param(
|
|
[string]$Check,
|
|
[string]$Status,
|
|
[string]$Detail
|
|
)
|
|
|
|
$results.Add([pscustomobject]@{
|
|
Check = $Check
|
|
Status = $Status
|
|
Detail = $Detail
|
|
}) | Out-Null
|
|
}
|
|
|
|
$config = Get-ProxmoxConfig
|
|
|
|
try {
|
|
Assert-ProxmoxConfig | Out-Null
|
|
Add-Result "config" "PASS" "host=$($config.HostName), node=$($config.Node), key present"
|
|
}
|
|
catch {
|
|
Add-Result "config" "FAIL" $_.Exception.Message
|
|
}
|
|
|
|
try {
|
|
$sshOutput = Invoke-ProxmoxSshCommand -ConnectTimeoutSec 8 -Command "hostname && pveversion && pct list && qm list"
|
|
$summary = ($sshOutput | Select-Object -First 2) -join " | "
|
|
Add-Result "ssh-read" "PASS" $summary
|
|
}
|
|
catch {
|
|
Add-Result "ssh-read" "FAIL" $_.Exception.Message
|
|
}
|
|
|
|
try {
|
|
$dockerOutput = Invoke-ProxmoxSshCommand -ConnectTimeoutSec 8 -Command "pct exec $($config.CoolifyLxc) -- docker ps --format '{{.Names}}\t{{.Status}}' | head -n 8"
|
|
$count = @($dockerOutput | Where-Object { $_ }).Count
|
|
Add-Result "docker-lxc-$($config.CoolifyLxc)" "PASS" "$count containers sampled"
|
|
}
|
|
catch {
|
|
Add-Result "docker-lxc-$($config.CoolifyLxc)" "FAIL" $_.Exception.Message
|
|
}
|
|
|
|
if ($config.ApiTokenHeader) {
|
|
try {
|
|
$version = Invoke-ProxmoxApi -Path "/version"
|
|
Add-Result "api-auth" "PASS" "version=$($version.data.version), release=$($version.data.release)"
|
|
}
|
|
catch {
|
|
Add-Result "api-auth" "FAIL" $_.Exception.Message
|
|
}
|
|
}
|
|
else {
|
|
Add-Result "api-auth" "SKIP" "set PROXMOX_API_TOKEN_ID and PROXMOX_API_TOKEN_SECRET"
|
|
}
|
|
|
|
$results | Format-Table -AutoSize
|
|
|
|
if ($results.Status -contains "FAIL") {
|
|
exit 1
|
|
}
|