echo restoring unused_space.sh cat > unused_space.sh << 'XxXxX-EOF-XoXoX' #!/bin/ksh #====================================== # # Have you ever needed space really badly and not had any drives available. # This program will show you any space left on the volumes that you are already using. # # unused_space.sh Program to show you which chunks have space left. # change the MAXCHUNKSIZE and MINWASTED variables to # values that work at your site. We use 2048000 as the max chunksize # We have logical volumes so we do not typically have an offset. # MinWasted is useful for skipping offsets. # #===================================== # # Written by: Curtis Crowson # BellSouth Advertising & Publishing # crowson.curtis@bapco.bls.com # #==================================== # # Standard Disclaimers for software apply email if you have an issue. # Use this at your own risk. # Copyright July 6, 1999 by Curtis Crowson # Use this under the FSF license. # #=================================== MAXCHUNKSIZE=2048000 # set to the max chunk size that you usually use. MINWASTED=0 # set to skip small unused spaces. like offsets of 10 etc. program=`basename $0` if [ $# -ne 0 ] ; then echo 'Usage: $program' exit 1 fi beginline=`onstat -d | nawk '{if ($1=="Chunks") { print NR + 2 ; exit }}'` onstat -d | tail +$beginline | tail -r | tail +3 | nawk '{printf"%s %20d %20d\n",$NF,$4*2,$5*2}'| sort | nawk \ -v MAXCHUNKSIZE=$MAXCHUNKSIZE \ -v MINWASTED=$MINWASTED \ ' BEGIN { cur_chunk = "" cur_space_used=MAXCHUNKSIZE } { if ($1 != cur_chunk) { if (cur_space_used + MINWASTED < MAXCHUNKSIZE) { printf "%s: %d - %d\n",cur_chunk,cur_space_used,MAXCHUNKSIZE } cur_chunk = $1 cur_offset = 0 cur_space_used=0 } if ($2 - cur_space_used > MINWASTED) { printf "%s: %d - %d\n",$1,cur_space_used,$2 } cur_space_used += $3 + ($2 - cur_space_used) } END { if (cur_space_used + MINWASTED < MAXCHUNKSIZE) { printf "%s: %d - %d\n",cur_chunk,cur_space_used,MAXCHUNKSIZE } }' XxXxX-EOF-XoXoX