Debian Codegraph @

doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotop.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
3 ]>
4
5 <section id="iotopsect">
6 <title>Periodically Print I/O Activity</title>
7 <indexterm>
8 <primary>script examples</primary>
9 <secondary>monitoring I/O activity</secondary>
10 </indexterm>
11
12 <indexterm>
13 <primary>examples of SystemTap scripts</primary>
14 <secondary>monitoring I/O activity</secondary>
15 </indexterm>
16
17 <indexterm>
18 <primary>monitoring I/O activity</primary>
19 <secondary>examples of SystemTap scripts</secondary>
20 </indexterm>
21
22 <indexterm>
23 <primary>I/O activity, monitoring</primary>
24 <secondary>examples of SystemTap scripts</secondary>
25 </indexterm>
26
27 <indexterm>
28 <primary>printing I/O activity (periodically)</primary>
29 <secondary>examples of SystemTap scripts</secondary>
30 </indexterm>
31
32 <para>This section describes how to monitor I/O activity on the system.</para>
33
34 <formalpara id="iotop">
35 <title>iotop.stp</title>
36 <para>
37 <programlisting><xi:include parse="text" href="../testsuite/systemtap.examples/io/iotop.stp" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
38 </para>
39 </formalpara>
40
41 <!-- <remark>what does $count do, specifically?</remark> -->
42
43 <para><xref linkend="iotop"/> prints out the top ten executables generating I/O traffic every 5-second interval, in descending order. Its output contains the process name and the amount of data read or written by the process, in KB. For example:</para>
44
45 <example id="iotopoutput">
46 <title><xref linkend="iotop"/> Sample Output</title>
47 <screen>[...]
48 Process KB Read KB Written
49 Xorg 50287 0
50 staprun 3328 0
51 multiload-apple 3039 23
52 sshd 208 1
53 floaters 14 62
54 NetworkManager 15 0
55 gnome-vfs-daemo 8 0
56 cupsd 3 3
57 sendmail 4 0
58 mixer_applet2 3 0
59
60 Process KB Read KB Written
61 Xorg 51886 0
62 staprun 3328 0
63 multiload-apple 3039 23
64 sshd 1344 4
65 snmpd 90 0
66 floaters 15 66
67 NetworkManager 23 0
68 irqbalance 16 0
69 pam_timestamp_c 9 0
70 sendmail 4 0</screen>
71 </example>
72
73 <para><xref linkend="iotopoutput"/> displays top I/O writes and reads within a random 10-second interval. Note that <xref linkend="iotop"/> also detects I/O resulting from SystemTap activity &mdash; <xref linkend="iotopoutput"/> displays reads done by <command>staprun</command>.</para>
74 <!--
75 global reads, writes, total_io
76
77 probe kernel.function("vfs_read") {
78 reads[execname()] += $count
79 }
80
81 probe kernel.function("vfs_write") {
82 writes[execname()] += $count
83 }
84
85 # print top 10 IO processes every 5 seconds
86 probe timer.s(5) {
87 foreach (name in writes)
88 total_io[name] += writes[name]
89 foreach (name in reads)
90 total_io[name] += reads[name]
91 printf ("%16s\t%10s\t%10s\n", "Process", "KB Read", "KB Written")
92 foreach (name in total_io- limit 10)
93 printf("%16s\t%10d\t%10d\n", name,
94 reads[name]/1024, writes[name]/1024)
95 delete reads
96 delete writes
97 delete total_io
98 print("\n")
99 }
100 -->
101
102 </section>