Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 228891

Re: script that gives the host name with most CPU and memory resources available

$
0
0

Hello, VicMware-

 

You can get the host with the most free CPU resources, or with the most free memory, using the following:

 

## get the host with the most free CPU cycles
Get-ClustermyCluster0 | Get-VMHost | Select-Object Name,
    @{n
="CpuMhzFree"; e={$_.CpuTotalMhz -$_.CpuUsageMhz}} | Sort-Object-PropertyCpuMhzFree-Descending | Select-First1

## get the host with the most free memory
Get-ClustermyCluster0 | Get-VMHost | Select-Object Name,
    @{n
="MemGBFree"; e={$_.MemoryTotalGB -$_.MemoryUsageGB}} | Sort-Object-PropertyMemGBFree-Descending | Select-First1

 

The first would output something like:

Name          CpuMhzFree
----          ----------
myVMHost0          25384

 

And the latter would output:

Name           MemGBFree
----           ---------
myVMHost4        122.323

 

...where each of those hosts are the ones in the cluster with the most free CPU/memory, respectively.  That get the things for which you are looking?


Viewing all articles
Browse latest Browse all 228891

Trending Articles