#!/bin/sh - # # $Id: gdf,v 1.9 2003/03/31 01:06:35 dgregor Exp $ # # Copyright (c) 2000 Daniel J. Gregor, Jr., All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Daniel J. Gregor, Jr. # 4. The name of Daniel J. Gregor, Jr. may not be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY DANIEL J. GREGOR, JR. ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DANIEL J. GREGOR, JR. BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # This script is based on the example output of a script that # was sent to the sage-members@usenix.org mailing list by Dave # Caplinger . # df -k "$@" | \ awk ' BEGIN { dashes = "===================="; print " MB MB % Mount"; print " Max Used Used Dir"; print ""; } NF == 1 { join = $1; next; } NF == 5 { $0 = join " " $1 " " $2 " " $3 " " $4 " " $5; } /^\// && $2 > 0 { if (lastfs != "") { $6 = $5; $5 = $4; $4 = $3; $3 = $2; $2 = $1; $1 = lastfs; lastfs = ""; } if (NF == 1) { lastfs = $1; } else { l = int(($3 / $2) * 20); if (l < 20) { arrow = ">"; } else { arrow = ""; } printf "%10.2f %10.2f [%-20s] %5.1f%% %s\n", \ $2 / 1024, \ $3 / 1024, \ substr(dashes, 1, l) arrow, \ ($3 / $2) * 100, \ $6; max += ($2 / 1024); used += ($3 / 1024); } } END { print ""; printf "Total: %.2f MBytes (%.1f%% of %.2f Mbytes in use)\n", \ used, \ (used / max) * 100, \ max; } '