#!/bin/ksh ## ## SCRIPT NAME: select_subdir_siz_recs ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ## SEE GUI VERSION IN ## $FEDIR/scripts/select_subdir_siz_recs_bygui ## ############################################################################## ## ## PURPOSE: Creates a size-sorted * /data * sub-directory * listing by ## extracting lines from a weekly-created file like ## ## ${REPORTDIR}/spac_data_dirs_siz.lis ## or ${REPORTDIR}/spac_apps_dirs_siz.lis ## ## where REPORTDIR="/usr/people/ideasadm/cleandir" ## ## The extract is done in either of two ways ## 1) specifying a number of directory levels to show (1,2,3,4) ## 2) specifying a key-string to search for. Examples: ## subs, ideas, shared, datamgmt, flowmaster, etc. ## ## NOTE: ## The /data & /apps subdir report files are created by ## the ideasadm crontab script ## ## creat_datadirsiz_lists in /apps/ideas/cron ## ## on 'engprd00'. ## See 'crontab -l' on engprd00, as ideasadm. ## See /apps/ideas/cron/READMEcrontab_ideas ## and /apps/ideas/cron/zREADMEcrontab_ideas.OLD97jul14 ## ############################################################################## ## ## CALLED BY: feamain -> ideclean.menu -> engdir_overview.menu ## in $FEDIR/scripts ## ## I.e. go to the nnsFEAmenu option 'c do' (Clean, DirOverview). ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: B.Montandon O06 27May99 based on ## $FEDIR/scripts/get_ideasfe_usage ## $FEDIR/scripts/prtplt_lookup_Qinfo ## and /apps/ideas/cron/creat_datadirsiz_lists ## Updated by: B.Montandon O06 27May99 ############################################################################## ##################################################################### ## SET THE REPORT TO EXTRACT FROM -- in $REPORT ##################################################################### REPORTDIR="/usr/people/ideasadm/cleandir" REPORT="${REPORTDIR}/spac_data_dirs_siz.lis" if test "$1" = "" then echo " This script requires a report file containing lines with the names of sub-directories and their sizes. Like $REPORT Exiting. *** Press Enter to finish." read NNS_JUNK exit fi REPORT="$1" ##################################################################### ## SET UTILITY-SCRIPT DIR VAR(s), if not set already. ##################################################################### if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi ##################################################################### ## PROMPT FOR QUERY PARMS -- no of dir levels or a search string. ##################################################################### # WINTITLE="SubDir Size List, Extract Info" # export WINTITLE # # TEMP=`$FEDIR/tkGUIs/enter_subdir_rept_query.tk` # eval $TEMP # # if test \( "$FIELD1" = "" -a "$FIELD2" = "" -a "$FIELD3" = "" \) # then # exit # fi . $FEDIR/scripts/clearnns echo "${HIbold}\ ...................................................................... SUBDIRECTORIES EXTRACT ${HIreset} from $REPORT a report generated at network quiet times. ${HIbold} ENTER A NUMBER to represent the sub-directory depth which you want to see (i.e. number of slashes, /, in each record)${HIreset} 2 3 4 5 ${HIbold}-OR- ENTER A SEARCH STRING, like${HIreset} ideas datamgmt shared flowmaster ${HIbold}-OR- simply press ENTER to EXIT ==>${HIreset} \c" read SEARCHSTR if test "$SEARCHSTR" = "" then continue # break # exit fi ##################################################################### ## PREP TEXT OUTPUT LIST FILE. ##################################################################### . $FEDIR/scripts/set_localoutlist ##################################################################### ## SET SEARCH-DESC in $SEARCH_CRIT -- for report header ##################################################################### if test "$SEARCHSTR" = "2" then SEARCH_CRIT="no more than 2 directory levels" elif test "$SEARCHSTR" = "3" then SEARCH_CRIT="no more than 3 directory levels" elif test "$SEARCHSTR" = "4" then SEARCH_CRIT="no more than 4 directory levels" elif test "$SEARCHSTR" = "5" then SEARCH_CRIT="no more than 5 directory levels" else SEARCH_CRIT="by search string: $SEARCHSTR" fi ##################################################################### ## PREP HEADER FOR LIST FILE. ##################################################################### echo "\ .................... `date '+%Y %b %d %a %T%p %Z'` ...................... DISK USAGE (in 1K blocks) in SUB-DIRECTORIES SEARCH CRITERION: $SEARCH_CRIT Sorted by sub-directory size. Largest sub-directories at the top. Similar to nnsFEAmenu query option 'u f ud' (Utilities, File-tools, Used-in-subDirectories) ... but to reduce load on the system and to get quick response, this report is extracted from an 'ideasadm' weekly cron job report done on the server: $REPORT This report extract can be done at nnsFEAmenu opt 'c do sd' or 'c do sa' for subdirectories of /data or /apps. Disk usage Subdirectory (1K blks) name ------------ --------- " > $OUTLIST ################################################# ## PREP 2-DIR-LEVELS EXTRACT ################################################# if test "$SEARCHSTR" = "2" then ## Remove comment lines; Remove blank lines; Remove lines with 3 or more slashes grep -v "^#" $REPORT | grep -v "^$" | grep -v "/.*/.*/" | \ awk '{printf ("%11s %s \n", $1, $2 )}' >> $OUTLIST ################################################# ## PREP 3-DIR-LEVELS EXTRACT ################################################# elif test "$SEARCHSTR" = "3" then ## Remove comment lines; Remove blank lines; Remove lines with 4 or more slashes grep -v "^#" $REPORT | grep -v "^$" | grep -v "/.*/.*/.*/" | \ awk '{printf ("%11s %s \n", $1, $2 )}' >> $OUTLIST ################################################# ## PREP 4-DIR-LEVELS EXTRACT ################################################# elif test "$SEARCHSTR" = "4" then ## Remove comment lines; Remove blank lines; Remove lines with 5 or more slashes grep -v "^#" $REPORT | grep -v "^$" | grep -v "/.*/.*/.*/.*/" | \ awk '{printf ("%11s %s \n", $1, $2 )}' >> $OUTLIST ################################################# ## PREP 5-DIR-LEVELS EXTRACT ################################################# elif test "$SEARCHSTR" = "5" then ## Remove comment lines; Remove blank lines; Remove lines with 6 or more slashes grep -v "^#" $REPORT | grep -v "^$" | grep -v "/.*/.*/.*/.*/.*/" | \ awk '{printf ("%11s %s \n", $1, $2 )}' >> $OUTLIST ################################################# ## PREP SEARCH-STRING EXTRACT ################################################# else ## Remove comment lines; Remove blank lines; Remove lines with 6 or more slashes grep -v "^#" $REPORT | grep -v "^$" | grep "$SEARCHSTR" | \ awk '{printf ("%11s %s \n", $1, $2 )}'>> $OUTLIST fi ##################################################################### ## SHOW INFO FOUND ##################################################################### # set -x export SHOFILENAME="$OUTLIST" $FEDIR/tkGUIs/shofil.tk & # set -