{"id":3317,"date":"2013-01-24T12:55:29","date_gmt":"2013-01-24T10:55:29","guid":{"rendered":"http:\/\/skeletor.org.ua\/?p=3317"},"modified":"2014-06-10T10:35:45","modified_gmt":"2014-06-10T07:35:45","slug":"dtrace-%d0%b8%d1%81%d1%81%d0%bb%d0%b5%d0%b4%d1%83%d0%b5%d0%bc-%d0%bd%d0%b0%d0%b3%d1%80%d1%83%d0%b7%d0%ba%d1%83","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=3317","title":{"rendered":"[Dtrace] \u0418\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443"},"content":{"rendered":"<p>\u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0438 \u0434\u043b\u044f <strong>dtrace<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 <strong>Solaris\/FreeBSD<\/strong>. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043a\u043d\u0438\u0433\u0438 \u043f\u043e <strong>dtrace<\/strong><\/p>\n<p><!--more--><\/p>\n<h2><strong><span style=\"color: #0000ff;\">CPU<\/span><\/strong><\/h2>\n<p>Which processes are on-CPU?<\/p>\n<p><code>dtrace -n 'profile-997hz { @[pid, execname] = count(); }'<\/code><\/p>\n<p>Which processes are on-CPU, running user code?<\/p>\n<p><code>dtrace -n 'profile-997hz \/arg1\/ { @[pid, execname] = count(); }'<\/code><\/p>\n<p>What are the top user functions running on-CPU (%usr time)?<\/p>\n<p><code>dtrace -n 'profile-997hz \/arg1\/ { @[execname, ufunc(arg1)] = count(); }'<\/code><\/p>\n<p>What are the top kernel functions running on-CPU (%sys time)?<\/p>\n<p><code>dtrace -n 'profile-997hz \/arg0\/ { @[func(arg0)] = count(); }'<\/code><\/p>\n<p>What are the top five kernel stack traces on the CPU (shows why)?<\/p>\n<p><code>dtrace -n 'profile-997hz { @[stack()] = count(); } END { trunc(@, 5); }'<\/code><\/p>\n<p>What are the top five user stack traces on the CPU (shows why)?<\/p>\n<p><code>dtrace -n 'profile-997hz { @[ustack()] = count(); } END { trunc(@, 5); }'<\/code><\/p>\n<p>What threads are on-CPU, counted by their thread name (FreeBSD)?<\/p>\n<p><code>dtrace -n 'profile-997 { @[stringof(curthread-&gt;td_name)] = count(); }'<\/code><\/p>\n<p>What system calls are being executed by the CPUs?<\/p>\n<p><code>dtrace -n 'syscall:::entry { @[probefunc] = count(); }'<\/code><\/p>\n<p>Which processes are executing the most system calls?<\/p>\n<p><code>dtrace -n 'syscall:::entry { @[pid, execname] = count(); }'<\/code><\/p>\n<p>What system calls are a given process name executing (for example, firefox-bin)?<\/p>\n<p><code>dtrace -n 'syscall:::entry \/execname == \"firefox-bin\"\/ { @[probefunc] = count(); }'<\/code><\/p>\n<h2><strong><span style=\"color: #0000ff;\">Memory<\/span><\/strong><\/h2>\n<p>Tracking memory page faults by process name:<\/p>\n<p><code>dtrace -n 'vminfo:::as_fault { @mem[execname] = sum(arg0); }'<\/code><\/p>\n<p>Tracking pages paged in by process name:<\/p>\n<p><code>dtrace -n 'vminfo:::pgpgin { @pg[execname] = sum(arg0); }'<\/code><\/p>\n<p>Tracking pages paged out by process name:<\/p>\n<p><code>dtrace -n 'vminfo:::pgpgout { @pg[execname] = sum(arg0); }'<\/code><\/p>\n<p>Tracking process user stack sizes:<\/p>\n<p><code>dtrace -n 'sched:::on-cpu { @[execname] = max(curthread-&gt;t_procp-&gt;p_stksize);}'<\/code><\/p>\n<p>Tracking which processes are growing their address space heap segment:<\/p>\n<p><code>dtrace -n 'fbt::brk:entry { @mem[execname] = count(); }'<\/code><\/p>\n<p>Process allocation (via malloc()) counting requested size:<\/p>\n<p><code>dtrace -n 'pid$target::malloc:entry { @[arg0] = count(); }' -p PID<\/code><\/p>\n<p>Process allocation (via malloc()) requested size distribution plot:<\/p>\n<p><code>dtrace -n 'pid$target::malloc:entry { @ = quantize(arg0); }' -p PID<\/code><\/p>\n<p>Process allocation (via malloc()) by user stack trace and total requested size:<\/p>\n<p><code>dtrace -n 'pid$target::malloc:entry { @[ustack()] = sum(arg0); }' -p PID<\/code><\/p>\n<p>Process allocation (via malloc()) by Java stack trace and total requested size:<\/p>\n<p><code>dtrace -n 'pid$target::malloc:entry { @[jstack()] = sum(arg0); }' -p PID<\/code><\/p>\n<h2><strong><span style=\"color: #0000ff;\">I\/O<\/span><\/strong><\/h2>\n<p>Which processes are executing common I\/O system calls?<\/p>\n<p><code>dtrace -n 'syscall::*read:entry,syscall::*write:entry { @rw[execname,probefunc] =\u00a0count(); }'<\/code><\/p>\n<p>Which file system types are targeted for reads and writes?<\/p>\n<p><code>dtrace -n 'syscall::*read:entry,syscall::*write:entry { @fs[execname, probefunc,<br \/>\nfds[arg0].fi_fs] = count(); }'<\/code><\/p>\n<p>Which files are being read, and by which processes?<\/p>\n<p><code>dtrace -n 'syscall::*read:entry { @f[execname, fds[arg0].fi_pathname] = count(); }'<\/code><\/p>\n<p>Which files are being written, and by which processes?<\/p>\n<p><code>dtrace -n 'syscall::*write:entry { @f[execname, fds[arg0].fi_pathname] = count(); }'<\/code><\/p>\n<p>Which processes are generating network I\/O (Solaris)?<\/p>\n<p><code>dtrace -n 'fbt:sockfs::entry { @[execname, probefunc] = count(); }'<\/code><\/p>\n<p>Which processes are generating file system I\/O (Solaris)?<\/p>\n<p><code>dtrace -n 'fsinfo::: { @fs[execname, probefunc] = count(); }'<\/code><\/p>\n<p>What is the rate of disk I\/O being issued?<\/p>\n<p><code>dtrace -n 'io:::start { @io = count(); } tick-1sec { printa(\"Disk I\/Os per second: %@d<br \/>\n\\n\", @io); trunc(@io); }'<\/code><\/p>\n<p>\u0410 \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<a style=\"color: #000000;\" rel=\"nofollow\" href=\"http:\/\/www.brendangregg.com\/DTrace\/iotop\">iotop<\/a>,\u00a0<a style=\"color: #000000;\" rel=\"nofollow\" href=\"http:\/\/lserinol.googlepages.com\/process_io_top\">process_io_top<\/a>,\u00a0<a style=\"color: #000000;\" rel=\"nofollow\" href=\"http:\/\/www.brendangregg.com\/DTrace\/iosnoop\">iosnoop<\/a>\u00a0\u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430\u00a0<a style=\"color: #000000;\" rel=\"nofollow\" href=\"http:\/\/www.brendangregg.com\/dtracetoolkit.html\">DTraceToolkit<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0438 \u0434\u043b\u044f dtrace, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 Solaris\/FreeBSD. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043a\u043d\u0438\u0433\u0438 \u043f\u043e dtrace<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,24],"tags":[],"class_list":["post-3317","post","type-post","status-publish","format-standard","hentry","category-freebsd","category-solaris"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/3317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3317"}],"version-history":[{"count":7,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/3317\/revisions"}],"predecessor-version":[{"id":4278,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/3317\/revisions\/4278"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}