Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from vmware/master
Pull recent changes
- Loading branch information
Showing
11 changed files
with
5,406 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
function Get-VMmaxIOPS { | ||
<# | ||
.SYNOPSIS | ||
Report VM Disk IOPS of VMs | ||
.DESCRIPTION | ||
This Function will Create a VM Disk IOPS Report | ||
.Example | ||
Get-VM TST* | Get-VMmaxIOPS -Minutes 60 | FT -Autosize | ||
.Example | ||
$SampleVMs = Get-VM "TST*" | ||
Get-VMmaxIOPS -VMs $SampleVMs -Minutes 60 | ||
.PARAMETER VMs | ||
Specify the VMs | ||
.PARAMETER Minutes | ||
Specify the Minutes to report (10080 is one Week) | ||
.Notes | ||
NAME: Get-VMmaxIOPS.ps1 | ||
LASTEDIT: 08/23/2016 | ||
VERSION: 1.1 | ||
KEYWORDS: VMware, vSphere, ESXi, IOPS | ||
.Link | ||
http://mycloudrevolution.com/ | ||
#Requires PS -Version 4.0 | ||
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} | ||
#> | ||
|
||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$true, ValueFromPipeline=$True, Position=0)] | ||
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] | ||
$VMs, | ||
[Parameter(Mandatory=$false, Position=1)] | ||
[int] $Minutes = 30 | ||
) | ||
|
||
Process { | ||
|
||
#region: Global Definitions | ||
[int]$TimeRange = "-" + $Minutes | ||
#endregion | ||
|
||
#region: Creating Metrics | ||
Write-Debug "Starting to Create Metrics..." | ||
$metrics = "virtualDisk.numberReadAveraged.average","virtualDisk.numberWriteAveraged.average" | ||
$start = (Get-Date).AddMinutes($TimeRange) | ||
$stats = Get-Stat -Stat $metrics -Entity $VMs -Start $start | ||
#endregion | ||
|
||
#region: Creating HD-Tab | ||
Write-Debug "Starting to Create HD-Tab..." | ||
$hdTab = @{} | ||
foreach($hd in (Get-Harddisk -VM $VMs)){ | ||
$controllerKey = $hd.Extensiondata.ControllerKey | ||
$controller = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $controllerKey} | ||
$hdTab[$hd.Parent.Name + "/scsi" + $controller.BusNumber + ":" + $hd.Extensiondata.UnitNumber] = $hd.FileName.Split(']')[0].TrimStart('[') | ||
} | ||
#endregion | ||
|
||
#region: Creating Reports | ||
Write-Debug "Starting to Process IOPS Report..." | ||
$reportPerf = @() | ||
$reportPerf = $stats | Group-Object -Property {$_.Entity.Name},Instance | %{ | ||
New-Object PSObject -Property @{ | ||
VM = $_.Values[0] | ||
Disk = $_.Values[1] | ||
IOPSMax = ($_.Group | ` | ||
Group-Object -Property Timestamp | ` | ||
%{$_.Group[0].Value + $_.Group[1].Value} | ` | ||
Measure-Object -Maximum).Maximum | ||
Datastore = $hdTab[$_.Values[0] + "/"+ $_.Values[1]] | ||
} | ||
} | ||
$reportPerf | Select-Object VM, Disk, Datastore, IOPSMax | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
function Set-CBT { | ||
<# | ||
.NOTES | ||
=========================================================================== | ||
Created by: Markus Kraus | ||
Twitter: @VMarkus_K | ||
Private Blog: mycloudrevolution.com | ||
=========================================================================== | ||
Changelog: | ||
2016.11 ver 1.0 Base Release | ||
=========================================================================== | ||
External Code Sources: | ||
http://wahlnetwork.com/2015/12/01/change-block-tracking-cbt-powercli/ | ||
=========================================================================== | ||
Tested Against Environment: | ||
vSphere Version: 5.5 U2 | ||
PowerCLI Version: PowerCLI 6.3 R1 | ||
PowerShell Version: 4.0 | ||
OS Version: Windows Server 2012 R2 | ||
=========================================================================== | ||
Keywords vSphere, ESXi, VM, Storage, CBT, Backup | ||
=========================================================================== | ||
.DESCRIPTION | ||
This Function enables or disables CBT. | ||
.Example | ||
Get-VN TST* | Set-CBT -DisableCBT | ||
.Example | ||
Get-VN TST* | Set-CBT -EnableCBT | ||
.PARAMETER DisableCBT | ||
Disables CBT for any VMs found with it enabled | ||
.PARAMETER EnableCBT | ||
Enables CBT for any VMs found with it disabled | ||
#Requires PS -Version 4.0 | ||
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} | ||
#> | ||
|
||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "VMs to process")] | ||
[ValidateNotNullorEmpty()] | ||
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $myVMs, | ||
[Parameter(Mandatory = $False,ValueFromPipeline=$False, Position = 1, HelpMessage = "Enables CBT for any VMs found with it disabled", ParameterSetName = "EnableCBT")] | ||
[ValidateNotNullorEmpty()] | ||
[Switch]$EnableCBT, | ||
[Parameter(Mandatory = $False,ValueFromPipeline=$False, Position = 1, HelpMessage = "Disables CBT for any VMs found with it enabled", ParameterSetName = "DisableCBT")] | ||
[ValidateNotNullorEmpty()] | ||
[Switch]$DisableCBT | ||
) | ||
Process { | ||
|
||
$vmconfigspec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec | ||
Write-Verbose -Message "Walking through given VMs" | ||
foreach($myVM in $myVMs) | ||
{ | ||
if ($DisableCBT -and $myVM.ExtensionData.Config.ChangeTrackingEnabled -eq $true -and $myVM.ExtensionData.Snapshot -eq $null) | ||
{ | ||
try | ||
{ | ||
Write-Verbose -Message "Reconfiguring $($myVM.name) to disable CBT" -Verbose | ||
$vmconfigspec.ChangeTrackingEnabled = $false | ||
$myVM.ExtensionData.ReconfigVM($vmconfigspec) | ||
|
||
if ($myVM.PowerState -eq "PoweredOn" ) { | ||
Write-Verbose -Message "Creating a snapshot on $($myVM.name) to clear CBT file" -Verbose | ||
$SnapShot = New-Snapshot -VM $myVM -Name "CBT Cleanup" | ||
|
||
Write-Verbose -Message "Removing snapshot on $($myVM.name)" -Verbose | ||
$SnapShot| Remove-Snapshot -Confirm:$false | ||
} | ||
|
||
} | ||
catch | ||
{ | ||
throw $myVM | ||
} | ||
} | ||
elseif ($EnableCBT -and $myVM.ExtensionData.Config.ChangeTrackingEnabled -eq $false -and $myVM.ExtensionData.Snapshot -eq $null) | ||
{ | ||
Write-Verbose -Message "Reconfiguring $($myVM.name) to enable CBT" -Verbose | ||
$vmconfigspec.ChangeTrackingEnabled = $true | ||
$myVM.ExtensionData.ReconfigVM($vmconfigspec) | ||
|
||
if ($myVM.PowerState -eq "PoweredOn" ) { | ||
Write-Verbose -Message "Creating a snapshot on $($myVM.name) to Create CBT file" -Verbose | ||
$SnapShot = New-Snapshot -VM $myVM -Name "CBT Cleanup" | ||
|
||
Write-Verbose -Message "Removing snapshot on $($myVM.name)" -Verbose | ||
$SnapShot | Remove-Snapshot -Confirm:$false | ||
} | ||
} | ||
else | ||
{ | ||
if ($myVM.ExtensionData.Snapshot -ne $null -and $EnableCBT) | ||
{ | ||
Write-Warning -Message "Skipping $($myVM.name) - Snapshots found" | ||
} | ||
elseif ($myVM.ExtensionData.Snapshot -ne $null -and $DisableCBT) | ||
{ | ||
Write-Warning -Message "Skipping $($myVM.name) - Snapshots found" | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.