Subscribe to our e-mail newsletters
For more info on a specific newsletter, click the title. Details will be displayed in a new window.
Application/Web Development
Computerworld Daily News (First Look and Wrap-Up)
Computerworld Blogs Newsletter
The Weekly Top 10
More E-Mail Newsletters 
Computerworld 2007Subscribe to Computerworld
40 years of the most authoritative source of news and information for IT leaders.

Track Down Your Disk Hogs

 

Sign up to receive Security Resource Alerts

April 05, 2004 (Computerworld) -- The following is excerpted from Wicked Cool Shell Scripts, published by No Starch Press, all rights reserved.


Wicked Cool Shell Scripts is "about making Unix a friendlier, more powerful, and more personal computing environment by exploiting the remarkable power and capabilities of the shell," says author Dave Taylor. "Without writing a single line of C or C++, without invoking a single compiler and loader, and without having to take any classes in program design and methodology, you [can] write dozens of wicked cool shell scripts, ranging from an interactive calculator to a set of scripts that make analyzing Apache log files a breeze."


The script below helps system administrators track down users who are exceeding their system storage limits, and will also automatically notify those users that they've maxed out their disk allocation.


Most system administrators seek the easiest way to solve a problem, and the easiest way to manage disk quotas is to extend the fquota script, Script #39, to include the ability to e-mail warnings directly to users who are consuming too much space.


The Code



#!/bin/sh

# diskhogs - Disk quota analysis tool for Unix; assumes all user
# accounts are >= UID 100. E-mails message to each violating user
# and reports a summary to the screen.

MAXDISKUSAGE=20
violators="/tmp/diskhogs0.$$"

trap "/bin/rm -f $violators" 0

for name in $(cut -d: -f1,3 /etc/passwd | awk -F: '$2 > 99 { print $1 }')
do
echo -n "$name "
# You might need to modify the following list of directories to match
# the layout of your disk. Most likely change: /Users to /home
find / /usr /var /Users -user $name -xdev -type f -ls | \
awk '{ sum += $7 } END { print sum / (1024*1024) }'

done | awk "\$2 > $MAXDISKUSAGE { print \$0 }" > $violators

if ¿ ! -s $violators Á ; then
echo "No users exceed the disk quota of ${MAXDISKUSAGE}MB"
cat $violators
exit 0
fi


while read account usage ; do


cat << EOF | fmt | mail -s "Warning: $account Exceeds Quota" $account
Your disk usage is ${usage}MB, but you have been allocated only
${MAXDISKUSAGE}MB.

Continued...
1 | 2 | NEXT  



Print this Story Send Us Feedback E-mail this Story Digg! Digg this Story Slashdot this Story
"IBM's old AS400 technology is fading fast, if product names are any indication...." Read more...
"Systems support pilot fish starts getting reports that a special Y2k tool has stopped working — in early 2008...." Read more...
Read more Development posts or See all Blogs
Microsoft promises four patches next week
Google gives away home-cooked Web application security scanner
Storm botnet stages Fourth of July attacks
More top stories...
Microsoft trumpets security additions in upcoming IE8
Apple cuts price of high-end SSD MacBook Air by $500
Ultrathin showdown: Apple MacBook Air vs. Lenovo ThinkPad X300 vs. Toshiba Portege R500
All it takes is a couple hours and about $125 to breathe new life into an old laptop. Here's how.
Is Microsoft's Golden Age over? What are Gates' most memorable quotes? Find out in Computerworld's complete coverage of the end of the Bill Gates era at Microsoft.
There are some things your CIO definitely doesn't want to hear. Also don't miss the flipside, Five things you should always tell your boss.
With its latest version, Mozilla's browser continues to raise the bar for what Web browsers should be.
Reviews, analyses, how-tos, visual tours, hot issues and predictions about Microsoft's new OS.
Four years from now, the IT field will be a vastly different place. Will you be ready?
All Zones
Application Performance Zone
Business Continuity Zone
Data Center Management Zone
Enterprise-Class Security Zone
The File Data Management Zone
Grid Computing on Windows Zone
Security Management Zone
ITIL Best Practices Zone
The SAS Zone
Storage Virtualization Zone
Business Intelligence and Analytics Zone

Ads by TechWords

See your link here
Sold on SOA

(Source: Computerworld) It's the hot technology for most large companies, but business, technical and cultural issues must be addressed for a successful SOA implementation. Get the whole story, from the big picture to the how-to-do-it details, in this Executive Bulletin. Download this Executive Bulletin (a $49.95 value) for Free, compliments of Fujitsu.
Download this executive briefing download
Driving Business Success Through Workgroup Choice and Flexibility
Download this white paper, free, compliments of Novell!
(Source: Novell) The structure of your workgroup environment plays a vital role in enabling your knowledge workers to be productive and collaborate securely. And IT choice and flexibility can mean the difference between reactive spending and proactive investment. Boost your competitive advantage with a workgroup infrastructure that lets you deliver the tools and services that are right for you. Download this white paper to learn how Novell offers a variety of solutions that give you the flexibility to address critical business initiatives and workforce productivity.
Download this white paper go
Safeguarding Critical Data
Safeguarding Critical Data
View this on demand webcast, free, compliments of IBM!
Go to the webcast 
White Papers
Read up on the latest ideas and technologies from companies that sell hardware, software and services.
Deploying Virtualized NetWare on Linux Whitepaper
Toward More Flexible, Next-Generation Collaboration Solutions
Driving Business Success Through Workgroup Choice and Flexibility
View more whitepapers