{"id":2642,"date":"2012-05-10T17:03:50","date_gmt":"2012-05-10T14:03:50","guid":{"rendered":"http:\/\/skeletor.org.ua\/?p=2642"},"modified":"2024-09-20T10:36:09","modified_gmt":"2024-09-20T07:36:09","slug":"dtrace-%d0%bd%d0%b5%d0%ba%d0%be%d1%82%d0%be%d1%80%d1%8b%d0%b5-%d0%bf%d1%80%d0%b8%d0%bc%d0%b5%d1%80%d1%8b-%d0%bf%d1%80%d0%b8%d0%bc%d0%b5%d0%bd%d0%b5%d0%bd%d0%b8%d1%8f","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=2642","title":{"rendered":"Dtrace: \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f"},"content":{"rendered":"<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 <strong>Solaris<\/strong>, \u043d\u043e \u0438 \u043d\u0430 <strong>FreeBSD<\/strong><\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0426\u041f\u0423 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 (\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430)<\/p>\n<p><code>dtrace -n 'syscall:::entry { @num[execname] = count(); }'<br \/>\ndtrace -n 'syscall:::entry { @num[pid,execname] = count(); }'<\/code><\/p>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (<strong>syscalls<\/strong>)<\/p>\n<p><code>dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'<\/code><\/p>\n<p><!--more--><\/p>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (<strong>syscalls<\/strong>) \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>MyApp<\/strong> (\u0432\u044b\u0432\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b <strong>dtracefile<\/strong>)<\/p>\n<p><code>dtrace -n 'syscall::MyApp:entry {@[ustack()] = count()}' &gt; dtracefile<\/code><\/p>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0430\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043b\u044f MyApp<\/p>\n<p><code>dtrace -n 'syscall::MyApp:entry {@[pid, tid] = count()}'<\/code><\/p>\n<p>\u0424\u0430\u0439\u043b\u044b, \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 (\u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b)<\/p>\n<p><code>dtrace -n 'syscall::open*:entry { printf(\"%s %s\",execname,copyinstr(arg0)); }'<\/code><\/p>\n<p>\u041d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438<\/p>\n<p><code>dtrace -n 'proc:::exec-success { trace(curpsinfo-&gt;pr_psargs); }'<\/code><\/p>\n<p>\u0421\u0442\u0435\u043a \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e <strong>pid&#8217;a<\/strong> \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>close<\/strong>:<\/p>\n<p><code>dtrace -n syscall::close:return'\/pid == 26651\/ { \u00a0ustack(); }'<\/code><\/p>\n<p>\u041f\u043e\u0434\u0447\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<p><code>dtrace -n 'syscall::mmap:entry { @ = sum(arg1); }' -c \"bash test.sh\"<\/code><\/p>\n<p>\u0421\u0435\u0442\u0435\u0432\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f<\/p>\n<p><code>#!\/usr\/sbin\/dtrace -qs<br \/>\nsyscall::connect:entry<br \/>\n{<br \/>\nsocks\u00a0=\u00a0(struct\u00a0sockaddr*)\u00a0copyin(arg1,\u00a0arg2);<br \/>\nhport\u00a0=\u00a0(uint_t)\u00a0socks-&gt;sa_data[0];<br \/>\nlport\u00a0=\u00a0(uint_t)\u00a0socks-&gt;sa_data[1];<br \/>\nhport\u00a0&lt;&lt;=\u00a08;<br \/>\nport\u00a0=\u00a0hport\u00a0+\u00a0lport;<br \/>\nprintf(\"%s: %d.%d.%d.%d:%d\\n\",\u00a0execname,\u00a0socks-&gt;sa_data[2],\u00a0socks-&gt;sa_data[3],\u00a0socks-&gt;sa_data[4],\u00a0socks-&gt;sa_data[5],\u00a0port);<br \/>\n}<\/code><\/p>\n<p><strong><span style=\"color: #ff0000;\">\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/span><\/strong><\/p>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438<\/p>\n<p>http:\/\/www.solarisinternals.com\/wiki\/index.php\/DTrace_Topics_One_Liners<br \/>\nhttp:\/\/www.brendangregg.com\/DTrace\/dtrace_oneliners.txt<br \/>\nhttp:\/\/www.brendangregg.com\/dtrace.html#Scripts<br \/>\nhttps:\/\/freebsdfoundation.org\/wp-content\/uploads\/2023\/01\/stolfa_dtrace.pdf<br \/>\nhttps:\/\/freebsdfoundation.org\/wp-content\/uploads\/2014\/05\/DTrace.pdf<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"9TuafR7wjx\"><p><a href=\"https:\/\/klarasystems.com\/articles\/freebsd-history-understanding-the-origins-of-dtrace\/\">FreeBSD History &#8211; Understanding the Origins of DTrace<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;FreeBSD History &#8211; Understanding the Origins of DTrace&#8221; &#8212; Klara Systems\" src=\"https:\/\/klarasystems.com\/articles\/freebsd-history-understanding-the-origins-of-dtrace\/embed\/#?secret=L9gl5cSWLU#?secret=9TuafR7wjx\" data-secret=\"9TuafR7wjx\" width=\"580\" height=\"327\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u0410 <a href=\"https:\/\/www.joyent.com\/events\/2016\/dtrace-conf\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0432\u0438\u0434\u0435\u043e \u0441 <strong>dtrace.conf<\/strong> <strong>2016<\/strong><\/p>\n<p><a href=\"https:\/\/axcient.com\/blog\/using-dtrace-to-find-block-sizes-of-zfs-nfs-and-iscsi\/\">\u0418\u0449\u0435\u043c<\/a> block size \u0432 ZFS\/NFS\/iSCSI<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 Solaris, \u043d\u043e \u0438 \u043d\u0430 FreeBSD \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0426\u041f\u0423 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 (\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430) dtrace -n &#8216;syscall:::entry { @num[execname] = count(); }&#8217; dtrace -n &#8216;syscall:::entry { @num[pid,execname] = count(); }&#8217; \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (syscalls) dtrace -n &#8216;syscall:::entry { @num[probefunc] = count(); }&#8217;<\/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-2642","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\/2642","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=2642"}],"version-history":[{"count":20,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/2642\/revisions"}],"predecessor-version":[{"id":6480,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/2642\/revisions\/6480"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}