VMware Cloud Community
vmk2014
Expert
Expert
Jump to solution

Getting information like Hosts name ,VM Name running on Host, total VM memory, VM vCPU from the Cluster ?

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

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

13 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$clusterName = 'MyCluster'

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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

Below is the sample

      

Cluster NameHost NameVMPowerstateVM Total MemoryGBVM Total vCPU
SaltLake__Onlybba-esx1.ne.comaptst1poweredOn3618
01dpoweredOn2010
ONEVIEW1poweredOn100.003906335
aent3dpoweredOn52.37515
bv-nepager1tpoweredOn2812
bv-mitr1tpoweredOn168
br1a-wmprt1tpoweredOn42
RHEL6.8-tmplt1poweredOff84
2918
cba-esx7.ne.comfix01poweredOn28.515
blviimsstst1poweredOn248
sstst2poweredOn3018
l6tmpl01poweredOn6416

Thanks

vmk2014

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

vmk2014
Expert
Expert
Jump to solution

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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

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

Step 2 – Target Host Specification

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

Host RAM Specification

RAM per host x Maximum RAM utilization per host (percentage) = RAM available per host

80,000MB x 70% = 56,000MB

Thanks

vmk

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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:

  • at night, there is a period of 2-4 hours with some heave load
  • during the office hours, there is load from users accessing apps on VMs
  • there remaining time there is moderate load

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