I know maybe not the best forum to ask
but I know most people here, rather than asking in another place and not getting any answers
anyway, I have this:
Code:
#!/bin/sh
echo "To: [email protected]
Subject: JG Server - Weekly Checkup
***** JG Server - Weekly Checkup *****
" > /tmp/jg_weekly.txt
uptime >> /tmp/jg_weekly.txt
echo -n "
Hostname: " >> /tmp/jg_weekly.txt
hostname >> /tmp/jg_weekly.txt
echo -n "Hostname (FQDN): " >> /tmp/jg_weekly.txt
hostname -f >> /tmp/jg_weekly.txt
echo "" >> /tmp/jg_weekly.txt
df -h --type=ext3 >> /tmp/jg_weekly.txt
echo "
Location Size Mounted on" >> /tmp/jg_weekly.txt
echo -n "E: Drive: " >> /tmp/jg_weekly.txt
du -hs /media/data/data >> /tmp/jg_weekly.txt
echo -n " *.doc = " >> /tmp/jg_weekly.txt
find /media/data/data -type f -iname '*.doc' -exec du -k {} \; | awk '{sum+=$1} END {split("K,M,G,T", Units, ",");u = 1;while (sum >= 1024){sum = sum / 1024;u += 1}sum = sprintf("%.1f%s", sum, Units[u]);print sum;}' >> /tmp/jg_weekly.txt
echo -n " *.xls = " >> /tmp/jg_weekly.txt
find /media/data/data -type f -iname '*.xls' -exec du -k {} \; | awk '{sum+=$1} END {split("K,M,G,T", Units, ",");u = 1;while (sum >= 1024){sum = sum / 1024;u += 1}sum = sprintf("%.1f%s", sum, Units[u]);print sum;}' >> /tmp/jg_weekly.txt
echo -n " *.jpg = " >> /tmp/jg_weekly.txt
find /media/data/data -type f -iname '*.jpg' -exec du -k {} \; | awk '{sum+=$1} END {split("K,M,G,T", Units, ",");u = 1;while (sum >= 1024){sum = sum / 1024;u += 1}sum = sprintf("%.1f%s", sum, Units[u]);print sum;}' >> /tmp/jg_weekly.txt
echo -n " *.dwg = " >> /tmp/jg_weekly.txt
find /media/data/data -type f -iname '*.dwg' -exec du -k {} \; | awk '{sum+=$1} END {split("K,M,G,T", Units, ",");u = 1;while (sum >= 1024){sum = sum / 1024;u += 1}sum = sprintf("%.1f%s", sum, Units[u]);print sum;}' >> /tmp/jg_weekly.txt
echo -n " *.pdf = " >> /tmp/jg_weekly.txt
find /media/data/data -type f -iname '*.pdf' -exec du -k {} \; | awk '{sum+=$1} END {split("K,M,G,T", Units, ",");u = 1;while (sum >= 1024){sum = sum / 1024;u += 1}sum = sprintf("%.1f%s", sum, Units[u]);print sum;}' >> /tmp/jg_weekly.txt
echo -n "Mailboxes: " >> /tmp/jg_weekly.txt
du -hs /var/mail/virtual >> /tmp/jg_weekly.txt
echo -n "Web Pages: " >> /tmp/jg_weekly.txt
du -hs /var/www >> /tmp/jg_weekly.txt
cat /tmp/jg_weekly.txt | /usr/sbin/sendmail [email protected]
rm /tmp/jg_weekly.txt
which outputs:
Code:
***** JG Server - Weekly Checkup *****
16:01:59 up 7 days, 22:13, 1 user, load average: 0.93, 1.02, 0.81
Hostname: server1
Hostname (FQDN): server1.blah.co.uk
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 3.1G 14G 19% /
/dev/sdb1 57G 29G 26G 53% /media/data
Location Size Mounted on
E: Drive: 25G /media/data/data
*.doc = 2.5G
*.xls = 24.9M
*.jpg = 16.2G
*.dwg = 688.6M
*.pdf = 1.1G
Mailboxes: 3.1G /var/mail/virtual
Web Pages: 119M /var/www
and the thing takes 10+ mins to run
and while it's only going to be run once a week (midnight on sundays), I'd like to speed it up if I can
I know I'm horribly inefficient calculating the different file type totals
does anyone have any advice to speed it up?
Thanks
Bookmarks