I have the following custom script:
$connection = Connect-VIServer -Server xxx.xxx.xxx.xxx -User xxxx -Password xxxx Write-Host "<prtg>" ForEach ($VM in Get-VM | where-object {($_.powerstate -ne "PoweredOff") }){ ForEach ($Drive in $VM.Extensiondata.Guest.Disk) { $Path = $Drive.DiskPath #Calculations $Freespace = [math]::Round($Drive.FreeSpace / 1MB) $Capacity = [math]::Round($Drive.Capacity/ 1MB) $PercentFree = [math]::Round(($FreeSpace)/ ($Capacity) * 100) #VMs with less space if ($PercentFree -lt 20) { $message = "$VM $Path" Write-Host "<result>" Write-Host "<channel>$message</channel>" write-host "<LimitMinWarning>20</LimitMinWarning>" write-host "<LimitMinError>10</LimitMinError>" Write-Host "<LimitMode>1</LimitMode>" Write-Host "<value>$PercentFree</value>" Write-Host "<unit>Percent</unit>" Write-Host "</result>" } } } Write-Host "</prtg>"
An if I try to use it as a sensor I get a JSON error.