Articles January 7, 2005 at 5:37 pm

An Introduction to diskspacemonitor on OS X Server

Running out of space on OS X is bad, like real bad.

Read on to find out more about the built-in facilities that will prevent you from running out of space.

The following information is based off of OS X Server 10.3.5

Introduction:

OS X Server comes with a utility called diskspacemonitor. This is a configurable, cron-activated commandline tool that resides in /usr/sbin/diskspacemonitor. It is designed to periodically monitor the amount of free space on disks and execute pre-configured actions when thresholds are reached.

This tutorial provides a brief introduction to this utility.

diskspacemonitor Files:

There are several configuration files used by diskspacemonitor. If you check the /etc/diskspacemonitor/ directory you’ll find the default files installed with OS X Server. Do not edit the .default files. Copies will be made for the appropriate configuration file when the diskspacemonitor utility is activated.


[X:/etc/diskspacemonitor/] username$ ls -1F

action/
alert.conf.default
daily.server.conf
daily.server.conf.default
diskspacemonitor.conf
diskspacemonitor.conf.default
monthly.server.conf.default
recover.conf.default
weekly.server.conf.default

<code>&lt;em&gt;action/&lt;/em&gt;&lt;br&gt;&lt;br&gt;
By default, the action directory contains two scripts: &lt;em&gt;alert&lt;/em&gt; and &lt;em&gt;recover&lt;/em&gt;.  Both of these shell scripts can be configured using the respective file: &lt;em&gt;alert.conf&lt;/em&gt; and &lt;em&gt;recover.conf&lt;/em&gt;.



&lt;em&gt;alert.conf.default&lt;/em&gt;&lt;br&gt;&lt;br&gt;
This is the default configuration file used for the alert script found at /etc/diskspacemonitor/action/alert.  The three configurable variables are: subject, to, and body.  These correspond with the email that is sent out by the alert script when the warning threshold is reached. 
</code>


# Config for alert
#

<code># Arguments passed to alert (and alert.local, if &lt;br&gt;
# it exists): &lt;br&gt;
# - Volume name &lt;br&gt;
# - Threshold &lt;br&gt;
# - Percentage full &lt;br&gt;
# - Log file &lt;br&gt;
# &lt;br&gt;
subject="DiskSpaceMonitor: Disk &amp;#36;1 has exceeded &amp;#36;2% threshold, is &amp;#36;3% full." &lt;br&gt;
to=admin &lt;br&gt;
body=`df -k -l -t ufs; df -k -l -t hfs` &lt;br&gt;
</code>

<code>Notice that the &lt;em&gt;body&lt;/em&gt; variable contains the output of the &lt;em&gt;df&lt;/em&gt; command.  &lt;b&gt;WARNING:&lt;/b&gt; When tested on OS X Server 10.3.5 the &lt;em&gt;df&lt;/em&gt; command above will fail with the following error: &lt;em&gt;df: -l and -t are mutually exclusive&lt;/em&gt;. After enabling diskspacemonitor, edit the alert.conf file by deleting the "-l".  For more information on &lt;em&gt;df&lt;/em&gt; see the man page.



&lt;em&gt;diskspacemonitor.conf&lt;/em&gt;&lt;br&gt;&lt;br&gt;
This is the main configuration file used by &lt;em&gt;diskspacemonitor&lt;/em&gt;. The four configurable variables are: monitor_interval, alert_threshold, recovery_threshold, and log_file. See the output for descriptions of these variables.
</code>


# Config for diskspacemonitor
#

monitor_interval=10 # Check disks at this interval, in minutes

alert_threshold=75 # When a disk is this percentage full, execute
# the alert scripts in
# /etc/diskspacemonitor/action/

recovery_threshold=85 # When a disk is this percentage full, execute
# the recovery scripts in
# /etc/diskspacemonitor/action/

log_file=/var/log/diskspacemonitor.log

<code>&lt;em&gt;daily.server.conf&lt;/em&gt;&lt;br&gt;&lt;br&gt;
This is the configuration file used by &lt;em&gt;/etc/periodic/600.daily.server&lt;/em&gt;, which is a log-rolling script installed by default with OS X Server.  I do not recommend editing this config file unless you know what you're doing.



&lt;em&gt;recover.conf.default&lt;/em&gt;&lt;br&gt;&lt;br&gt;
This is the configuration file for the &lt;em&gt;recover script&lt;/em&gt; located in /etc/diskspacemonitor/action/.  It defines what log files to roll or compress. Do not edit this file unless you know what you're doing.



&lt;em&gt;Unused files&lt;/em&gt;&lt;br&gt;&lt;br&gt;
As of OS X Server 10.3.5 the following files don't do anything:
&lt;ul&gt;
    &lt;li&gt; monthly.server.conf.default
    &lt;li&gt; weekly.server.conf.default
&lt;/ul&gt;
</code>

Leave a reply

You must be logged in to post a comment.