Subscribe

Aggregate Capacity Report (7-Mode & ONTAP)

 

The below powershell script is designed to get the aggregate capacity (Used vs Total rounded in TB) of NetApp systems regardless of the OS type. The result will be saved in an excel sheet.

 

The list of 7-modes system will be loaded from this file

$netappFile = "7netapp.txt"

The list for ONTAP system will be loaded from this file

$netappFile = "Cnetapp.txt"

In case of connectivity issue, the following message will be printed on the console

Write-Host -ForegroundColor Yellow "Failure on $netapp"
            Add-Content $outputFile "Can't connect to $netapp"

Output file name can be changed from here

$outputFile = "Aggr Capacity.xls"

 

The Powershell script

 

#Initilaize Values
$Total = 0
$TotalUsed =0
#Getting Netapp Filers List from a file called 7netapp.txt
$netappFile = "7netapp.txt"
$netappList = Get-Content $netappFile

#Create a File to save the output to
$outputFile = "Aggr Capacity.xls"
Out-File $outputFile

#Get Aggr Capacity and write to file
foreach ($netapp in $netappList){
    
    Write-Host -ForegroundColor Yellow "`nConnecting to $netapp ..."
    Add-Content $outputFile $netapp
    #Add-Content $outputFile "`n"

    try{
     
     Connect-NaController $netapp -RPC
     Add-Content $outputFile  " Aggregate Name `t Used Capacity(TB) `t Total Capacity(TB)"
     Get-NaAggr|ForEach-Object{
     #get the values per aggregate
     $x = [math]::Round($_.SizeUsed/1.09951E+12,2)
     $y = [math]::Round($_.SizeTotal/1.09951E+12,2)

     #add to the grand total
     $TotalUsed = $TotalUsed + $x
     $Total = $Total + $y

     Add-Content $outputFile  " $($_.Name) `t $x `t $y"
     #Add-Content $outputFile  "`t $($_.SizeUsed) "
      }
      

      
     }

     catch{
           
            Write-Host -ForegroundColor Yellow "Failure on $netapp"
            Add-Content $outputFile "Can't connect to $netapp"
	        write-host $_.Exception.ToString()
	        #exit 1
            }


}
################################## END OF 7-MODE PART #################################

#Getting Netapp Filers List from a file called Cnetapp.txt
$netappFile = "Cnetapp.txt"
$netappList = Get-Content $netappFile

#Get Aggr Capacity and write to file
foreach ($netapp in $netappList){
    
    Write-Host -ForegroundColor Yellow "`nConnecting to $netapp ..."
    Add-Content $outputFile $netapp
    #Add-Content $outputFile "`n"

    try{
     
     Connect-NcController $netapp
     Add-Content $outputFile  " Aggregate Name `t Used Capacity(TB) `t Total Capacity(TB)"
     Get-NcAggr|ForEach-Object{
     #get the values per aggregate
     $x = [math]::Round(($_.TotalSize/1.09951E+12)- ($_.Available/1.09951E+12),2)
     $y = [math]::Round($_.TotalSize/1.09951E+12,2)
     Add-Content $outputFile  " $($_.AggregateName) `t $x `t $y"
     
     #add to the grand total
     $TotalUsed = $TotalUsed + $x
     $Total = $Total + $y

      }
      

      
     }

     catch{
           
            Write-Host -ForegroundColor Yellow "Failure on $netapp"
            Add-Content $outputFile "Can't connect to $netapp"
	        write-host $_.Exception.ToString()
	        #exit 1
            }
   



}
    Add-Content $outputFile  "Overall Total: -"
    Add-Content $outputFile  "Used Capacity(TB) `t Total Capacity(TB)"
    Add-Content $outputFile  "$TotalUsed `t $Total"