Hi
I have the following script (I know the output format isn't correct) that I would like to use to monitor a Hyper-v Cluster.
Script Start ========== function Get-ClusterVM { [CmdletBinding()] param( [Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the Cluster to fetch inventory from", ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [System.String] $ClusterName ) process { $Cluster = Get-Cluster -Name $ClusterName $HVHosts = $Cluster | Get-ClusterNode foreach ($HVHost in $HVHosts) { Get-VM -Computer $HVHost | where {$_.ResourceMeteringEnabled -like "False"} | Enable-VMResourceMetering $VMs = Get-VM -Computer $HVHost | Measure-VM foreach ($VM in $VMs) { write-host "*********" write-host "VMName: "$VM.VMName write-host "AvgCPU(Mhz): "$VM.AvgCPU write-host "AvgRAM(M): "$VM.AvgRAM write-host "AggregatedAverageNormalizedIOPS: "$VM.AggregatedAverageNormalizedIOPS write-host "AggregatedAverageLatency: "$VM.AggregatedAverageLatency write-host "AggregatedDiskDataRead: "$VM.AggregatedDiskDataRead write-host "AggregatedDiskDataWritten: "$VM.AggregatedDiskDataWritten write-host "MeteringDuration: "$VM.MeteringDuration $InboundTraffic = ($VM.NetworkMeteredTrafficReport | where {($_.Direction -eq "Inbound")} | measure-object TotalTraffic -sum).sum $OutboundTraffic = ($VM.NetworkMeteredTrafficReport | where {($_.Direction -eq "Outbound")} | measure-object TotalTraffic -sum).sum write-host "InboundTraffic(M): "$InboundTraffic write-host "OutboundTraffic(M): "$OutboundTraffic $TotalIO = ($VM.AggregatedDiskDataRead + $VM.AggregatedDiskDataWritten) if ($TotalIO -eq "0") { $ReadPercent = "0" $WritePercent = "0" } else { $ReadPercent = ($VM.AggregatedDiskDataRead/$TotalIO)*100 $ReadPercent = [math]::round($ReadPercent) $WritePercent = ($VM.AggregatedDiskDataWritten/$TotalIO)*100 $WritePercent = [math]::round($WritePercent) } write-host "Total IO: "$TotalIO write-host "% Read Data: "$ReadPercent write-host "% Write Data: "$WritePercent write-host "*********" #Cleanup Values $InboundTraffic = "" $OutboundTraffic = "" $TotalIO = "" $ReadPercent = "" $WritePercent = "" } Get-VM -Computer $HVHost | Reset-VMResourceMetering Get-VM -Computer $HVHost | Enable-VMResourceMetering } } } Get-ClusterVM -clustername $ClusterName Exit 0 =========
Does anyone know how to take each returned set of data (per VM in this instance) and create a sensor with multiple channels for that sensor? This Sensor would be update on subsequent runs
Any help is appreciated
Thanks
Article Comments
Hi
Thanks, but wont the above create multiple channels in a single sensor ?
Thanks
Jun, 2016 - Permalink
Hello rhyse,
thank you for your reply.
Yes, that's correct. Doing a "loop" for every instance will create a multi-channel sensor which isn't always desirable.
We've recently introduced (In PRTG 16.1.22) a way to do a so-called "metascan" for Exe-sensors, this way the sensor can do a "metascan" (where it will query the list of available instances) and deploy one sensor per instance, please review the official KB-post on the subject:
Best Regards,
Jul, 2016 - Permalink
Add something like this to the loop and take it from there:
Jun, 2016 - Permalink