#!/bin/ksh ## ## SCRIPT NAME: sho_quota_files4user_bygui ## ## Where: in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################## ## PURPOSE: A utility to show, for a given userid, the files in the ## file server (engprd00) home-directory-file-system ## (= /usr/people = /usrpeople) that go into calculating the ## file-space of the userid to compare with the site 'soft' and ## 'hard' quota limits. ## ## Uses a 'find' command of the form: ## ## rsh engprd00 find /usrpeople -type f -user divadm -exec ls -l {} \; ## ## [In 2000-2001, the hard-quota was 150 Meg, ## and the soft-quota was 120 Meg.] ## ## Includes a GUI prompt for a userid --- along with a description ## of the way the quota system works for any particular userid. ## In particular, ALL FILES ANYWHERE IN THE FILE-SYSTEM (/usrpeople) ## OWNED BY THE USERID COUNT TOWARD THE TOTAL SPACE FIGURE THAT ## IS COMPARED TO THE QUOTA-LIMITS. ## ## ############################################################################## ## GUI INPUTS: from the user, gets a userid. ## ############################################################################## ## CALLED BY: 'spacetools' script in $FEDIR/scripts ## actually, by 'spacetools.chestdef' in $FEDIR/scripts ## ## which is called by the 'handytools' script in $FEDIR/scripts ## ## SGI toolchest-drawer path is ## ## SGI Toolchest -> ## Handy Tools -> ## Any Host - Space Tools (Files) ## Find ALL 'QUOTA-FILES' for a USERID (SIZE-SORT), big 'find' ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 26mar2001 Based on 'divviz_kill_pgms_bygui', ## and 'runcmd_on_pingable_hosts_bygui' and ## 'diruse_files_onelevel_sizesort_bygui' ## in $FEDIR/scripts ## Updated by: Blaise Montandon 27mar2001 Chg format & headings of output list, ## use 'awk' to show file sizes in MegB. ## ## Updated by: Blaise Montandon 08apr2004 To avoid a bug in new SGI 'sort' ## in IRIX 6.5.22, changed several cases ## of 'sort -k5nr' to 'sort +4 -5nr'. ############################################################################## if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi ############################################################################## ## PREPARE ENVIRONMENT VARIABLES TO INITIALIZE GUI - prompt for userid. ############################################################################## SERVER="engprd00" WIN_TITLE="SHOW FILES THAT COUNT TOWARD 'DISK QUOTA' OF A GIVEN USER" export WIN_TITLE WIN_INFO="\ Enter/paste a userid. This utility will find all the files 'OWNED' by that user and in the 'HOME-DIRECTORIES-FILE-SYSTEM' of the SGI network. The list of files is sorted by size, largest at the top. This utility is meant to help a user eliminate 'disk quota exceeded' error messages --- and eliminate all the bad things that happen when a user's space quota is exceeded in the home-directories-file-system. NOTE: ALL FILES OWNED BY THE USERID *ANYWHERE* IN THE HOME-DIRECTORIES-FILE-SYSTEM (/usr/people -- actually $SERVER:/usrpeople) COUNT TOWARD THE TOTAL SPACE FIGURE THAT IS COMPARED TO THE QUOTA-LIMITS. So if USERID1 owns files in the home directory of USERID2, those files count toward the quota of USERID1, NOT the quota of USERID2. [In 2000-2001, the 'hard-quota' was 150 Meg, and the 'soft-quota' was 120 Meg. A user gets 'warning' messages when the total space occupied by files owned by the user exceeds the 'soft-quota'. And the user can no longer create files in the /usr/people (= /usrpeople) file system on the server, when the user exceeds the 'hard-quota'.] It will take several minutes to scan the home-directories-file-system. Then a size-sorted file list will be presented. Use this query sparingly --- only when in a 'disk quota exceeded' situation AND a query on the file space occupied in the USERID HOME DIRECTORY does NOT seem to add up to be 'near' the userid-disk-quota limits." export WIN_INFO WIN_PROMPT="USERID:" export WIN_PROMPT ## Optionally, initialize the entry with a default: WIN_ENTRY="$USER" export WIN_ENTRY ## Optional setting of color scheme for the window: WIN_COLOR="lightskyblue" export WIN_COLOR ## FOR TESTING: # set -x USER_ID=`$FEDIR/tkGUIs/enter_at1prompt.tk` ## FOR TESTING: # set - if test "$USER_ID" = "" then exit fi ############################################################################## ## WARN USER THAT THIS QUERY WILL TAKE OVER 2 MINUTES. ## (I.e. the report will appear in a couple of minutes.) ############################################################################## xconfirm -c -B DISMISS \ -t "This query on the home-directory-file-system," \ -t "$SERVER:/user/people, will take SEVERAL MINUTES to complete." \ -t "" \ -t "Use this query sparingly --- only when a query on the file" \ -t "space occupied in the * $USER_ID * home directory does NOT" \ -t "seem to be near the userid-disk-quota limits." \ -t "" \ -t " [In 2000-2001, the 'hard-quota' was 150 Meg," \ -t " and the 'soft(warning)-quota' was 120 Meg.]" \ -t "" \ -t "Unfortunately," \ -t "for technical reasons, the userid QUOTAS apply to the ENTIRE" \ -t "home-directories FILE SYSTEM, NOT to individual home DIRECTORIES." \ -t "" \ -t "The query has started, on $SERVER. The report will be shown" \ -t "in a couple of minutes. You may work in other windows." \ -font -*-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ > /dev/null & # -font -adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ ############################################################################## ## SET AN $OUTLIST FILENAME. ############################################################################## . $FEDIR/scripts/set_localoutlist ## rm -f $OUTLIST ########################################################################## ## SET THE *TOP* OF THE REPORT HEADING --- for the sorted files listing. ########################################################################## echo "\ ********************* `date '+%Y %b %d %a %T%p'` *********************** FOR USERID $USER_ID HERE IS A SIZE-SORTED LIST OF FILES THAT COUNT TOWARD THE DISK-QUOTA FOR THE USER. THESE ARE ALL FILES 'OWNED' BY $USER_ID --- IN THE HOME-DIRECTORIES-FILE-SYSTEM ON THE SERVER $SERVER --- THAT IS, ${USER_ID}-OWNED FILES IN *ANY DIRECTORY* UNDER THE DIRECTORY: $SERVER:/usr/people Disk usage Last-Modified (MegaBytes) Permissions Owner Group Date-time Filename ------------- ----------- -------- -------- ------------ ---------------------- GigMeg.KilByt | | | | " > $OUTLIST ## Disk usage Last-Modified ## Permissions Owner Group (Bytes) Date-time Filename ## ----------- -------- -------- ---------- ------------ ---------------------- ## ************* ## Disk usage Last-Modified ## (MegaBytes) Permissions Owner Group Date-time Filename ## ------------- ----------- -------- -------- ------------ ---------------------- ## GigMeg.KilByt ## | | | | ######################################################################## ## FIND THE FILES OWNED BY THE SPECIFIED $USER_ID. ######################################################################## ############################################## ## MAKE .rhosts FILE FOR THE USER, if needed. ############################################## ## echo "+ $USER" > $HOME/.rhosts ############################################## . $FEDIR/scripts/mak_rhosts ## FOR TESTING: set -x # rsh $SERVER \ # "find /usrpeople -type f -user $USER_ID -exec ls -l {} \; 2> /dev/null" \ # | sort -k5nr | >> $OUTLIST rsh $SERVER \ "find /usrpeople -type f -user $USER_ID -exec ls -l {} \; 2> /dev/null" \ | sort +4 -5nr | \ awk '{printf ("%13.6f %-10s %-8s %-8s %-3s %2s %5s %s\n", $5/1000000, $1, $3, $4, $6, $7, $8, $9 )}' \ >> $OUTLIST # | sort -k5nr | \ ## FOR TESTING: set - ######################################################################## ## Add TRAILER to report. ######################################################################## echo " | | | | GigMeg.KilByt ------------- ----------- -------- -------- ------------ ---------------------- (MegaBytes) Permissions Owner Group Date-time Filename Disk usage Last-Modified ********************* `date '+%Y %b %d %a %T%p'` *********************** The output above is from script $0 which was run from host $THISHOST . ........................................................................... This utility is meant to help a user eliminate 'disk quota exceeded' error messages --- and eliminate all the bad things that happen when a user's space quota is exceeded in the home-directories-file-system. NOTE: ALL FILES OWNED BY THE USERID *ANYWHERE* IN THE HOME-DIRECTORIES-FILE-SYSTEM (/usr/people -- actually $SERVER:/usrpeople) COUNT TOWARD THE TOTAL SPACE FIGURE THAT IS COMPARED TO THE QUOTA-LIMITS. So if USERID1 owns files in the home directory of USERID2, those files count toward the quota of USERID1, NOT the quota of USERID2. THIS EXPLAINS WHY, SOMETIMES, A USER GETS IN A 'DISK QUOTA EXCEEDED' SITUATION EVEN WHEN THE FILE SIZES IN THE USER'S HOME DIRECTORY DO NOT ADD UP TO THE SITE QUOTA LIMITS. [In 2000-2001, the 'hard-quota' was 150 Meg, and the 'soft-quota' was 120 Meg. A user gets 'warning' messages when the total space occupied by files owned by the user exceeds the 'soft-quota'. And the user can no longer create files in the /usr/people (= /usrpeople) file system on the server, when the user user exceeds the 'hard-quota'.] Unfortunately, for technical reasons, the userid quotas apply to the entire home-directories FILE SYSTEM, NOT to individual home DIRECTORIES. ........................................................................... SGI toolchest-drawer path is SGI Toolchest -> Handy Tools -> Any Host - Space Tools (Files) -> Find ALL 'QUOTA-FILES' for a USERID (SIZE-SORT), big 'find' ........................................................................... Commands used: rsh $SERVER find /usrpeople -type f -user $USER_ID -exec ls -l {} \; piped into sort +4 -5nr AND awk '{printf (\"..a format..\", \$5/1000000, \$1, \$3, \$4, \$6, \$7, \$8, \$9 )}' ........................................................................... " >> $OUTLIST ##################################################################### ## SHOW THE REPORT. ##################################################################### ## $FEDIR/scripts/shofil Does not work in an 'xwsh' from toolchest. ## Apparently, ## because of '&' batch invocation of shofil.tk within this script. ##################################################################### ## If you start this script from an 'xwsh', instead of the following ##################################################################### # $FEDIR/scripts/shofil $OUTLIST ##################################################################### ## you could use the following statements. ##################################################################### # # SHOFILENAME=$OUTLIST # export SHOFILENAME # # XLPHP_FORMAT="AV" # export XLPHP_FORMAT # ## $FEDIR/tkGUIs/shofil.tk & ## DOES NOT SHOW UP in an 'xwsh'. # $FEDIR/tkGUIs/shofil.tk # ##################################################################### XLPHP_FORMAT="AH" export XLPHP_FORMAT $FEDIR/scripts/shofil $OUTLIST