Anna Khomulo - Fotolia

Get started Bring yourself up to speed with our introductory content.

How to monitor NetApp quotas for disks with PowerShell

NetApp's PowerShell module provides a fast and easy way to automate and monitor NetApp quotas for disks. Learn how with this step-by-step tutorial.

NetApp storage is thought of by many as the Cadillac of enterprise storage and for good reason. NetApp has a reputation of being resilient, and it has an auto-support system that reacts fast when failures do occur.

Like many other enterprise system manufacturers, NetApp has provided a method to manage its storage systems with the popular scripting language PowerShell. With PowerShell, IT storage administrators can use a familiar command-line interface and scripting syntax to easily automate certain storage scenarios.

One such common task that IT storage administrators look to automate is the monitoring of disk quotas, especially quotas created for end users. In this article, I will show how the NetApp PowerShell module provides a way to monitor NetApp quotas.

Viewing quota reports

The first aspect of monitoring a NetApp quota on a cluster is displaying the quotas themselves. In PowerShell, this can be done with the Get-NcQuotaReport cmdlet.

For instance, to view a NetApp quota for a specific user, in this case, "dan," I can use dan in the following target parameter.

   C:\> Get-NcQuotaReport -Target dan | Format-List

     DiskLimit     : 167772160
     DiskUsed      : 17697180
     FileLimit     : -
     FilesUsed     : 904
     NcController  : fas-1
     QuotaTarget   : dan
     QuotaType     : user
     QuotaUsers    : {dan, DOMAIN\dan}
     SoftDiskLimit : -
     SoftFileLimit : -
     Threshold     : -
     Tree          : homedir
     Volume        : testvol
     Vserver       : fas-1
     Qtree         : home

The output provides some valuable information. We see the disk limit and disk used on the quota. The disk limit is the quota limit, so the user can't save any other data in this specific qtree.

We also see the volume the qtree is on, the vserver, as well as the controller we are connected to.

In my experience, I usually organize NetApp quotas on qtrees. To view all quotas on a particular qtree, you can just specify the qtree.

Get-NcQuotaReport -Qtree testqtree

Formatting quota report output

By default, the data that Get-NcQuotaReport sends to the output isn't the most readable. The disk used and disk limit properties are shown in total bytes, making it hard for storage administrators to gauge how close they are to disk limit.

This is why I like to wrap this up with a PowerShell custom object and change these properties a bit.

Get-NcQuotaReport -Qtree testqtree | ForEach-Object { $Limit = [math]::Round($_.DiskLimit / 1MB) $Used = [math]::Round($_.DiskUsed / 1MB) $Percentage = ($Used / $Limit) if ($Percentage -gt .10 -and $_.QuotaTarget -match '^[a-z0-9]+$'){ [PSCustomObject]@{ UserName = $_.QuotaTarget Used = $Used Limit = $Limit Percentage = $Percentage.Tostring("P") } } }

In this command, I pipe the output of Get-NcQuotaReport to ForEach-Object. I then round the properties of disk limit and disk used to show in gigabytes. I calculate the percentage used in the $Percentage variable by dividing $Used and $Limit.

$Percentage = ($Used / $Limit)

Next, I use an "if" statement to show only quotas that have a user target of an alphanumeric value and that are over 10%.

         if ($Percentage -gt .10 -and $_.QuotaTarget -match '^[a-z0-9]+$'){

Finally, I wrap these up in a custom object and output. Note that I changed the value to a percentage by using the overload method of "P" in the Tostring method.

             [PSCustomObject]@{
                UserName = $_.QuotaTarget
                Used = $Used
                Limit = $Limit
                Percentage = $Percentage.Tostring("P")
               }

The result is a nicely formatted object shown in gigabytes and the percentage of disk used in each user's defined quota.

   UserName UsedinGB LimitinGB PercentageUsed
   -------- -------- --------- --------------
   Test1    173      250       69.20 %
   Test2    84       120       70.00 %
   dan      19       25        76.00 %
   Test3    798      1024      77.93 %

Call me old-fashioned, but I still prefer to receive email notifications when NetApp quotas meet a certain condition. For this task, we can use the Send-MailMessage cmdlet. Note that I use the variable $Alert to hold the output of Get-NcQuotaReport and use that in the body of my mail message.

$Alert = Get-NcQuotaReport -Qtree testqtree | ForEach-Object {
         $Limit = [math]::Round($_.DiskLimit / 1MB)
         $Used = [math]::Round($_.DiskUsed / 1MB)
         $Percentage = ($Used / $Limit)
         if ($Percentage -gt .60 -and $_.QuotaTarget -match '^[a-z0-9]+$'){
             [PSCustomObject]@{
                UserName = $_.QuotaTarget
                Used = $Used
                Limit = $Limit
                Percentage = $Percentage.Tostring("P")
               }
         }
     }

     Send-MailMessage -Body $Alert -To dan@domain.com -From mon@domain.com -SmtpServer smtp.domain.com -Subject 'Netapp Quota alert'

Quotas are just the start

I have had positive experiences with NetApp storage and NetApp quotas. Combined with its PowerShell module, managing NetApp clusters can greatly increase the automation capabilities. NetApp's cmdlets provide an easy way of looking at disk quotas and monitoring them as I have shown here. Of course, quotas are just the tip of the iceberg in terms of what can be automated with PowerShell.

Dig Deeper on Storage management tools

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

NetApp users, what has your experience been with automating and monitoring disk quotas?
Cancel

-ADS BY GOOGLE

SearchDisasterRecovery

SearchDataBackup

SearchConvergedInfrastructure

Close