I finally got an opportunity to mess around with the PowerShell cmdlets for NetApp. Overall, I think that a storage vendor’s adoption of something like PowerShell is always a Good Thing. (From what I understand, EMC has PowerShell cmdlets out now, as well — but I digress.)
There were a couple of things that I wanted to use PowerShell for — basically, “quicklook” kind of information. Sure, I could use NetApp’s System Manager, or FilerView, or DataFabric Manager, etc – but all of those require time to load and sort through, etc. The cmdlets, when structured properly, can aggregate a great deal of information into a short & actionable list.
I’ve written two examples that demonstrate what I’m talking about. The first one will show all volumes that are over 90% utilized on a NetApp cluster (both heads). The second one will show a top 10 list of volumes with the most number of snapshots and the percentage used space.
[powershell]
Import-Module DataONTAP
$cred = Get-Credential "root"
$controllers = @("filer01a","filer01b")
foreach ($controller in $controllers) {
$nacontroller = Connect-NaController $controller -Credential $cred -Transient:$true
Get-NaVol -Controller $nacontroller | where { ($_.PercentageUsed -gt "90") -and ($_.Name -inotlike "*backup*") } | select Name,PercentageUsed,ContainingAggregate | ft -AutoSize
}
[/powershell]
As you can see, I’ve started by loading the DataONTAP modules into the PowerShell environment. You can choose to do this at the top of every script, or just toss it into your profile. Next, I’ve created an array that consists of the 2 heads that form an OnTAP cluster. The Get-NaVol line will get every volume that is more than 90% used, as long as the name doesn’t include the word “backup” (that’s part of our snap volume naming conventions). The output is produces looks like so:
[code]
Name PercentageUsed ContainingAggregate
—- ————– ——————-
FILER01A_AGGR1_VMFS1 92 FILER01A_AGGR1
FILER01A_AGGR2_SQL2 91 FILER01A_AGGR2
Name PercentageUsed ContainingAggregate
—- ————– ——————-
FILER01B_AGGR3_CIFS 92 FILER01B_AGGR3
FILER01B_AGGR4_SQL1 92 FILER01B_AGGR4
[/code]
Here’s the second snippet.
[powershell]
$volumes = Get-NaVol
$details = @()
foreach ($volume in $volumes) {
$detail = "" | select Name,SnapshotCount,PercentageUsed
$detail.Name = $volume.Name
$detail.SnapshotCount = (Get-NaSnapshot $volume.Name).Count
$detail.PercentageUsed = $volume.PercentageUsed
$details += $detail
}
$details | Sort-Object -Property SnapshotCount -Descending | Select-Object -First 10 | Format-Table -AutoSize
[/powershell]
Output looks like this:
[code]
Name SnapshotCount PercentageUsed
—- ————- ————–
FILER01A_AGGR2_SQL_PROD 25 87
FILER01A_AGGR1_DFS_TEST 21 51
FILER01A_AGGR3_EXCHANGE02 17 67
FILER01A_AGGR4_VMFS1 17 63
FILER01A_AGGR3_EXCHANGE03 17 66
FILER01A_AGGR1_VMFS2 17 65
FILER01A_AGGR1_SQL_DEV 13 86
FILER01A_AGGR2_SQL_TEST 12 63
FILER01A_AGGR2_APPS_DEV 11 8
FILER01A_AGGR4_VMFS5 11 64
[/code]
As you can see, the last snippet is especially handy. I now know that I should look at deleting some snapshots on that top volume.
I hope this helps, and I encourage you to take a look at the PowerShell cmdlets for NetApp, or for any other storage you manage.
cris says
Is there a way to exclude offline volumes from being inventoried for snapshot?