-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClusterFailoverMemoryAware_v.01.ps1
41 lines (33 loc) · 1.33 KB
/
ClusterFailoverMemoryAware_v.01.ps1
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
29
30
31
32
33
34
35
36
37
38
39
40
41
$Env:servers
$totalmemory = "", ""
$freememory = "" , ""
$combinedmem = ""
$memfulltoint = 0
$memfreetoint = 0
$node_minus1_memory = 0
for($i = 0; $i -lt $servers.Length; $i++ ){
$totalmemory += Get-WmiObject -ComputerName $servers[$i] -Query "SELECT __Server,TotalVisibleMemorySize FROM Win32_OperatingSystem" |
Select @{l='SystemName';e={$_.__Server}},TotalVisibleMemorySize
$freememory += Get-WmiObject -ComputerName $servers[$i] -Query "SELECT __Server,FreePhysicalMemory FROM Win32_OperatingSystem" |
Select @{l='SystemName';e={$_.__Server}},FreePhysicalMemory
}
foreach($total in $totalmemory){
$memfulltoint += $total.TotalVisibleMemorySize -as [int]
$node_minus1_memory = ($total.TotalVisibleMemorySize -as [int])*($servers.Count-1)
}
foreach($free in $freememory){
$memfreetoint += $free.FreePhysicalMemory -as [int]
}
echo "Total Memory=" $memfulltoint
echo "Free Memory=" $memfreetoint
echo "ClusterMemoryInUse=" ($memfulltoint - $memfreetoint)
$warning = ($memfulltoint - $memfreetoint)
if($warning -ge $node_minus1_memory ) {
echo "<-Start Result->"
echo "ClusterMemory=Available Memory is NOT sufficient for Failover!"
echo "<-End Result->"
} else {
echo "<-Start Result->"
echo "ClusterMemory=Available Memory is sufficient for Failover!"
echo "<-End Result->"
}