Re-sizing Volume Snapshot Reserve Calculator

Just a mathematical tool to help me resize the volume snapshot reserve on some volumes that are warning - via OCUM - that their volume snapshot reserve is over 100% used.

A - real world - example:

- I have a volume that is 7.49 TB in size
- The volume is 57 percent full
- The current snapshot reserve is 5 percent
- The current snapshot reserve space used is 534 percent

- I want the NEW snapshot reserve space used to be 75 percent
- I want the NEW volume size to leave it 65 percent full

New Volume Size = 7.59 TB
New Percent Snapshot Reserve = 35%

Image: Snap Reserve Calculator in action
The Script

## Re-sizing Volume Snapshot Reserve Calculator ##

Function TrapOut{ "Not a valid value!"; EXIT }
Trap {TrapOut}

<# To get the first 4 items using Clustershell:
::> vol show -volume VOLNAME -fields size,percent-used,percent-snapshot-space,snapshot-space-used #>

[Double]$VolumeSize      = Read-Host "Volume size"
[Double]$PercVolSizeUsed = Read-Host "Percent volume full"
[Double]$PercSnapRes     = Read-Host "Percent snapshot reserve"
[Double]$PercSnapResUsed = Read-Host "Percent snapshot reserve used"

[Double]$NewSnapResPerc  = Read-Host "NEW percent snapshot reserve used"
[Double]$NewVolPercFull  = Read-Host "NEW percent volume full"

[Double]$SizeUsedBySnapshots = ($VolumeSize * $PercSnapRes * $PercSnapResUsed) / (100 * 100)
If($PercSnapResUsed -le 100){ [Double]$SnapshotSpill = 0 }
else{ [Double]$SnapshotSpill = $SizeUsedBySnapshots - (($VolumeSize * $PercSnapRes) / 100) }
[Double]$SizeUsedByUserData = (($VolumeSize * $PercVolSizeUsed) / 100) - (($VolumeSize * $PercSnapRes) / 100) - $SnapshotSpill

[Double]$NewSnapshotReserveSize = ($SizeUsedBySnapshots / $NewSnapResPerc) * 100
[Double]$NewVolumeSize = (($SizeUsedByUserData + $NewSnapshotReserveSize) / $NewVolPercFull) * 100
[Double]$NewPercSnapRes = ($NewSnapshotReserveSize / $NewVolumeSize) * 100

("New Volume Size = " + [String]($NewVolumeSize))
("New Percent Snapshot Reserve = " + [String]($NewPercSnapRes))


Comments