Hi,
Need help how we can automate if my Cluster Host and Memory Utilization reaches certain threshold to notify user with dashboard report. Need to add host capacity in Cluster
What do you already have?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Currently , we are not using any tool. Looking for help to build script . Please help us . How we can automate...
That is a very vague request for a script.
Do you have any concrete requirements for the script?
What specific help do you seek?
Have you any experience with PowerCLI?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, Have experience in using Powercli. Can you help us to get dashborad report . If not possible for anomaly detection.
Looking Powercli script like this
ClusterName =
Total Hosts =
Total VMs =
CPU (Available) = No of Phyical core per socket
Memory (Available) (GB) =
vCPU (Allocated) =
vCPU Allocation Ratio (%) = vCPU (Allocated) / CPU (Available)
vRAM Allocated (GB) =
vRAM Allocation Ratio (%) = vRAM Allocated (GB) / Memory (Available) (GB)
vCPU Utilization Max(%) =
vCPU Utilization Min(%) =
vCPU Utilization Avg(%) =
vRAM Utilization Max(%) =
vRAM Utilization Min(%) =
vRAM Utilization Avg(%) =
Did you do a search in this community?
That kind of report is asked for quite regularly.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I tried but not getting relevant report. Would request you to share the discussion article or help me to get script.
Thanks , I found same script in your earlier post.
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 @SStat
$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
}
There are similar questions in this community, see for example Solved: Re: Generate HTML Report with cell colors - VMware Technology Network VMTN
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference