17.2. Kernel Utilities

 < 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.

17.1.1. top

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


Table 17-1. Memory information displayed by top

Item number

Item

Description

1

Processes

Number of processes and threads. A running process is currently using CPU time, while a sleeping process is not.

2

Load Avg.

Average system load (the number of jobs vying for the CPU's attention) over the last 1, 5, and 15 minutes.

3

CPU usage

Breakdown of CPU usage, listing time spent in user mode, kernel (sys) mode, and idle time.

4

SharedLibs

Number of shared libraries in use, along with their memory utilization.

5

MemRegions

Number of Mach virtual memory regions in use, along with memory utilization details.

6

PhysMem

Physical memory utilization. Memory that is wired cannot be swapped to disk. active memory is memory that's currently being used, inactive memory is memory that Mac OS X is keeping "on deck" for processes that need it, and free memory is memory that's not being used at all.

7

VM

Virtual memory statistics, including the total amount of virtual memory allocated (the sum of the VSIZE in the process list), as well as paging activity (data paged in and out of physical memory).


Table 17-2. Process information displayed by top

Item number

Item

Description

8

PID

Process ID

9

COMMAND

Program's name

10

%CPU

Percentage of the CPU that the process is using

11

TIME

Total amount of CPU time this process has used

12

#TH

Number of threads in this process

13

#PRTS

Number of Mach ports

14

#MREGS

Number of memory registers

15

RPRVT

Resident private memory

16

RSHRD

Resident shared memory

17

RSIZE

Resident memory

18

VSIZE

Process's total address space, including shared memory


17.1.2. fs_usage

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:

  • Timestamp

  • System call

  • Filename

  • Elapsed time

  • Name of the process

17.1.3. latency

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.

17.1.4. sc_usage

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


Table 17-3. Information displayed by sc_usage

Item number

Row

Description

1

TYPE

System call type

2

NUMBER

System call count

3

CPU_TIME

Processor time used by the system call

4

WAIT_TIME

Absolute time that the process spent waiting

5

CURRENT_TYPE

Current system call type

6

LAST_PATHNAME_WAITED_FOR

Last file or directory that resulted in a blocked I/O operation during a system call

7

CUR_WAIT_TIME

Cumulative time spent blocked

8

THRD#

Thread ID

9

PRI

Scheduling priority


17.1.5. vm_stat

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


Table 17-4. Information displayed by vm_stat

Item number

Accumulated mode

Continuous mode

Description

1

Pages free

free

Total free pages

2

Pages active

active

Total pages in use that can be paged out

3

Pages inactive

inac

Total inactive pages

4

Pages wired down

wire

Total pages wired into memory (cannot be paged out)

5

translation Faults

faults

Number of times vm_fault has been called

6

Pages copy-on-write

copy

Number of faults that resulted in a page being copied

7

Pages zero filled

zerofill

Number of pages that have been zero-filled

8

Pages Reactivated

reactive

Number of pages reclassified from inactive to active

9

Pageins

pagein

Number of pages moved into physical memory

10

Pageouts

pageout

Number of pages moved out of physical memory


     < Day Day Up > 


    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net