Linux Training

Linux training for private, public & voluntary sector.

0800 024 8425

City LinUX sample scripts - chkdf

NAME

chkdf - uses df on a remote host to check that the local file system percentage usage is within specified limits.

SYNOPSIS

chkdf [-c <config file> [-d] [-e <e-mail_address> ] [-u <login name> ] [-l] [-m <max_usage> ] [-v] <hostname>

AVAILABILITY

chkdf is a Bourne shell script which should work equally well on all versions of UNIX and Linux.

DESCRIPTION

The script chkdf, invokes a ssh session to the remote host specified on the command line and runs the df command. The output which is piped back to the the administration host is used by awk to extract the percentage usage of the filesystems and compares this to the maximum usage value set in the configuration file.

In the event of no host name being set on the command line the target host is set to "localhost".

If the threshold is exceeded email is dispatched to the mail address specified on the command line (see -m option below).

If the configuration file exists but the host is not found a default value of 60% is used as the threshold for all file systems found.

If the host is found in the configuration file but the file system being checked is not, the default is used. This may be the global default of 60% or a host specific value set in the config file.

The script attempts to exclude cdroms, dvds and loopback devices.

The script is most useful when invoked by cron on a regular schedule throughout the day.

OPTIONS

-c <config file> The default configuration file is /usr/local/etc/chkdf.cf . An alternative configuration file may be set with the -c    option. If no configuration file is found a message is written to standard error and the script terminates.

-d    Set the script to debug mode.

The -x    option is set in the shell, output of the usage and maximum value comparator for each file system is turned on and the contents of the temporary files generated are written to standard out.

-e <e-mail_recipient> Alerts will be sent to the mail address specified at e-mail_recipient. If the -e    option is not used chkdf will attempt to send the email alert to the user invoking the command.

-l    Use the syslog logging facility to record the invocation of chkdf and again should the threshold (see below) be exceeded. This degree of logging for most purposes would be over the top but it does allow activity reports to be generated very easily.

-m <maximum> Set the threshold or maximum percentage usage for any file system on the remote host to <maximum>. This override all settings in the configuration file. It is useful for getting the current state of play on a new host. A value of zero (0) will cause chkdf to report all file systems found.

-u <login_name> The ssh session will attempt to login with login_name.
If no login_name is set on the command line chkdf will attempt to login with the the current effective user id.

-v    Set the operation mode of the script to verbose. In verbose mode chkdf will report it's progress as it runs and will write any alerts to standard out .

EXAMPLES

chkdf merlin

Check the file system usage on merlin using the configuration file /usr/local/etc/chkdf.cf .

Email the user invoking the command if any of the filesystems exceed the usage thresholds set in the configuration file. If a filesystem is not found in the configuration file use the default threshold. If no default is found in the configuration file set a maximum value of 60%.

chkdf -m 65 -e systems.admin@citylinux.com caswallon-gw 

Check the file system usage on "caswallon-gw". Override any thresholds found in the configuration files. If any of the file systems exceed 65% send an email alert to the systems administrator at City Linux.

FILES

/usr/local/etc/chkdf.cf.

BUGS

The script has very little input error checking. Name resolution and network availability is not checked. The script is designed to be used with frequently used host names where ssh keys have already been exchanged.

SEE ALSO

chkftpd, chkfw, clean.

AUTHOR

Clifford W Fulford of City Linux.
Offering systems management and support for Linux, Windows and Apple environments. Contact fulford@fulford.net or +44 (0)709 229 5385.


The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.