Having got the powercli for Cluster information. But need your help how i can convert this into dashboard in html format. Can we set some threshold to high light in red color using formula.
Example : If used capacity of CPU / Mem / Storage reaches 85% then should highlight in red color.
Get-Cluster -Server $vc | where{$_.ExtensionData.Host.Count -ne 0} | ForEach-Object -Process {
Write-Host "Looking at cluster $($_.Name)"
#$ds = Get-Datastore -RelatedObject $_ | where{$_.ExtensionData.Summary.MultipleHostAccess}
$sStat = @{
Entity = Get-Cluster -Name $_.Name
Stat = 'cpu.usage.average', 'mem.usage.average'
Start = (Get-Date).AddDays(-7)
# Start = (Get-Date).AddHours(-1)
Instance = '*'
ErrorAction = 'SilentlyContinue'
}
$stat = Get-Stat
$esx = Get-VMHost -Location $_
$hostthreads = ($esx.extensiondata.hardware.cpuinfo.numcputhreads | Measure-Object -Sum).Sum
$vm = Get-VM -Location $_ | where{$_.PowerState -eq "PoweredOn"}
$cpuTot = ($esx | Measure-Object -Property CpuTotalMhz -Sum).Sum
$cpuUse = ($esx | Measure-Object -Property CpuUsageMhz -Sum).Sum
$memTot = ($esx | Measure-Object -Property MemoryTotalGB -Sum).Sum
$memUse = ($esx | Measure-Object -Property MemoryUsageGB -Sum).Sum
$obj = [ordered]@{
#vCenter = $global:defaultviserver.Name
Cluster = $_.Name
'Total CPU Ghz' = [math]::Round($cpuTot/1000,0)
'CPU Usage' = "{0:P0}" -f ($cpuUse/$cpuTot)
'CPU 7-day' = "{0:P2}" -f (((($stat | where { $_.MetricId -eq 'cpu.usage.average' }).Value | Measure-Object -Average).Average)/100)
'CPU Free' = "{0:P0}" -f (($cpuTot - $cpuUse)/$cpuTot)
'Total RAM GB' = [math]::Round($memTot,0)
'RAM Usage' = "{0:P0}" -f ($memUse/$memTot)
'RAM 7-day' = "{0:P2}" -f (((($stat | where { $_.MetricId -eq 'mem.usage.average' }).Value | Measure-Object -Average).Average)/100)
'RAM Free GB' = "{0:P0}" -f (($memTot - $memUse)/$memTot)
#'Total Capacity GB' = [math]::Round(($ds.CapacityGB | Measure-Object -Sum).Sum,0)
#'Used Capacity GB' = [math]::Round(($ds | %{$_.CapacityGB - $_.FreeSpaceGB} | Measure-Object -Sum).Sum,0)
#'Free Capacity GB' = [math]::Round(($ds.FreeSpaceGB | Measure-Object -Sum).Sum,0)
'N° Hosts' = $_.ExtensionData.Host.Count
'N°VMs' = &{
$esxVM = Get-View -Id $_.ExtensionData.Host -Property VM
$vm = @()
if($esxVM.VM){
$vm = Get-View -Id $esxVM.VM -Property Summary.Config.Template |
where{-not $_.Summary.Config.Template}
}
$vm.Count
}
'vCPU' = ($vm.NumCpu | Measure-Object -Sum).Sum
'pCPU' = ($esx.NumCpu | Sort-Object -Descending | Select -Skip 1 | Measure-Object -Sum).Sum
'vCPU/pCPU' = "{0:P0}" -f (($vm.NumCpu | Measure-Object -Sum).Sum / ($esx.NumCpu | Measure-Object -Sum).Sum)
'vMem' = [math]::Round(($vm.MemoryGB | Measure-Object -Sum).Sum)
'pMem' = [math]::Round(($esx.MemoryTotalGB | Measure-Object -Sum).Sum)
'vMem/pMem' = "{0:P0}" -f (($vm.MemoryGB | Measure-Object -Sum).Sum / ($esx.MemoryTotalGB | Measure-Object -Sum).Sum)
}
New-Object PSObject -Property $obj
}