Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FILE SYSTEM USAGE 4

Status
Not open for further replies.

Ann28

MIS
Apr 2, 2004
97
US
Hi Everyone -

I am using unix AIX Version 5.2.

What command should I use to see the CPU utilization & how many bytes, % every file in the system is using to see if it needs to be reorganized/resized.


Thanks a lot for your help!
Ann. [ponytails]

 
Mohmin,

you can try the following commands,they all work:


#vmstat 2 10 % checks virtual mem and cpu status
every 2 sec 10 times.

#iostat 2 10 % checks the cpu and disk activity

#ps -ef |wc -l % to see no: of process running

#ps aux

#sar -u 60 30 %collects cpu usage every 60sec
#topas

bye,
 
Thank you Mohmin!

But I need a command to list all files in the system along with the %
df ??? [ponder]
 
mohmin,


#lsfs

#lsfs -q (fsname)

#dfsck /filesystem/filesystem



I think i did'nt get ur question,if yes then the above commands should resolve it.

If not let me know....

Bye,
 
THAKS ALL FOR YOUR HELP!!! [bigears]
but I really need a command to show all the files under the directory & the usage %
 
As kHz says, du might be part of the answer. man du for details, but you might need to manipulate it for percentages.
 
Here is a little script I wrote up to help out some of our SA's in identifying large files within given directories. Please feel free to use and distibute as you see fit. Remeber that if you copy and paste this there may be lines that word wrapped in this forum and need to be recombined when you paste it into your UNIX machine.

#!/bin/ksh
#
# This script will find the top 10 space offenders in any given filesystem.
# Written by Jim Hirschauer

comma ()
{
if [ $# -ne 1 ]
then
echo "Usage: $(basename $0) number"
exit 1
fi

(( TMP = $(echo $1 | wc -c) - 1 ))
(( TMP1 = TMP / 3 ))
(( NUM = TMP - ( TMP1 * 3 ) ))

case $TMP1 in
0)
NUM1=$(echo $1 | cut -c 1-$NUM)
echo $NUM1 | awk '{printf "%s\n", $1}'
;;
1)
if [ $NUM -eq 0 ]
then
NUM1=$(echo $1 | cut -c 1-$NUM)
echo $NUM1 | awk '{printf "%s\n", $1}'
else
NUM1=$(echo $1 | cut -c 1-$NUM)
NUM2=$(echo $1 | cut -c $(( 1 + NUM ))-$(( 3 + NUM )))
echo $NUM1 $NUM2 | awk '{printf "%s,%s\n", $1, $2}'
fi
;;
2)
if [ $NUM -eq 0 ]
then
NUM1=$(echo $1 | cut -c 1-3)
NUM2=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
echo $NUM1 $NUM2 | awk '{printf "%s,%s\n", $1, $2}'
else
NUM1=$(echo $1 | cut -c 1-$NUM)
NUM2=$(echo $1 | cut -c $(( 1 + NUM ))-$(( 3 + NUM )))
NUM3=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
echo $NUM1 $NUM2 $NUM3 | awk '{printf "%s,%s,%s\n", $1, $2, $3}'
fi
;;
3)
if [ $NUM -eq 0 ]
then
NUM1=$(echo $1 | cut -c 1-3)
NUM2=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM3=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
echo $NUM1 $NUM2 $NUM3 | awk '{printf "%s,%s,%s\n", $1, $2, $3}'
else
NUM1=$(echo $1 | cut -c 1-$NUM)
NUM2=$(echo $1 | cut -c $(( 1 + NUM ))-$(( 3 + NUM )))
NUM3=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM4=$(echo $1 | cut -c $(( 7 + NUM ))-$(( 9 + NUM )))
echo $NUM1 $NUM2 $NUM3 $NUM4| awk '{printf "%s,%s,%s,%s\n",$1,$2,$3,$4}'
fi
;;
4)
if [ $NUM -eq 0 ]
then
NUM1=$(echo $1 | cut -c 1-3)
NUM2=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM3=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM4=$(echo $1 | cut -c $(( 7 + NUM ))-$(( 9 + NUM )))
echo $NUM1 $NUM2 $NUM3 $NUM4| awk '{printf "%s,%s,%s,%s\n",$1,$2,$3,$4}'
else
NUM1=$(echo $1 | cut -c 1-$NUM)
NUM2=$(echo $1 | cut -c $(( 1 + NUM ))-$(( 3 + NUM )))
NUM3=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM4=$(echo $1 | cut -c $(( 7 + NUM ))-$(( 9 + NUM )))
NUM5=$(echo $1 | cut -c $(( 10 + NUM ))-$(( 12 + NUM )))
echo $NUM1 $NUM2 $NUM3 $NUM4 $NUM5| awk '{printf "%s,%s,%s,%s,%s\n",$1,$
2,$3,$4,$5}'
fi
;;
5)
if [ $NUM -eq 0 ]
then
NUM1=$(echo $1 | cut -c 1-3)
NUM2=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM3=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM4=$(echo $1 | cut -c $(( 7 + NUM ))-$(( 9 + NUM )))
NUM5=$(echo $1 | cut -c $(( 10 + NUM ))-$(( 12 + NUM )))
echo $NUM1 $NUM2 $NUM3 $NUM4 $NUM5| awk '{printf "%s,%s,%s,%s,%s\n",$1,$
2,$3,$4,$5}'
else
NUM1=$(echo $1 | cut -c 1-$NUM)
NUM2=$(echo $1 | cut -c $(( 1 + NUM ))-$(( 3 + NUM )))
NUM3=$(echo $1 | cut -c $(( 4 + NUM ))-$(( 6 + NUM )))
NUM4=$(echo $1 | cut -c $(( 7 + NUM ))-$(( 9 + NUM )))
NUM5=$(echo $1 | cut -c $(( 10 + NUM ))-$(( 12 + NUM )))
NUM6=$(echo $1 | cut -c $(( 13 + NUM ))-$(( 15 + NUM )))
echo $NUM1 $NUM2 $NUM3 $NUM4 $NUM5 $NUM6| awk '{printf "%s,%s,%s,%s,%s,%
s\n",$1,$2,$3,$4,$5,$6}'
fi
;;
*) echo $1
;;
esac
}

list2array ()
{
# For Directories.
#echo "LIST2ARRAY dir"
set -A SIZE
set -A NAME
i=0
echo "${LIST}" | while read ELEMENT1 ELEMENT2
do
SIZE=$ELEMENT1
NAME=$ELEMENT2
(( i = i + 1 ))
done
# For files.
#echo "LIST2ARRAY file"
set -A FSIZE
set -A FNAME
j=0
echo "${FLIST}" | while read ELEMENT1 ELEMENT2
do
if [ -n "$ELEMENT1" ]
then
FSIZE[j]=$ELEMENT1
FNAME[j]=$ELEMENT2
(( j = j + 1 ))
fi
done
}

buildmenu ()
{
#echo "BUILDMENU dir"
clear
j=0
k=1
ARRLEN=${#SIZE[*]}
echo "\n----- Directories -----"
while [ $j -lt $ARRLEN ]
do
echo "$k ${NAME[$j]} = `comma ${SIZE[$j]}` Kb"
(( j = j + 1 ))
(( k = k + 1 ))
done

#echo "BUILDMENU file"
j=0
FARRLEN=${#FSIZE[*]}
echo "\n----- Largest files in ${NAME[0]} -----"
while [ $j -lt $FARRLEN ]
do
echo "${FNAME[$j]} = `comma ${FSIZE[$j]}` bytes"
(( j = j + 1 ))
done
}

mklist ()
{
echo "Working, please wait..."
LIST=$(du -k ${NAME[$NUM]} | sort -rn | head -10)
FLIST=$(ls -l ${NAME[$NUM]} | grep -v ^d | sort +4 -rn | head -10 | awk '{print $5, $9}')
}

#
# Main section
#
clear
read FS?"Which filesystem/directory do you want to examine? "
if [ ! -d "$FS" ]
then
echo "ERROR: You must enter a valid filesystem or directory name."
else
echo "Working, please wait..."
LIST=$(du -k $FS | sort -rn | head -10)
FLIST=$(ls -l $FS | grep -v ^d | sort +4 -rn | head -10 | awk '{print $5, $9}')
list2array
buildmenu
QUIT=0
while [ "$QUIT" != 99 ]
do
echo
read QUIT?"Choose a directory to drill down into: (1-$ARRLEN or 99 to quit) "
if [[ "$QUIT" -ge 1 && "$QUIT" -le $ARRLEN ]]
then
(( NUM = QUIT - 1 ))
[[ "$QUIT" != 99 ]] && mklist
[[ "$QUIT" != 99 ]] && list2array
[[ "$QUIT" != 99 ]] && buildmenu
else
[[ "$QUIT" != 99 ]] && echo "ERROR: Invalid selection"
fi
done
fi


Jim Hirschauer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top