System View
From DTraceBook
This chapter uses DTrace for operating system analysis. It extends existing performance tools and methodology with DTrace.
Contents |
Sample One-Liners
See the DTrace book for more one-liners.
CPU
What are the top user functions running on CPU (% usr time)?
dtrace -n 'profile-997hz /arg1/ { @[execname, ufunc(arg1)] = count(); }'
What are the top 5 kernel stack traces on CPU (shows why)?
dtrace -n 'profile-997hz { @[stack()] = count(); } END { trunc(@, 5); }'
What threads are on CPU, counted by their thread name? (FreeBSD)
dtrace -n 'profile-997 { @[stringof(curthread->td_name)] = count(); }'
What system calls are being executed by the CPUs?
dtrace -n 'syscall:::entry { @[probefunc] = count(); }'
Which processes are executing the most system calls?
dtrace -n 'syscall:::entry { @[pid, execname] = count(); }'
Memory
Tracking memory page faults by process name:
dtrace -n 'vminfo:::as_fault { @mem[execname] = sum(arg0); }'
Process allocation (via malloc()) requested size distribution plot:
dtrace -n 'pid$target::malloc:entry { @ = quantize(arg0); }' -p PID
Process allocation (via malloc()) by user stack trace and total requested size:
dtrace -n 'pid$target::malloc:entry { @[ustack()] = sum(arg0); }' -p PID
I/O
Which processes are executing common I/O system calls:
dtrace -n 'syscall::*read:entry,syscall::*write:entry { @rw[execname,probefunc] = count(); }'
What is the rate of disk I/O being issued:
dtrace -n 'io:::start { @io = count(); } tick-1sec { printa("Disk I/Os per second: %@d\n", @io); trunc(@io); }'
Scripts
- brk.d
- disk_io.d
- fstop10.d
- fstop10_enhanced.d
- iotimeq.d
- kprof.d
- kprof_func.d updated
- lat.d
- mmap.d
- net.d
- nfs.d
- pf.d
- plat.d
- rq.d
- rw_bytes.d
- rwa.d
- scrwtop10.d
- sctop10.d
- sock.d
- sock_j.d
- vmtop10.d
- wrun.d
Errata
1st printing:
- p81, 3rd para: "use of the printa() function ... (line 24)": "24" should be "21"