我想配置特定于虚拟机的报告。例如,我想获取 pdf 格式的特定虚拟机的以下指标的报告。请告诉我如何实现这一点?
我也尝试过使用 PowerShell,但由于时间和日期与各种指标不匹配而出现错误
$resource = 'Server01'
$cred = Get-Credential
try {
Connect-OMServer "vrops.example.com" -Username $username -Password $password -ErrorAction Stop | Out-Null
Write-Host "Connected to vROPS server"
}
catch {
Write-Host "Failed to connect to vROPS server." ($_.Exception.Message)
exit
}
$today = Get-Date
$last30days = $today.AddDays(-30).
$demandmhz = Get-OMStat -Resource $resource -Key 'cpu|demandmhz' -From $last30days -To $today -ErrorAction Stop
$demandper = Get-OMStat -Resource $resource -Key 'cpu|demandPct' -From $last30days -To $today -ErrorAction Stop
$usageper = Get-OMStat -Resource $resource -Key 'cpu|usage_average' -From $last30days -To $today -ErrorAction Stop
$usagemhz = Get-OMStat -Resource $resource -Key 'cpu|usagemhz_average' -From $last30days -To $today -ErrorAction Stop
$cpu = [PSCustomObject]@{
Resource = $resource
DemandMhz = $demandmhz.Value
DemandPer = $demandper.Value
UsagePer = $usageper.Value
UsageMhz = $usagemhz.Value
}
$cpu | Export-Csv -Path "C:\temp\cpu.csv" -NoTypeInformation -Append
我想要使用 powershell 或 REST API 来报告上述要求
我找到了解决问题的方法。 Link 使用 GET /api/reportdefinitions API 获取虚拟机资源 ID,并使用 GET /api/reports API 获取 reportDefinition ID。然后使用 POST /api/reports API 触发报告。最后使用 GET /api/reports/{id}/download API 下载报告