I'm not sure whether vCenter and Hyper-V have the ability to perform custom actions on specific events, however I would recommend setting up a Scheduled Task to periodically run on some server (such as the PRTG Core); this will connect to both PRTG and vCenter, figure out which devices are missing from PRTG and then create those devices for you.
You can control vCenter and PRTG using PowerShell via the VMware PowerCLI and PrtgAPI
Connect-VIServer vcenter-1
if(!(Get-PrtgClient)
{
Connect-PrtgServer prtg.example.com (New-Credential username password)
}
$cloneSource = Get-Device -Id 1234
$vms = Get-VM
$devices = Get-Device | select -expand Name
$missingVMs = $vms | where { $_.Name -notin $devices }
foreach($vm in $missingVMs)
{
Write-Host "Creating device for VM '$($vm.Name)'"
$newDevice = $cloneSource | Clone-Object -DestinationId $cloneSource.ParentId $vm.Name
$newDevice | Resume-Object
$vm | Set-VM $vm -Notes "PRTG Device $($newDevice.Id)"
}
You would likely want to customize this a bit so that VMs that are stored in certain groups/have certain names etc are cloned from specific PRTG devices and then stored in custom groups, rather than storing all of your created devices under the parent of the clone source. Depending on your setup you may instead want to store your PRTG notes on the VM in a custom attribute / annotation, etc
Regards,
lordmilko
Add comment