UNIX Hints & Hacks

ContentsIndex

Chapter 4: System Monitoring

 

Previous ChapterNext Chapter

Sections in this Chapter:

   

4.1 Monitoring at Boot Time

 

4.5 Mail a Process

 

4.9 Monitoring with ping

 

4.2 Starting with a Fresh Install

 

4.6 Watching the Disk Space

 

4.10 Monitoring Core Files

 

 

4.3 Monitor with tail

 

4.7 Find the Disk Hog

 

4.11 Monitoring Crash Files

 

 

4.4 Cut the Log in Half

 

4.8 Watching by grepping the Difference

 

4.12 Remember Daylight Savings Time

 

 

 

4.7 Find the Disk Hog

4.7.1 Description

4.7.1 Description

When disk space is at a minimum, quickly finding what is taking up the most disk space is a necessity.

Example One: Do It with du

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

On systems where there are multiple drives and partitions, watch for the following areas:

Reason

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.

Real World Experience

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

Other Resources

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

ContentsIndex

Chapter 4: System Monitoring

 

Previous ChapterNext Chapter

Sections in this Chapter:

   

4.1 Monitoring at Boot Time

 

4.5 Mail a Process

 

4.9 Monitoring with ping

 

4.2 Starting with a Fresh Install

 

4.6 Watching the Disk Space

 

4.10 Monitoring Core Files

 

 

4.3 Monitor with tail

 

4.7 Find the Disk Hog

 

4.11 Monitoring Crash Files

 

 

4.4 Cut the Log in Half

 

4.8 Watching by grepping the Difference

 

4.12 Remember Daylight Savings Time

 

 

 

© Copyright Macmillan USA. All rights reserved.