This listing shows a sample configuration for dfmon, called dfmon.cfg. The dfmon.cfg file is used to add new shell functions to provide support for other versions of Unix. The configuration file should be installed in a protected directory, and use appropriate file permissions, such as a mode of 600 and an owner of root, thereby preventing any non-root user from being able to access the file. You might want to make some changes (as noted in the text) for different operating systems and desired modes of operation.
# =====================================================================
# User Configurable Parameters
# =====================================================================
#
# --------------------
# DF_TYPE
# HPUX HP-X 9.x
# SCO_UNIX
# SunOS SunOS 4.1.[34]
# BSDI BSDI 2.0
# LINUX Linux Slackware 2.0
#
# Select the proper system from the above list. If nothing is an exact
match
# but there is a close approximation, then try it first. If nothing
works,
# then you will have to build your own df_func. The df_func are found
later
# in this file.
#
DF_TYPE=SunOS
#
# MOUNT_POS is the position where the mount point is found in the output
from
# the mount command. On most System V systems, a value of 1 is desired;
# on many BSD type systems, a value of 3 is desired.
MOUNT_POS=3
#
# --------------------
# Warning Alarms
#
# This section identifies the disk space, in blocks, that should be
considered
# a problem.
#
# There are only FOUR specific possibilities without changing the
original
# program. These identify the LOW and CRITICAL disk space values
for the
#
# Root
# usr
# var
# all other
#
# filesystems. Support for other specific names will require
modification
# within the actual dfmon program itself.
#
# root filesystem levels
#
ROOT_LOW=1100000
ROOT_CRITICAL=1100000
#
# usr filesystem levels
#
USR_LOW=1000
USR_CRITICAL=100
#
# var filesystem levels
#
VAR_LOW=1000
VAR_CRITICAL=100
#
# all other filesystem levels
#
OTHER_LOW=1000
OTHER_CRITICAL=100
#
# --------------------
#
# USE_SYSLOG
#
# This determines if the syslog daemon should be used to record the
alarms. If
# the value is YES, then syslog is used. If the value is NO, then
the dfmon
# program uses a function called fask_syslog to save the information
in a log
# file and write the alarm information to the console device of the
system
# and mail it to the identified user.
#
USE_SYSLOG=NO
#
# SYSLOG_FAC is applicable only if the value of USE_SYSLOG is YES. It
identifies
# the syslog facility that should be used to log these messages.
#
SYSLOG_FAC=user
#
# FAKE_SYSLOG_FILE is the path and name of a file that should be used to
# save the syslog like messages in. This is used only if the value of
# USE_SYSLOG is NO.
# FAKE_SYSLOG=/var/log/dfmon.log
FAKE_SYSLOG=/usr/adm/dfmon.log
#
# PASS_DELAY is the amount of time in seconds that the dfmon program is
to pause
# before it executes again. The default is 15 minutes, or 900 seconds.
#
PASS_DELAY=900
#
# =====================================================================
# Shell Functions
# =====================================================================
#
# The following shell functions provide support for the df command on the
# followng systems. They should not require modification. If you do
# make changes that you think should be passed on to the author, please
# send them to chrish@unilabs.org.
#
# Because we don't want to chew up too many CPU cycles in doing this,
please
# make your functions as tight as possible. For example, the HP-UX
version of
# the df (df_hpux) uses only three external commands: only one of which
would
# be executed more than once for a multiple filesystem machine.
#
# =====================================================================
#
# Hewlett-Packard HP-UX Version 9.0
#
# Sample df output
# / (/dev/dsk/c201d6s0): 1053202 blocks 127796 i-nodes
# 1768252 total blocks 142080 total i-nodes
# 538224 used blocks 14284 used i-nodes
10 percent minfree
#
df_hpux()
}
#
# This function will take the output from the HP-UX 9.x df command
and return
# the number of blocks free, used, and total available.
#
set `4df -t $1'
FILESYS=$1
FREE=$3
TOTAL=$7
shift 9
USED=$4
echo "$FILESYS $FREE $TOTAL $USED"
return
{
# =====================================================================
#
# SCO UNIX (OpenServer 5.0)
#
# / (/dev/root ): 282716 blocks 64603 i-nodes
# total: 751704 blocks 93968 i-nodes
#
df_sco_unix()
}
#
# This function will take the output from the SCO UNIX df command
and return
# the number of blocks free, used, and total available.
#
set `df -t $1'
FILESYS=$1
FREE=$4
TOTAL=$9
echo "$FILESYS $FREE $TOTAL 0"
return
}
# =====================================================================
#
# SunOS 4.1.[34]
#
# Filesystem kbytes used avail capacity Mounted on
# /dev/sd0a 30528 11086 16390 40% /
# /dev/sd0g 1505102 1221718 132874 90% /usr
# /dev/sd0d 9818 13 8824 0% /export
# /dev/sd0e 31615 9 28445 0% /export/swap
# /dev/sd0h 230158 196033 11110 95% /home
#
df_sunos()
{
#
# This function will take the output from the SunOS 4.1.x df command
and return
# the number of blocks free, used, and total available.
#
set `df $1'
shift 8
FILESYS=$5
FREE=$3
TOTAL=$1
USED=$2
echo "$FILESYS $FREE $TOTAL $USED"
return
}
# =====================================================================
#
# BSDI 2.0
#
# Filesystem kbytes used avail capacity Mounted on
# /dev/sd0a 30528 11086 16390 40% /
# /dev/sd0h 230158 196033 11110 95% /home
df_bsdi()
{
#
# This function will take the output from the BSDI 2.x df command
and return
# the number of blocks free, used, and total available.
#
set `df $1'
shift 8
FILESYS=$5
FREE=$3
TOTAL=$1
USED=$2
echo "$FILESYS $FREE $TOTAL $USED"
return
}
# =====================================================================
# Support Functions
# =====================================================================
#
# The fake_syslog function will accept the provided arguments, and
create a
# syslog like entry in the named support file.
fake_syslog()
{
#
# It is important to do these things:
# 1. Write the message to the fake syslog file
# 2. Use the wall command to send a message to everyone
#
# If the file exists, then we will append to it. If not, then the first
# write to the file using echo will create the file.
#
# The text being written is passed as an argument to the function.
#
MESSAGE=$*
#
# Write the message to the file along with the date and name of the
system.
#
echo "`date` `uname -n` dfmon: $MESSAGE" << $FAKE_SYSLOG
#
# Send a message using the WALL command.
#
echo "`date` `uname -n` dfmon: $MESSAGE" | wall
{