|< Day Day Up >|
17.1. Diagnostic Utilities
Mac OS X includes many diagnostic utilities that you can use to monitor your system and investigate problems.
The top utility displays memory statistics and a list of running processes. It is divided into two regions: the top region contains memory statistics, and the bottom region contains details on each process.
You can specify the number of processes to show by supplying a numeric argument. By default, top refreshes its display every second and sorts the list of processes by process ID (PID) in descending order. You can set top to sort by CPU utilization with -u, and you can specify the refresh delay with the -s option. Figure 17-1 shows the output of top -u 16 (if you wanted to refresh the output every 3 seconds, you could run top -s3 -u 16).
Table 17-1 describes the values shown in the top region, and Table 17-2 describes the columns in the bottom region (process information).
Figure 17-1. Sample output from top
The fs_usage utility shows a continuous display of filesystem-related system calls and page faults. You must run fs_usage as root. By default, it ignores anything originating from fs_usage, Terminal, telnetd, sshd, rlogind, tcsh, csh, or sh.
Figure 17-2 shows the output of fs_usage monitoring the startup of a new bash shell, and displaying the following columns:
latency measures the number of context switches and interrupts, and reports on the resulting delays, updating the display once per second. This utility must be run as root. Example 17-1 shows a portion of its output.
Figure 17-2. Monitoring filesystem operations with fs_usage
Example 17-1. Partial output from latency
Sat Apr 2 11:07:35 0:04:18 SCHEDULER INTERRUPTS --------------------------------------------- total_samples 209208 336535 delays < 10 usecs 183575 332310 delays < 20 usecs 11999 3197 delays < 30 usecs 2416 836 delays < 40 usecs 1289 158 delays < 50 usecs 624 25 delays < 60 usecs 492 6 delays < 70 usecs 323 2 delays < 80 usecs 329 1 delays < 90 usecs 280 0 delays < 100 usecs 235 0 total < 100 usecs 201562 336535
The SCHEDULER column lists the number of context switches and the INTERRUPTS column lists the number of interrupts.
The sc_usage utility samples system calls and page faults, then displays them onscreen. sc_usage must be run by root or by someone with superuser privileges. The display is updated once per second. You must specify a PID, a command name, or a program to execute with the -E switch. For example, to monitor the Finder, use sudo sc_usage Finder. Figure 17-3 shows the output of running sc_usage on the Finder. Table 17-3 explains sc_usage's output.
Figure 17-3. sc_usage monitoring the Finder
The vm_stat utility displays virtual memory statistics. Unlike implementations of vm_stat in other Unix systems, it does not default to continuous display. Instead, it displays accumulated statistics.
To obtain a continuous display, specify an interval argument (in seconds), as in vm_stat 1. Figure 17-4 shows the output of vm_stat with no arguments.
Figure 17-4. vm_stat displaying accumulated statistics
Figure 17-5 shows the output of vm_stat 1. Table 17-4 describes the information that vm_stat displays (the item numbers correspond to the callouts in both figures).
Figure 17-5. vm_stat's continuous output
|< Day Day Up >|