search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Hyper-V Cluster Memory Reports v2
Posted in Windows Powershell, Windows Server | 2 Comments | 2,172 views | 13/02/2014 10:51

You can get memory usage of Hyper-V clusters with following script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$Clusters = Get-Content Clusters.txt
foreach ($Cluster in $Clusters)
{
	[int]$TotalFreeMemory = 0;
	[int]$TotalMemory = 0;
	[int]$NodeCount = 0;
	$ClusterNodes = Get-Cluster $Cluster | Get-ClusterNode
	foreach ($ClusterNode in $ClusterNodes)
	{
		[int]$FreeMemory = [math]::round(((Get-WmiObject -ComputerName $ClusterNode -Class Win32_OperatingSystem).FreePhysicalMemory / 1MB), 0)
		[int]$TotalFreeMemory = [int]$TotalFreeMemory + [int]$FreeMemory
		[int]$NodeMemory = [math]::round(((Get-WmiObject -ComputerName $ClusterNode -Class Win32_OperatingSystem).TotalVisibleMemorySize / 1MB), 0)
		[int]$TotalMemory = [int]$TotalMemory + [int]$NodeMemory
		[int]$NodeCount = [int]$NodeCount + 1
	}
	[int]$TotalAvailableMemory = [int]$TotalFreeMemory - [int]$NodeMemory
 
	Write-Host "Cluster: $Cluster"
	Write-Host "Total Memory: $TotalMemory"
	Write-Host "Total Free Memory: $TotalFreeMemory"
	Write-Host "Total Available Memory: $TotalAvailableMemory"
	Write-Host "Node Count: $NodeCount"
 
	Write-Host " "
 
	$Value = $Cluster + ";" + $TotalMemory + ";" + $TotalFreeMemory + ";" + $TotalAvailableMemory + ";" + $NodeCount + ";" + $NodeMemory
	Add-Content -Value $Value -Path Memory.txt
}

You will see detailed memory usage information of your Hyper-V clusters.


Comments (2)

Barend

February 13th, 2014
14:10:34

Thankyou for the useful script. But how does it calculate the total available memory? Why is my available memory +/- 50% of my total free memory?

Kind regards,
Barend


admin

February 13th, 2014
17:05:50

Hi Barend,

Available Memory = Free Memory – Node Memory

So if you lose one of cluster nodes, you will be able to use that available memory. Of course that’s for n-1 combination :)

Yusuf.



Leave a Reply