Friday, 31 July 2015

Powershell - NetApp Volumes, Snapshots and Dedup

Some basic scripts that helped we get some sizing information.

First of all you'll need Powershell (who knew?!) and then the NetApp Powershell Toolkit - I found this link useful for this:

First script get the volume information with a loop due to having a number of Filers to get information on:

Import-Module DataOnTap

$filers = (Get-Content C:\Script_Output\Filers.txt)

Foreach ($filer in $filers){

Connect-NAController $filer -Credential <account-name>

Get-NaVol | Select @{Name="HostName";Expression={$filer}}`
,@{Name="VolumeName";Expression={$_.name}}`
,@{Name="TotalSize(GB)";Expression={[math]::Round([decimal]$_.SizeTotal/1gb,2)}}`
,@{Name="AvailableSize(GB)";Expression={[math]::Round([decimal]$_.SizeAvailable/1gb,2)}}`
,@{Name="UsedSize(GB)";Expression={[math]::Round([decimal]$_.SizeUsed/1gb,2)}}`
,PercentageUsed | Export-CSV C:\Script_Output\filers-vol-size.csv -Append -NoTypeInformation
}


Second script lists the snapshots per volume on each Filer:

Import-Module DataOnTap

$filers = (Get-Content C:\Script_Output\Filers.txt)

Foreach ($filer in $filers){
Connect-NAController $filer -Credential <account-name>
get-navol | get-nasnapshot | Select @{Name="HostName";Expression={$filer}}`
,@{Name="VolumeName";Expression={$_.TargetName}}`
,@{Name="SnapshotName";Expression={$_.Name}}`
,@{Name="CumlativeTotal(GB)";Expression={[math]::Round([decimal]$_.CumulativeTotal/1gb,2)}}`
,@{Name="Total(GB)";Expression={[math]::Round([decimal]$_.Total/1gb,2)}}`
,Created | Export-CSV C:\Script_Output\ifilers-snapshot-size.csv -Append -NoTypeInformation
}


Third script is for the Data Dedup information on each Filer (this script needs more work on it as I had to run it against each Filer instead of having a text file list of Filers

Import-Module DataOnTap

$controller = "isg-filer06"

Connect-NAController $controller -Credential <account-name>

Get-NaVol | foreach {
$volname = $_.name
Get-NaVolSis $_ | Select-Object @{n="HostName";e={$controller}}`
,@{n="VolumeName";e={$volname}}`
,@{Name="TotalSaved(GB)";Expression={[math]::Round([decimal]$_.TotalSaved/1gb,2)}}`
,State,PercentageSaved | Export-CSV C:\Script_Output\filers-dedup1.csv -Append -NoTypeInformation
}


Again, thanks to a number of bloggers out there where I managed to re-hash a few scripts to get what I wanted. I will credit them when I find their pages again!