Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 72 lines (65 sloc) 1.519 kB
#!/bin/bash
#################
# Operation - disk_util.sh
# This script is written to check status of disk or diskusage
# https://github.com/sillydong/Operation
#
# By Chen Zhidong
# http://sillydong.com
# Email:njutczd+gmail.com
# GPL v2
#################
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
usage(){
echo " This script is written to check status of disk or diskusage"
echo " $0 command"
echo " command:"
echo " u|usage - show diskusage"
echo " i|inode maxdepth path - analysis inodes of directories in maxdepth of path"
echo " o|io - use vmstat to show system stat"
exit 0
}
check_usage(){
df -h
}
check_inode(){
#check_inode maxdepth directory
if [ $# -lt 2 ];then
echo "$0 i|inode maxdepth directory"
else
if [ -e $2 -a -d $2 ];then
dirs=`find -P $2 -maxdepth $1 -type d | grep -xv $2 | grep -xv . | sort`
for d in $dirs
do
if [ -e $d -a -d $d ];then
c=$(find -P $d -type f | wc -l)
printf "%-70s- %s\n" $d $c
fi
done
printf "%-70s- %s\n" "Total:" $(find -P $2 -type f | wc -l)
else
echo "$2 not exist"
fi
fi
}
check_io(){
vmstat 1
}
if [ $# -lt 1 ];then
usage
else
case $1 in
u|usage)
check_usage
;;
i|inode)
check_inode $2 $3
;;
o|io)
check_io
;;
*)
;;
esac
fi
Jump to Line
Something went wrong with that request. Please try again.