BigAdmin System Administration Portal
Community-Submitted Tech Tips
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

Script for Checking Used Space in File Systems in the Solaris OS

Victor Feng, February 2008

As system administrators, one of our jobs is to keep an eye on the available space of systems. This article provides a script, checkfsspace, which checks whether the used space for both UFS and ZFS file systems exceeds a warning threshold. If the used space exceeds the threshold, the script sends a warning message to a specified email address. If you don't have ZFS (for example, on a system that runs the Solaris 9 OS), the script will skip checking ZFS.

Note: The checkfsspace script was tested on the Solaris 9 09/04 OS and the Solaris 10 11/06 OS.

Here's the script source code. Please save the script without the .txt suffix.

Then specify the values of the following variables in the checkfsspace script, and run the script at a time when your system is not busy.

  • LOG, which specifies where to log warning messages (<dir_of_checkfsspace>/fsspace_msg)
  • RECEIVER, which specifies the email address where warning messages will be sent
  • USED_SPACE_PERCENT_WARN, which specifies the used-space warning threshold; the default is 80 percent

The following demonstrates how checkfsspace reacts when the used space of some file systems exceeds the warning threshold of 80 percent:

For this demonstration, here's information about the UFS file system:

# df -h -F ufs
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c0t0d0s0       15G    12G   2.6G    83%    /
/dev/dsk/c0t0d0s4       15G    15M    15G     1%    /u01

For ZFS, we'll consider only the pools, because important applications such as enterprise applications should not be given a quota:

# zpool list
NAME        SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
tank       14.9G   1.63G   13.2G    10%  ONLINE     -
train      17.9G   16.3G   1.54G    91%  ONLINE     -

First, we'll run the script:

# ./checkfsspace

Then we'll check the generated warning messages:

# cat fsspace_msg


UFS /dev/dsk/c0t0d0s0 has used 83% of its space.
ZFS pool train has used 91% of its space.

The generated messages indicate what we expected.

Discuss and comment on this resource in the BigAdmin Wiki


Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin
  
 
 
 
 
Would you recommend this Sun site to a friend or colleague?
Contact About Sun News & Events Employment Site Map Privacy Terms of Use Trademarks Copyright Sun Microsystems, Inc.