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
Add comment