From bb07bc66b3020f320fb818ec426807fcb89159f0 Mon Sep 17 00:00:00 2001 From: Britney Fransen Date: Sat, 31 Aug 2013 20:58:00 -0500 Subject: LinHES-system: add checkXFSfrag.sh and weekly cron job. closes #929 --- abs/core/LinHES-system/PKGBUILD | 10 +++++-- abs/core/LinHES-system/checkXFSfrag.sh | 51 ++++++++++++++++++++++++++++++++++ abs/core/LinHES-system/xfs_defrag | 3 ++ 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100755 abs/core/LinHES-system/checkXFSfrag.sh create mode 100755 abs/core/LinHES-system/xfs_defrag diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 8588f3a..be0de10 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=8.0 -pkgrel=3 +pkgrel=4 arch=('i686' 'x86_64') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin @@ -32,12 +32,13 @@ binfiles="LinHES-start optimize_mythdb.py misc_upcoming_recordings.pl misc_which_recorder.pl change_channel.sh change_channel_wrapper.sh - be_check.py" + be_check.py + checkXFSfrag.sh" source=(LinHES-session LinHES-profile.sh $binfiles alsa-base myth_mtc.lr - diskspace cacheclean.cron + diskspace cacheclean.cron xfs_defrag readme_is_xml readme_light add_storage.readme system-sudo.rules ) @@ -71,6 +72,7 @@ build() { install -m755 -D $startdir/src/cacheclean.cron $startdir/pkg/etc/cron.weekly/cacheclean.cron install -m755 -D $startdir/src/diskspace $startdir/pkg/etc/cron.tenminutes/diskspace install -m644 -D $startdir/src/myth_mtc.lr $startdir/pkg/etc/logrotate.d/myth_mtc + install -m755 -D $startdir/src/xfs_defrag $startdir/pkg/etc/cron.weekly/xfs_defrag #sudo rules @@ -121,10 +123,12 @@ md5sums=('8fc4b7c1ddf8f3c4d2266ce55086b4d4' '17f678d37187be0f12d67f64e40429c6' 'bacc813b48bafcc6fe906e5969930501' '8b0298f70f97cc1dc2a58b9a73c64bd3' + '911b0fbc8d9178dac1a193346c9decaf' 'eb879fee9603a05d5420d4ce8ed9e450' '6782771960c495aeb597893f37d1e5ee' '84492954db16740f949d795b74383189' '02c810c2f47b7c4495fdacaf54189473' + '474d5c6883fcfffae4f199aceb3b1356' '1e2ca4dd872a50df6b70528e06df558a' '59d0602bac7e06f11abba1894acc8bb0' 'da432d68962e109e09beb2b71c8c8571' diff --git a/abs/core/LinHES-system/checkXFSfrag.sh b/abs/core/LinHES-system/checkXFSfrag.sh new file mode 100755 index 0000000..99b833c --- /dev/null +++ b/abs/core/LinHES-system/checkXFSfrag.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Bash script by Gene Alexander (http://www.eracc.com/contact) +# of ERA Computers & Consulting (www.eracc.com, blog.eracc.com, shopping.eracc.com) +# Written using vim, the BEST plain text file editor in all of Creation. +# +# Teach yourself bash scripting: http://tldp.org/LDP/abs/html/index.html +# +# Purpose: To check fragmentation on XFS with xfs_db and run xfs_fsr on XFS mount points that +# are above a specific fragmentation threshold. +# +# What is xfs_db? Use 'man xfs_db' to find out. +# What is xfs_fsr? Use 'man xfs_fsr' to find out. +# +# Any busy files, such as open logs on /var/log, will be skipped. To defragment logs one should +# wrap this script with another script to stop and restart logging. Or, even better, write +# one's own script just for defragmentation of the logs. +# +# Warranty: NONE. Use at your own discretion and be aware that data loss is on your head if +# you choose to use this script. +# +# License: GPL 2.0 http://www.gnu.org/licenses/gpl-2.0.html +# +# Suggested Usage: crontab file for root +# 0 0 * * * /root/bin/chkxfsfrag # Run at midnight +# +# Original Release: 2011 December 15 (Merry Christmas!) +# 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. +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" ] + 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}\t$percent2 is not above fragmentation threshold of $pctmax." + fi +done +exit 0 diff --git a/abs/core/LinHES-system/xfs_defrag b/abs/core/LinHES-system/xfs_defrag new file mode 100755 index 0000000..4d35507 --- /dev/null +++ b/abs/core/LinHES-system/xfs_defrag @@ -0,0 +1,3 @@ +#!/bin/bash +#. /etc/profile +/usr/LH/bin/checkXFSfrag.sh > /var/log/xfs_defrag.log -- cgit v0.12