Hello Everyone,
I'm looking for information to pull from Power cli like Hosts name, Host version ,VM Name running on the host, total VM memory assigned, VM vCPU from the Cluster ? And to export to CSV format.
Let me know if its possible to extract the above info for capacity analysis.
Power Cli version installed 11.0
Thanks
vmk2014
You mean like this?
Get-Cluster -PipelineVariable cluster |
ForEach-Object -Process {
$report = Get-VMHost -Location $cluster -PipelineVariable esx |
Get-VM |
Select @{N='Cluster';E={$cluster.Name}},
@{N='Host';E={$esx.Name}},
@{N='ESXi Version';E={$esx.Version}},
@{N='VM';E={$_.Name}},
PowerState,
@{N='VM Total MemoryGB';E={$_.MemoryGB}},
@{N='VM Total vCPU';E={$_.NumCpu}}
$report += New-Object PSObject -Property @{
Cluster = 'Total'
Host = ''
'ESXi Version' = ''
VM = ''
'VM Total MemoryGB' = $report | Measure-Object -Property 'VM Total MemoryGB' -Sum | Select -ExpandProperty Sum
'VM Total vCPU' = $report | Measure-Object -Property 'VM Total vCPU' -Sum | Select -ExpandProperty Sum
}
$report
} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
Get-VMHost | Select Name,Version,
@{N='VM';E={$script:vm = Get-VM -Location $_; $script:vm.Name -join '|'}},
@{N='VM Total MemoryGB';E={($script:vm | Measure-Object -Property MemoryGB -Sum).Sum}},
@{N='VM Total vCPU';E={($script:vm | Measure-Object -Property NumCpu -Sum).Sum}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LuCD,
Thank you for help. I did tried the script but it's generating ourput at the vcenter level not at at the Cluster level. Also, is it possible to generate out for all cluster in one shot instead of running the script multiple times ? Note :- Some host are created at Datac center level also, i mean without cluster name.
Looking forward your help on this.
Thanks
vmk2014
You mean like this?
Get-Cluster -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster | Select @{N='Cluster';E={$cluster.Name}},Name,Version,
@{N='VM';E={$script:vm = Get-VM -Location $_; $script:vm.Name -join '|'}},
@{N='VM Total MemoryGB';E={($script:vm | Measure-Object -Property MemoryGB -Sum).Sum}},
@{N='VM Total vCPU';E={($script:vm | Measure-Object -Property NumCpu -Sum).Sum}}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That is possible, but that would generate a lot of redundant information.
What about the total vCPU and memory per ESXi node?
Do I repeat that for each VM?
Perhaps it would be better if you could show me a mock up layout of the report you want.
The columns and what exactly you want in each column.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Below is the sample
Cluster Name | Host Name | VM | Powerstate | VM Total MemoryGB | VM Total vCPU |
SaltLake__Only | bba-esx1.ne.com | aptst1 | poweredOn | 36 | 18 |
01d | poweredOn | 20 | 10 | ||
ONEVIEW1 | poweredOn | 100.0039063 | 35 | ||
aent3d | poweredOn | 52.375 | 15 | ||
bv-nepager1t | poweredOn | 28 | 12 | ||
bv-mitr1t | poweredOn | 16 | 8 | ||
br1a-wmprt1t | poweredOn | 4 | 2 | ||
RHEL6.8-tmplt1 | poweredOff | 8 | 4 | ||
29 | 18 | ||||
cba-esx7.ne.com | fix01 | poweredOn | 28.5 | 15 | |
blviimsstst1 | poweredOn | 24 | 8 | ||
sstst2 | poweredOn | 30 | 18 | ||
l6tmpl01 | poweredOn | 64 | 16 |
Thanks
vmk2014
Try like this
Get-Cluster -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster -PipelineVariable esx |
Get-VM |
Select @{N='Cluster';E={$cluster.Name}},
@{N='Host';E={$esx.Name}},
@{N='ESXi Version';E={$esx.Version}},
@{N='VM';E={$_.Name}},
PowerState,
@{N='VM Total MemoryGB';E={$_.MemoryGB}},
@{N='VM Total vCPU';E={$_.NumCpu}}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LuCD. it worked Can you do one last favor ?, Can we sum up total vCPU anf Total Memory in GB at the end in report ? I mean at Cluster level
Thanks
vmk
You mean like this?
Get-Cluster -PipelineVariable cluster |
ForEach-Object -Process {
$report = Get-VMHost -Location $cluster -PipelineVariable esx |
Get-VM |
Select @{N='Cluster';E={$cluster.Name}},
@{N='Host';E={$esx.Name}},
@{N='ESXi Version';E={$esx.Version}},
@{N='VM';E={$_.Name}},
PowerState,
@{N='VM Total MemoryGB';E={$_.MemoryGB}},
@{N='VM Total vCPU';E={$_.NumCpu}}
$report += New-Object PSObject -Property @{
Cluster = 'Total'
Host = ''
'ESXi Version' = ''
VM = ''
'VM Total MemoryGB' = $report | Measure-Object -Property 'VM Total MemoryGB' -Sum | Select -ExpandProperty Sum
'VM Total vCPU' = $report | Measure-Object -Property 'VM Total vCPU' -Sum | Select -ExpandProperty Sum
}
$report
} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Exactly what i'm looking LuCD. Thank you for your help. From RV tools it took me lot of effort for 2500 VM's.
Thanks
vmk
LucD,
Sorry for opening the mail thread again. Can we collect data from power cli for host sizing on new cluster ? As from previous scripts we got all info but the below info for host sizing.
Example
CPU Data Collection
Average CPU per physical (MHz) x Average CPU Count = Average CPU per physical system
2,000MHz x 4 = 8,000MHz
Average CPU per physical system x Average peak CPU utilization (percentage) = Average peak CPU utilization (MHz)
8,000MHz x 12% = 960Mhz
Average peak CPU utilization (MHz) x Number of concurrent VM’s = Total peak CPU utilization (MHz)
960MHz x 50 = 48,000MHz
RAM Data Collection
Average RAM per physical (MB) x Average Peak RAM utilization (percentage) = Average peak RAM utilization (MB)
4,000MB x 52% = 2080MB
Average peak RAM utilization (MB) x Number of concurrent VM’s = Total peak RAM utilization (MB)
2080MB x 50 = 104,000MB
These are your target systems, remember to think about items such as server build limitations e.g. 2 Sockets with 6 Cores with Blades, DIMM slots and other factors such as license requirements or physical space which is available.
I also try and factor in maximum capacity at this point, some people like to call this head room or growth.
Host CPU Specification
CPU sockets per host x Cores per socket = Cores per host
2 x 6 =12
Cores per host x MHz per core = MHz per host
12 x 2,000MHz = 24,000MHz
MHz per host x Maximum CPU utilization per host (percentage) = CPU available per host
24,000MHz x 80% = 19,200MHz
RAM per host x Maximum RAM utilization per host (percentage) = RAM available per host
80,000MB x 70% = 56,000MB
Thanks
vmk
Those "Peak utilisation" percentages, do you have any idea over which period they shall be taken?
PS: perhaps it would be better to create a new thread for this?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Sorry, i didnt put the question in right way. Actually through this out, i am trying to calculate the no of host required in new cluster. i.e. Host forecast.
Refer to below link
https://vmfocus.com/2013/09/01/vsphere-sizing-formula-cpu-ram/
I want to first 2 steps through power cli or if its possible to calculate the steps# i.e. No fo host required then it would be great.
Thanks
vmk
No, I think your question is clear.
But the "Average Peak ... utilization" assumes that one looks at the max values over a certain period of time.
It's that period of time that I asked about.
If that period of time is longer, your average peak values will normally be flattened out.
If that period of time is rather short, you might hit a busy period, and then that average peak could be much higher.
In fact I don't really agree with those formulas as-is for scaling.
Unless your datacenter is constantly under the same load, it would be best, imho, to first determine the activity periods in your environment.
An example:
Imho, you would first need to discover those 3 periods with different workloads.
Then you would need to define which workload needs unconditional resources, meaning none or a very low Ready percentage.
Suppose the night interval can tolerate an increase of the Ready percentage, then you would perhaps better scale your environment on the day interval.
On the other hand if you determine your scaling on the average peak during the day (over all 3 periods we discovered earlier), you would be using a skewed value to scale the environment.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference