UNIX Hints & Hacks |
|||||||||||||||||||||||||||||||||||||
Chapter 4: System Monitoring |
|
||||||||||||||||||||||||||||||||||||
|
When disk space is at a minimum, quickly finding what is taking up the most disk space is a necessity.
Flavors: AT&T, BSD
Shells: All
Syntax:
du -s [dirname|filename] sort -rn
There are many areas of a system in which you want to get a disk usage report with the du command. Use this command in conjunction with sort so a completed listing of the offenders can be listed in reverse numerical order. This shows the highest users first.
# du -s * | sort -rn
Over a period of time, log files grow, users never clean up their files, spooling directories fill up, and system files and process occasionally go crazy and fill up a disk. Some really good areas to monitor on a system disk are
Spooling directories--/var/spool
On systems where there are multiple drives and partitions, watch for the following areas:
Disk drives always eventually fill up. No company has yet designed a system with enough disk space for any one user. Admins must always check for who is hogging the all the disk space on the system.
Users sometimes ignore all requests to clean up disk space until it is discovered that they are the ones taking up all the space on the system. It generally doesn't sit very well with their co-workers. If you can take a snapshot of the disk usage and, once a week, email the top ten users hogging the disk this is generally enough to get the point across.
# du -s | sort -rn | head -10
In monitoring the disk usage with the du command, as you learned in section 4.5, "Mail a Process," you can pipe the command to mail and send off the list to everyone.
# du -s /usr/people | sort -rn | head -10 | mail -s "Disk Hogs" everyone@rocket.ugu.com
Man pages:
du, sort
World Wide Web:
ftp://ftp.unix911.com/pub/admintools/xdu ftp://ftp.unix911.com/pub/admintools/diskuse ftp://ftp.unix911.com/pub/admintools/dugraph
UNIX Hints & Hacks |
|||||||||||||||||||||||||||||||||||||
Chapter 4: System Monitoring |
|
||||||||||||||||||||||||||||||||||||
|
© Copyright Macmillan USA. All rights reserved.