So this post is to help someone over at the vRops vmware communities, they wanted to dump all reports from vRops via the Suite-API so i wrote them a little script to help them on their way… used in conjunction with my first post vrops-suite-api-run-report they will be able to automatically generate all the reports as they please.
param ( [String]$vRopsAddress = 'vc.vman.ch', [String]$vRopscreds = 'vc' ) $ScriptPath = (Get-Item -Path ".\" -Verbose).FullName if($vRopscreds -gt ""){ $vRopscred = Import-Clixml -Path "$ScriptPath\config\$vRopscreds.xml" } else { echo "crednetials missing" Exit } #Take all certs. add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy $ContentType = "application/xml;charset=utf-8" $header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $header.Add("Accept", "application/xml") $url = "https://$vRopsAddress/suite-api/api/reportdefinitions" [xml]$Data = Invoke-RestMethod -Method GET -uri $url -ContentType $ContentType -Headers $header -Body $body -Credential $vRopscred $ReportList = @() Foreach($Report in $Data.'report-definitions'.'report-definition'){ $ReportList += New-Object PsObject -Property @{ Name = $Report.name id = $Report.id description = $Report.description 'traversal-spec-name' = [string]$Report.'traversal-specs'.'traversal-spec'.'name' 'rootAdapterKindKey' = [string]$Report.'traversal-specs'.'traversal-spec'.'rootAdapterKindKey' 'rootResourceKindKey' = [string]$Report.'traversal-specs'.'traversal-spec'.'rootResourceKindKey' } } $ReportList | select id,Name,description,traversal-spec-name,rootAdapterKindKey,rootResourceKindKey | Export-Csv 'c:\vrops\reportlist.csv' -NoTypeInformation Remove-Variable * -ErrorAction SilentlyContinue
Hi vMAN,
Nice post. But i have unique requirement of generating Average Host CPU Usage report for business hours, say for example, a monthly reports of Average CPU Usage between 8:00 AM and 6:00PM only. I tried a lot but there is no such option to generate. Is there any way to generate such a report in VROPS 6.2/6.3?
Any help in this regard is really appreciated.
Regards,
Anil Aliyan
In policies, select the Host system object, then at the bottom you have the “Time Range” which you can modify to track usage for specific days / timeranges… but obviously this has it’s downsides…
How do I use credential, If I need to hard code the username and password. Also, How can this script work without parameter?
My using the credentials files it is like hard coding it. Make the modifications to the script so that you don’t need to pass the parameters