-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsnfsFileCount.sh
executable file
·119 lines (98 loc) · 1.95 KB
/
snfsFileCount.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
# Argument = -b beginning_stripe_group -e ending_string_group -f fs_mount_point -d output_dir_name -t num_threads
CURDATE=`date +"%m_%d_%Y-%H_%M_%S"`
SOURCEPATH=
SGSTART=4
SGEND=4
TCOUNT=3
usage()
{
cat << EOF
usage: $0 [-d output_dir_name] [-f fs_mount_point] [-b beginning_stripe_group] [-e ending_stripe_group] [-t num_threads]
OPTIONS:
-d Target Directory (must exists).
-f File System Mount Point to Run report on
-b Beginning Stripe Group
-e Ending Stripe Group
-t num_threads
EOF
}
intro()
{
cat << EOF
Dumping file lists EspritProd, SG2-SG20.
Started at $CURDATE
EOF
}
threadThrottle()
{
while [ `jobs -r | grep -c .` -ge $TCOUNT ]
do
sleep 10
done
}
#BEGIN SCRIPT EXECUTIION
DIR=/stornext/EspritCDN_MX/migration_reports/
# GETOPTS
while getopts “d:f:b:e:t:” OPTION
do
case $OPTION in
d)
DIR=$OPTARG
;;
f)
SOURCEPATH=$OPTARG
;;
b)
SGSTART=$OPTARG
;;
e)
SGEND=$OPTARG
;;
t)
TCOUNT=$OPTARG
;;
esac
done
if [[ -z $DIR ]]
then
echo "Directory " $DIR " not specified."
usage
exit 1
fi
if ! [ -d $DIR ]
then
echo "Directory " $DIR " does not exist"
usage
exit 1
fi
if [[ -z $SOURCEPATH ]]
then
echo "Filesystem mount point not specified"
usage
exit 1
fi
if ! [ -d $SOURCEPATH ]
then
echo "Directory " $SOURCEPATH " does not exist"
usage
exit 1
fi
# Print date & time started
intro
DIR=$DIR`date +"%m_%d_%Y-%H_%M_%S"`
# Make directory for current run
mkdir $DIR
if ! [ -d $DIR ]
then
echo "Directory " $DIR " could not be created"
exit 1
fi
for (( i=$SGSTART; i<=$SGEND; i++))
do
# if the number of running jobs exceeds the max, wait until one job is done
threadThrottle
snfsdefrag -l -G $i -m 0 -r $SOURCEPATH > $DIR"/SG"$i".txt" &
done
wait;
echo "Finished at " `date +"%m_%d_%Y-%H_%M_%S"`