Updated August 20, 2004
Created October 07, 2003


Autogenerated Site Map
Search this Site!:
Search this site powered by FreeFind

#0 in the next 2 fields means no limit
REPORT_HISTORY_DAYS=8
HARD_REPORT_HISTORY=240
LOGFILE=/tmp/free.txt

#Do a df -h report to my email.  I don't care about mounted iso
# images, nor items with "Filesystems: none".
# Keep a running history that will have to be cleaned out by hand
# Can choose with the above "REPORT_HISTORY_DAYS" how I want the
# report to show; however, history will be maintained.
# I could probably just as easily add a HARD_HISTORY_DAYS limit also
# that would flush out any items older than a HARD limit so that
# it doesn't have to be manually flushed.
df -h | grep -v iso | grep -v none | awk '{system("date +\"%Y%m%d\" | tr \"\n\" \" \""); print $0}' >> $LOGFILE
if [ $HARD_REPORT_HISTORY != 0 ]; then
    # trim the log file
    HARD_LINES=`df -h | grep -v iso | grep -v none | awk '{system("date +\"%Y%m%d\" | tr \"\n\" \" \""); print $0}' | wc -l`
    HARD_REPORT_LINES_KEEP=`expr $HARD_LINES \* $HARD_REPORT_HISTORY`
    tail -n $HARD_REPORT_LINES_KEEP $LOGFILE >/tmp/free.tmp.$$
    cat /tmp/free.tmp.$$ > $LOGFILE
    rm -rf /tmp/free.tmp.$$
fi

DF_LINES=`df -h | grep -v iso | grep -v none | grep -v "^Filesystem" | wc -l`
REPORT_LINES=`expr $REPORT_HISTORY_DAYS \* $DF_LINES`

(
echo -ne "Date\t "
df -h | grep "^Filesystem"
cat $LOGFILE | grep -v "Filesystem" | if [ $REPORT_HISTORY_DAYS != 0 ]; then tail -n $REPORT_LINES; else cat -; fi | sort -k 7 -k 1 ) >/tmp/free.txt.results

cat /tmp/free.txt.results | mail -s "linuxone Report" richard.black@cpqlinux.com

And then I added the following to crontab -e:
0 0 * * * /scripts/maintenance.sh
which maintenance.sh is a script that does a various list of maintenance items for me including checking the free space.

Here is a sample report using the above defaults of 8 days.
Date	 Filesystem            Size  Used Avail Use% Mounted on
20030913 /dev/ida/c0d0p3        66G   51G   11G  82% /
20030914 /dev/ida/c0d0p3        66G   51G   11G  82% /
20030915 /dev/ida/c0d0p3        66G   51G   11G  82% /
20030916 /dev/ida/c0d0p3        66G   56G  6.8G  89% /
20030917 /dev/ida/c0d0p3        66G   57G  5.6G  91% /
20030918 /dev/ida/c0d0p3        66G   57G  5.4G  92% /
20030919 /dev/ida/c0d0p3        66G   57G  5.4G  92% /
20030920 /dev/ida/c0d0p3        66G   57G  5.4G  92% /
20030913 /dev/ida/c0d0p1        96M   15M   77M  16% /boot
20030914 /dev/ida/c0d0p1        96M   15M   77M  16% /boot
20030915 /dev/ida/c0d0p1        96M   15M   77M  16% /boot
20030916 /dev/ida/c0d0p1        96M   15M   77M  16% /boot
20030917 /dev/ida/c0d0p1        96M   15M   77M  16% /boot
20030918 /dev/ida/c0d0p1        96M   15M   77M  16% /boot
20030919 /dev/ida/c0d0p1        96M   15M   77M  16% /boot
20030920 /dev/ida/c0d0p1        96M   15M   77M  16% /boot

Search this Site!:
Search this site powered by FreeFind

Homepage: http://www.cpqlinux.com
Site Map: http://www.cpqlinux.com/sitemap.html