summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/checkXFSfrag.sh
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/LinHES-system/checkXFSfrag.sh')
-rwxr-xr-xabs/core/LinHES-system/checkXFSfrag.sh22
1 files changed, 15 insertions, 7 deletions
diff --git a/abs/core/LinHES-system/checkXFSfrag.sh b/abs/core/LinHES-system/checkXFSfrag.sh
index 99b833c..74b73c4 100755
--- a/abs/core/LinHES-system/checkXFSfrag.sh
+++ b/abs/core/LinHES-system/checkXFSfrag.sh
@@ -28,24 +28,32 @@
# DO NOT ALTER HEADER FROM THIS LINE UP.
#
e='/bin/echo -e' # Use the echo command, not built-in.
-xfsfsr=/usr/sbin/xfs_fsr # Set variable with the path to xfs_fsr.
-xfsdb=/usr/sbin/xfs_db # Set variable with the path to xfs_db.
+xfsfsr=/usr/bin/xfs_fsr # Set variable with the path to xfs_fsr.
+xfsdb=/usr/bin/xfs_db # Set variable with the path to xfs_db.
pctmax=15 # Set maxiumum frag percent needed for defrag.
# This is zero here for testing purposes only
# a higher number should be used in production.
array=`df -T|grep xfs|cut -f 1 --delim=" "` # Array of all XFS file systems.
for i in ${array[@]};
do
- percentage=`$xfsdb -c frag -r ${i}|cut -f 7 --delim=" "`
- percent2=`$e $percentage|cut -f 1 --delim=.`
- if [ "$percent2" -gt "$pctmax" ]
+ #check that the device is SATA and skip defrag on SSDs
+ device=`echo ${i} | cut -f 3 --delim="/" | sed 's/[0-9]//g'`
+ isSATA=`cat /sys/block/${device}/queue/rotational`
+ if [[ $isSATA -eq 1 ]]
then
- $e "${i} is $percentage fragmented. Running defragment on ${i}."
+ percentage=`$xfsdb -c frag -r ${i}|cut -f 7 --delim=" "`
+ percent2=`$e $percentage|cut -f 1 --delim=.`
+ if [ "$percent2" -gt "$pctmax" ]
+ then
+ $e "${i} is $percentage% fragmented. Running defragment on ${i}."
# Only uncomment one of the following two lines.
#$xfsfsr -v ${i} # Uncomment for verbose defrag.
$xfsfsr ${i} # Uncomment for quiet defrag.
+ else
+ $e "${i} is $percent2% fragmented and is below the fragmentation threshold of $pctmax%. Skipping."
+ fi
else
- $e "${i}\t$percent2 is not above fragmentation threshold of $pctmax."
+ echo "${i} is an SSD. Skipping."
fi
done
exit 0