Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!amdahl!pyramid!uccba!hal!ncoast!allbery
From: allbery@ncoast.UUCP
Newsgroups: comp.sources.misc
Subject: Script to generate nice disk usage reports
Message-ID: <2676@ncoast.UUCP>
Date: Thu, 18-Jun-87 12:31:54 EDT
Article-I.D.: ncoast.2676
Posted: Thu Jun 18 12:31:54 1987
Date-Received: Sun, 21-Jun-87 04:55:30 EDT
Sender: allbery@ncoast.UUCP
Lines: 133
Approved: allbery@ncoast.UUCP
X-Archive: sources_misc/871619.01

This script prints nice summaries of people's disk usage, as they change
from day-to-day and week-to-week.  The sample shown below is somewhat off,
because I just ran the thing twice to get two reports.  I lifted this from
a source that would rather remain anonymous.  I did some hacking to make
it more efficient (e.g., the "eval" stuff).
		-rich $alz

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh diskuse.sh <<'END_OF_diskuse.sh'
X
X#! /bin/sh
X# Show report of disk usage.  Should be run nightly from cron.  The
X# report looks like this:
X#	Thu Jun 18 01:12:26 EDT 1987
X#	Filesystem    kbytes    used   avail capacity  Mounted on
X#	/dev/ra0h      87519   70147    8620    89%    /usr/politics
X#	
X#	 Today Yester Change   Week Change  Directory
X#	 21766  21766      0        +21766  bidden
X#	 12645  12645      0        +12645  donaldson
X#	 10632  10632      0        +10632  kemp
X#	  4493   4493      0         +4493  emacs
X#	  2810   2808     +2         +2810  pac
X#	  1932   1932      0         +1932  common-cause
X#	  1566   1566      0         +1566  guest
X#	  1213   1213      0         +1213  root
X#	   596    596      0          +596  reagan
X#	   594    594      0          +594  bush
X#	   349    349      0          +349  hart
X#	   248    248      0          +248  kennedy
X#	    51     51      0           +51  cuomo
X#	 28634      4      0            +4  lost+found
X# Where the columns mean:
X#	Today		Today's usage
X#	Yester		What it was yesterday
X#	Change		Difference over the two days
X#	Week		What it was last week
X#	Change		Difference from last week
X#	Directory	Directory within this filesystem.
X
X# Our output goes to stderr; reports go to stdout
Xexec >&2
X
X# This is where the "raw" du reports go.
XUSEDIR=/usr/adm/.du
X# This is where the daily reports go.
XOUTDIR=/usr/adm/disk_use
X
X# Build filesystem list into commands to set shell variables.
XLIST=`awk -F: '{ printf "DEV=%s;FS=%s\n", $1, $2 }' ${USE}.0
X#   cd ${FS} ; du * | grep -v '\.*/.*'  | sort +1 >${USE}.0
X
X    # Send output to report
X    touch ${OUT}
X    mv -f ${OUT} ${OUT}.BAK
X    exec >${OUT}
X
X    # Prolog
X    date
X    df ${DEV}
X    echo
X    awk  0)
X	    dsign = "+"
X	else
X	    dsign = ""
X	week = $2 - $4
X	if (week > 0)
X	    wsign = "+"
X	else
X	    wsign = ""
X	printf FMT, $2, $3, dsign day, $4, wsign week, $1
X    }' | sort -nr
X
X    # Send our output back to stderr.
X    exec >&2
Xdone
X
END_OF_diskuse.sh
if test 2815 -ne `wc -c