File: Useful_Scripts-topsys.xml

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (121 lines) | stat: -rw-r--r-- 3,802 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?xml version='1.0'?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>


<section id="topsyssect">
<title>Tracking Most Frequently Used System Calls</title>
<indexterm>
<primary>script examples</primary>
<secondary>monitoring system calls</secondary>
</indexterm>

<indexterm>
<primary>examples of SystemTap scripts</primary>
<secondary>monitoring system calls</secondary>
</indexterm>

<indexterm>
<primary>monitoring system calls</primary>
<secondary>examples of SystemTap scripts</secondary>
</indexterm>

<!--
<indexterm>
<primary>counting function calls</primary>
<secondary>examples of SystemTap scripts</secondary>
</indexterm>
-->

<indexterm>
<primary>system calls, monitoring</primary>
<secondary>examples of SystemTap scripts</secondary>
</indexterm>

	<para>
		<xref linkend="timeouts"/> from <xref linkend="timeoutssect"/>
		helps you identify which applications
		are polling by examining a small subset of system calls (
		<command>poll</command>,
		<command>select</command>,
		<command>epoll</command>,
		<command>itimer</command>,
		<command>futex</command>,
		<command>nanosleep</command>, and
		<command>signal</command>).
		However, in some systems, an excessive number of system calls
		outside that small subset
		might be responsible for time spent in the
		kernel. If you suspect that an application is using
		system calls excessively, you need to
		identify the most frequently used system calls on the
		system. To do this, use <xref linkend="topsys"/>.
	</para>

<formalpara id="topsys">
	<title>topsys.stp</title>
<para>
<programlisting><xi:include parse="text" href="../testsuite/systemtap.examples/profiling/topsys.stp" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</para>
</formalpara>

<para>
	<xref linkend="topsys"/> lists the top 20 system calls used by the system per 5-second interval. It also lists
	how many times each system call was used during that period. Refer to <xref linkend="topsysoutput"/> for a sample output.
</para>

<indexterm>
<primary>script examples</primary>
<secondary>timer.s(), sample usage</secondary>
</indexterm>

<indexterm>
<primary>examples of SystemTap scripts</primary>
<secondary>timer.s(), sample usage</secondary>
</indexterm>

<indexterm>
<primary>timer.s(), sample usage</primary>
<secondary>examples of SystemTap scripts</secondary>
</indexterm>


<example id="topsysoutput">
	<title><xref linkend="topsys"/> Sample Output</title>
<screen>--------------------------------------------------------------
                  SYSCALL      COUNT
             gettimeofday       1857
                     read       1821
                    ioctl       1568
                     poll       1033
                    close        638
                     open        503
                   select        455
                    write        391
                   writev        335
                    futex        303
                  recvmsg        251
                   socket        137
            clock_gettime        124
           rt_sigprocmask        121
                   sendto        120
                setitimer        106
                     stat         90
                     time         81
                sigreturn         72
                    fstat         66
--------------------------------------------------------------</screen>
</example>
<!--probe kernel.function(@1) {  # probe function passed as argument from stdin
called[probefunc()] &lt;&lt;&lt; 1  # add a count efficiently
}
global called
probe end,timer.ms(30000) {
foreach (fn+ in called)  # Sort by function name
#       (fn in called-)  # Sort by call count (in decreasing order)
printf("%s %d\n", fn, @count(called[fn]))
exit()
}-->

	</section>