1 <?xml version='
1.0'
?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
8 This file is part of systemd.
10 Copyright 2012 Lennart Poettering
13 <refentry id=
"systemd-cgtop"
14 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
17 <title>systemd-cgtop
</title>
18 <productname>systemd
</productname>
22 <contrib>Developer
</contrib>
23 <firstname>Lennart
</firstname>
24 <surname>Poettering
</surname>
25 <email>lennart@poettering.net
</email>
31 <refentrytitle>systemd-cgtop
</refentrytitle>
32 <manvolnum>1</manvolnum>
36 <refname>systemd-cgtop
</refname>
37 <refpurpose>Show top control groups by their resource usage
</refpurpose>
42 <command>systemd-cgtop
</command>
43 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
44 <arg choice=
"opt">GROUP
</arg>
49 <title>Description
</title>
51 <para><command>systemd-cgtop
</command> shows the top control
52 groups of the local Linux control group hierarchy, ordered by
53 their CPU, memory, or disk I/O load. The display is refreshed in
54 regular intervals (by default every
1s), similar in style to
55 <citerefentry project='man-pages'
><refentrytitle>top
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
56 If a control group path is specified, shows only the services of
57 the specified control group.
</para>
59 <para>If
<command>systemd-cgtop
</command> is not connected to a
60 tty, no column headers are printed and the default is to only run
61 one iteration. The
<varname>--iterations=
</varname> argument, if
62 given, is honored. This mode is suitable for scripting.
</para>
64 <para>Resource usage is only accounted for control groups in the
65 relevant hierarchy, i.e. CPU usage is only accounted for control
66 groups in the
<literal>cpuacct
</literal> hierarchy, memory usage
67 only for those in
<literal>memory
</literal> and disk I/O usage for
68 those in
<literal>blkio
</literal>. If resource monitoring for
69 these resources is required, it is recommended to add the
70 <varname>CPUAccounting=
1</varname>,
71 <varname>MemoryAccounting=
1</varname> and
72 <varname>BlockIOAccounting=
1</varname> settings in the unit files
74 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
77 <para>The CPU load value can be between
0 and
100 times the number of
78 processors the system has. For example, if the system has
8 processors,
79 the CPU load value is going to be between
0% and
800%. The number of
80 processors can be found in
<literal>/proc/cpuinfo
</literal>.
</para>
82 <para>To emphasize this: unless
83 <literal>CPUAccounting=
1</literal>,
84 <literal>MemoryAccounting=
1</literal> and
85 <literal>BlockIOAccounting=
1</literal> are enabled for the
86 services in question, no resource accounting will be available for
87 system services and the data shown by
88 <command>systemd-cgtop
</command> will be incomplete.
</para>
92 <title>Options
</title>
94 <para>The following options are understood:
</para>
98 <term><option>-p
</option></term>
99 <term><option>--order=path
</option></term>
101 <listitem><para>Order by control group
102 path name.
</para></listitem>
106 <term><option>-t
</option></term>
107 <term><option>--order=tasks
</option></term>
109 <listitem><para>Order by number of tasks/processes in the control group.
</para></listitem>
113 <term><option>-c
</option></term>
114 <term><option>--order=cpu
</option></term>
116 <listitem><para>Order by CPU load.
</para></listitem>
120 <term><option>-m
</option></term>
121 <term><option>--order=memory
</option></term>
123 <listitem><para>Order by memory usage.
</para></listitem>
127 <term><option>-i
</option></term>
128 <term><option>--order=io
</option></term>
130 <listitem><para>Order by disk I/O load.
</para></listitem>
134 <term><option>-b
</option></term>
135 <term><option>--batch
</option></term>
137 <listitem><para>Run in
"batch" mode: do not accept input and
138 run until the iteration limit set with
139 <option>--iterations=
</option> is exhausted or until killed.
140 This mode could be useful for sending output from
141 <command>systemd-cgtop
</command> to other programs or to a
142 file.
</para></listitem>
146 <term><option>-r
</option></term>
147 <term><option>--raw
</option></term>
149 <listitem><para>Format byte counts (as in memory usage and I/O metrics)
150 with raw numeric values rather than human-readable
151 numbers.
</para></listitem>
155 <term><option>--cpu=percentage
</option></term>
156 <term><option>--cpu=time
</option></term>
158 <listitem><para>Controls whether the CPU usage is shown as
159 percentage or time. By default, the CPU usage is shown as
160 percentage. This setting may also be toggled at runtime by
161 pressing the
<keycap>%
</keycap> key.
</para></listitem>
165 <term><option>-P
</option></term>
167 <listitem><para>Count only userspace processes instead of all
168 tasks. By default, all tasks are counted: each kernel thread
169 and each userspace thread individually. With this setting,
170 kernel threads are excluded from the counting and each
171 userspace process only counts as one, regardless how many
172 threads it consists of. This setting may also be toggled at
173 runtime by pressing the
<keycap>P
</keycap> key. This option
174 may not be combined with
175 <option>-k
</option>.
</para></listitem>
179 <term><option>-k
</option></term>
181 <listitem><para>Count only userspace processes and kernel
182 threads instead of all tasks. By default, all tasks are
183 counted: each kernel thread and each userspace thread
184 individually. With this setting, kernel threads are included in
185 the counting and each userspace process only counts as on one,
186 regardless how many threads it consists of. This setting may
187 also be toggled at runtime by pressing the
<keycap>k
</keycap>
188 key. This option may not be combined with
189 <option>-P
</option>.
</para></listitem>
193 <term><option>--recursive=
</option></term>
195 <listitem><para>Controls whether the number of processes shown
196 for a control group shall include all processes that are
197 contained in any of the child control groups as well. Takes a
198 boolean argument, which defaults to
<literal>yes
</literal>. If
199 enabled, the processes in child control groups are included, if
200 disabled, only the processes in the control group itself are
201 counted. This setting may also be toggled at runtime by
202 pressing the
<keycap>r
</keycap> key. Note that this setting
203 only applies to process counting, i.e. when the
204 <option>-P
</option> or
<option>-k
</option> options are
205 used. It has not effect if all tasks are counted, in which
206 case the counting is always recursive.
</para></listitem>
210 <term><option>-n
</option></term>
211 <term><option>--iterations=
</option></term>
213 <listitem><para>Perform only this many iterations. A value of
214 0 indicates that the program should run
215 indefinitely.
</para></listitem>
219 <term><option>-
1</option></term>
221 <listitem><para>A shortcut for
<option>--iterations=
1</option>.
</para></listitem>
225 <term><option>-d
</option></term>
226 <term><option>--delay=
</option></term>
228 <listitem><para>Specify refresh delay in seconds (or if one of
229 <literal>ms
</literal>,
<literal>us
</literal>,
230 <literal>min
</literal> is specified as unit in this time
231 unit). This setting may also be increased and decreased at
232 runtime by pressing the
<keycap>+
</keycap> and
233 <keycap>-
</keycap> keys.
</para></listitem>
237 <term><option>--depth=
</option></term>
239 <listitem><para>Maximum control group tree traversal depth.
240 Specifies how deep
<command>systemd-cgtop
</command> shall
241 traverse the control group hierarchies. If
0 is specified,
242 only the root group is monitored. For
1, only the first level
243 of control groups is monitored, and so on. Defaults to
248 <term><option>-M
<replaceable>MACHINE
</replaceable></option></term>
249 <term><option>--machine=
<replaceable>MACHINE
</replaceable></option></term>
251 <listitem><para>Limit control groups shown to the part
252 corresponding to the container
253 <replaceable>MACHINE
</replaceable>.
254 This option may not be used when a control group path is specified.
</para></listitem>
257 <xi:include href=
"standard-options.xml" xpointer=
"help" />
258 <xi:include href=
"standard-options.xml" xpointer=
"version" />
266 <para><command>systemd-cgtop
</command> is an interactive tool and
267 may be controlled via user input using the following keys:
</para>
271 <term><keycap>h
</keycap></term>
273 <listitem><para>Shows a short help text.
</para></listitem>
277 <term><keycap function=
"space"/></term>
279 <listitem><para>Immediately refresh output.
</para></listitem>
283 <term><keycap>q
</keycap></term>
285 <listitem><para>Terminate the program.
</para></listitem>
289 <term><keycap>p
</keycap></term>
290 <term><keycap>t
</keycap></term>
291 <term><keycap>c
</keycap></term>
292 <term><keycap>m
</keycap></term>
293 <term><keycap>i
</keycap></term>
295 <listitem><para>Sort the control groups by path, number of
296 tasks, CPU load, memory usage, or I/O load, respectively. This
297 setting may also be controlled using the
298 <option>--order=
</option> command line
299 switch.
</para></listitem>
303 <term><keycap>%
</keycap></term>
305 <listitem><para>Toggle between showing CPU time as time or
306 percentage. This setting may also be controlled using the
307 <option>--cpu=
</option> command line switch.
</para></listitem>
311 <term><keycap>+
</keycap></term>
312 <term><keycap>-
</keycap></term>
314 <listitem><para>Increase or decrease refresh delay,
315 respectively. This setting may also be controlled using the
316 <option>--delay=
</option> command line
317 switch.
</para></listitem>
321 <term><keycap>P
</keycap></term>
323 <listitem><para>Toggle between counting all tasks, or only
324 userspace processes. This setting may also be controlled using
325 the
<option>-P
</option> command line switch (see
326 above).
</para></listitem>
330 <term><keycap>k
</keycap></term>
332 <listitem><para>Toggle between counting all tasks, or only
333 userspace processes and kernel threads. This setting may also
334 be controlled using the
<option>-k
</option> command line
335 switch (see above).
</para></listitem>
339 <term><keycap>r
</keycap></term>
341 <listitem><para>Toggle between recursively including or
342 excluding processes in child control groups in control group
343 process counts. This setting may also be controlled using the
344 <option>--recursive=
</option> command line switch. This key is
345 not available if all tasks are counted, it is only available
346 if processes are counted, as enabled with the
347 <keycap>P
</keycap> or
<keycap>k
</keycap>
348 keys.
</para></listitem>
355 <title>Exit status
</title>
357 <para>On success,
0 is returned, a non-zero failure code
362 <title>See Also
</title>
364 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
365 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
366 <citerefentry><refentrytitle>systemd-cgls
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
367 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
368 <citerefentry project='man-pages'
><refentrytitle>top
</refentrytitle><manvolnum>1</manvolnum></citerefentry>