xref: /freebsd/usr.bin/rctl/rctl.8 (revision c0a04e017b2b5c9f9903a8f32fd130fd35a6db6f)
16ec54a57SEdward Tomasz Napierala.\"-
26ec54a57SEdward Tomasz Napierala.\" Copyright (c) 2009 Edward Tomasz Napierala
36ec54a57SEdward Tomasz Napierala.\" All rights reserved.
46ec54a57SEdward Tomasz Napierala.\"
56ec54a57SEdward Tomasz Napierala.\" Redistribution and use in source and binary forms, with or without
66ec54a57SEdward Tomasz Napierala.\" modification, are permitted provided that the following conditions
76ec54a57SEdward Tomasz Napierala.\" are met:
86ec54a57SEdward Tomasz Napierala.\" 1. Redistributions of source code must retain the above copyright
96ec54a57SEdward Tomasz Napierala.\"    notice, this list of conditions and the following disclaimer.
106ec54a57SEdward Tomasz Napierala.\" 2. Redistributions in binary form must reproduce the above copyright
116ec54a57SEdward Tomasz Napierala.\"    notice, this list of conditions and the following disclaimer in the
126ec54a57SEdward Tomasz Napierala.\"    documentation and/or other materials provided with the distribution.
136ec54a57SEdward Tomasz Napierala.\"
146ec54a57SEdward Tomasz Napierala.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
156ec54a57SEdward Tomasz Napierala.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
166ec54a57SEdward Tomasz Napierala.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
176ec54a57SEdward Tomasz Napierala.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE
186ec54a57SEdward Tomasz Napierala.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
196ec54a57SEdward Tomasz Napierala.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
206ec54a57SEdward Tomasz Napierala.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
216ec54a57SEdward Tomasz Napierala.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
226ec54a57SEdward Tomasz Napierala.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
236ec54a57SEdward Tomasz Napierala.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
246ec54a57SEdward Tomasz Napierala.\" POSSIBILITY OF SUCH DAMAGE.
256ec54a57SEdward Tomasz Napierala.\"
266ec54a57SEdward Tomasz Napierala.\" $FreeBSD$
276ec54a57SEdward Tomasz Napierala.\"
28*c0a04e01SBryan Drewery.Dd February 14, 2014
296ec54a57SEdward Tomasz Napierala.Dt RCTL 8
306ec54a57SEdward Tomasz Napierala.Os
316ec54a57SEdward Tomasz Napierala.Sh NAME
326ec54a57SEdward Tomasz Napierala.Nm rctl
336ec54a57SEdward Tomasz Napierala.Nd display and update resource limits database
346ec54a57SEdward Tomasz Napierala.Sh SYNOPSIS
356ec54a57SEdward Tomasz Napierala.Nm
366ec54a57SEdward Tomasz Napierala.Op Fl h
376ec54a57SEdward Tomasz Napierala.Op Fl n
386ec54a57SEdward Tomasz Napierala.Op Ar filter
396ec54a57SEdward Tomasz Napierala.Nm
406ec54a57SEdward Tomasz Napierala.Fl a
416ec54a57SEdward Tomasz Napierala.Op Ar rule
426ec54a57SEdward Tomasz Napierala.Nm
43*c0a04e01SBryan Drewery.Fl l
446ec54a57SEdward Tomasz Napierala.Op Fl h
456ec54a57SEdward Tomasz Napierala.Op Fl n
466ec54a57SEdward Tomasz Napierala.Op Ar filter
476ec54a57SEdward Tomasz Napierala.Nm
486ec54a57SEdward Tomasz Napierala.Fl r
496ec54a57SEdward Tomasz Napierala.Op Ar filter
506ec54a57SEdward Tomasz Napierala.Nm
516ec54a57SEdward Tomasz Napierala.Fl u
52*c0a04e01SBryan Drewery.Op Fl h
536ec54a57SEdward Tomasz Napierala.Op Ar filter
54*c0a04e01SBryan Drewery.Pp
55*c0a04e01SBryan Drewery.Nm
56*c0a04e01SBryan Dreweryrequires the kernel to be compiled with:
57*c0a04e01SBryan Drewery.Bd -ragged -offset indent
58*c0a04e01SBryan Drewery.Cd "options RACCT"
59*c0a04e01SBryan Drewery.Cd "options RCTL"
60*c0a04e01SBryan Drewery.Ed
616ec54a57SEdward Tomasz Napierala.Sh DESCRIPTION
626ec54a57SEdward Tomasz NapieralaWhen called without options, the
636ec54a57SEdward Tomasz Napierala.Nm
646ec54a57SEdward Tomasz Napieralacommand writes currently defined RCTL rules to standard output.
656ec54a57SEdward Tomasz Napierala.Pp
666ec54a57SEdward Tomasz NapieralaIf a
676ec54a57SEdward Tomasz Napierala.Ar filter
686ec54a57SEdward Tomasz Napieralaargument is specified, only rules matching the filter are displayed.
696ec54a57SEdward Tomasz NapieralaThe options are as follows:
706ec54a57SEdward Tomasz Napierala.Bl -tag -width indent
716ec54a57SEdward Tomasz Napierala.It Fl a Ar rule
726ec54a57SEdward Tomasz NapieralaAdd
736ec54a57SEdward Tomasz Napierala.Ar rule
746ec54a57SEdward Tomasz Napieralato the RCTL database.
756ec54a57SEdward Tomasz Napierala.It Fl l Ar filter
766ec54a57SEdward Tomasz NapieralaDisplay rules applicable to the process defined by
776ec54a57SEdward Tomasz Napierala.Ar filter .
78aeb99b56SEdward Tomasz NapieralaNote that this is different from showing the rules when called without
79aeb99b56SEdward Tomasz Napieralaany options, as it shows not just the rules with subject equal to that
80aeb99b56SEdward Tomasz Napieralaof process, but also rules for the user, jail, and login class applicable
81aeb99b56SEdward Tomasz Napieralato the process.
826ec54a57SEdward Tomasz Napierala.It Fl r Ar filter
836ec54a57SEdward Tomasz NapieralaRemove rules matching
846ec54a57SEdward Tomasz Napierala.Ar filter
856ec54a57SEdward Tomasz Napieralafrom the RCTL database.
866ec54a57SEdward Tomasz Napierala.It Fl u Ar filter
87*c0a04e01SBryan DreweryDisplay resource usage for a subject
88*c0a04e01SBryan Drewery.Po
89*c0a04e01SBryan Drewery.Sy process ,
90*c0a04e01SBryan Drewery.Sy user ,
91*c0a04e01SBryan Drewery.Sy loginclass
92*c0a04e01SBryan Dreweryor
93*c0a04e01SBryan Drewery.Sy jail
94*c0a04e01SBryan Drewery.Pc
95*c0a04e01SBryan Drewerymatching the
966ec54a57SEdward Tomasz Napierala.Ar filter .
976ec54a57SEdward Tomasz Napierala.It Fl h
986ec54a57SEdward Tomasz Napierala"Human-readable" output.
996ec54a57SEdward Tomasz NapieralaUse unit suffixes: Byte, Kilobyte, Megabyte,
1006ec54a57SEdward Tomasz NapieralaGigabyte, Terabyte and Petabyte.
1016ec54a57SEdward Tomasz Napierala.It Fl n
1026ec54a57SEdward Tomasz NapieralaDisplay user IDs numerically rather than converting them to a user name.
103b2e52cedSUlrich Spörlein.El
104*c0a04e01SBryan Drewery.Pp
105*c0a04e01SBryan DreweryModifying rules affects all currently running and future processes matching
106*c0a04e01SBryan Drewerythe rule.
1076ec54a57SEdward Tomasz Napierala.Sh RULE SYNTAX
1086ec54a57SEdward Tomasz NapieralaSyntax for a rule is subject:subject-id:resource:action=amount/per.
1096ec54a57SEdward Tomasz Napierala.Pp
110*c0a04e01SBryan Drewery.Bl -tag -width "subject-id" -compact -offset indent
111*c0a04e01SBryan Drewery.It subject
112*c0a04e01SBryan Drewerydefines the kind of entity the rule applies to.
113*c0a04e01SBryan DreweryIt can be either
114*c0a04e01SBryan Drewery.Sy process ,
115*c0a04e01SBryan Drewery.Sy user ,
116*c0a04e01SBryan Drewery.Sy loginclass ,
117*c0a04e01SBryan Dreweryor
118*c0a04e01SBryan Drewery.Sy jail .
119*c0a04e01SBryan Drewery.It subject-id
120*c0a04e01SBryan Dreweryidentifies the
121*c0a04e01SBryan Drewery.Em subject .
122*c0a04e01SBryan DreweryIt can be a process ID, user name, numerical user ID, login class name from
123*c0a04e01SBryan Drewery.Xr login.conf 5 ,
124aeb99b56SEdward Tomasz Napieralaor jail name.
125*c0a04e01SBryan Drewery.It resource
126*c0a04e01SBryan Dreweryidentifies the resource the rule controls.
127*c0a04e01SBryan DrewerySee the
128*c0a04e01SBryan Drewery.Sx RESOURCES
129*c0a04e01SBryan Drewerysection below for details.
130*c0a04e01SBryan Drewery.It action
131*c0a04e01SBryan Drewerydefines what will happen when a process exceeds the allowed
132*c0a04e01SBryan Drewery.Em amount .
133*c0a04e01SBryan DrewerySee the
134*c0a04e01SBryan Drewery.Sx ACTIONS
135*c0a04e01SBryan Drewerysection below for details.
136*c0a04e01SBryan Drewery.It amount
137*c0a04e01SBryan Drewerydefines how much of the resource a process can use before
138*c0a04e01SBryan Drewerythe defined
139*c0a04e01SBryan Drewery.Em action
140*c0a04e01SBryan Drewerytriggers.
141*c0a04e01SBryan DreweryResources which limit bytes may use prefixes from
142*c0a04e01SBryan Drewery.Xr expand_number 3 .
143*c0a04e01SBryan Drewery.It per
144*c0a04e01SBryan Drewerydefines what entity the
145*c0a04e01SBryan Drewery.Em amount
146*c0a04e01SBryan Drewerygets accounted for.
1476ec54a57SEdward Tomasz NapieralaFor example, rule "loginclass:users:vmem:deny=100M/process" means
1486ec54a57SEdward Tomasz Napieralathat each process of any user belonging to login class "users" may allocate
1496ec54a57SEdward Tomasz Napieralaup to 100MB of virtual memory.
1506ec54a57SEdward Tomasz NapieralaRule "loginclass:users:vmem:deny=100M/user" would mean that for each
1516ec54a57SEdward Tomasz Napieralauser belonging to the login class "users", the sum of virtual memory allocated
15220d3bac0SEdward Tomasz Napieralaby all the processes of that user will not exceed 100MB.
1536ec54a57SEdward Tomasz NapieralaRule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of
1546ec54a57SEdward Tomasz Napieralavirtual memory allocated by all processes of all users belonging to that login
1556ec54a57SEdward Tomasz Napieralaclass will not exceed 100MB.
156*c0a04e01SBryan Drewery.El
1576ec54a57SEdward Tomasz Napierala.Pp
158*c0a04e01SBryan DreweryA valid rule has all those fields specified, except for
159*c0a04e01SBryan Drewery.Em per ,
160*c0a04e01SBryan Drewerywhich defaults
161*c0a04e01SBryan Dreweryto the value of
162*c0a04e01SBryan Drewery.Em subject .
1636ec54a57SEdward Tomasz Napierala.Pp
164*c0a04e01SBryan DreweryA filter is a rule for which one of more fields other than
165*c0a04e01SBryan Drewery.Em per
166*c0a04e01SBryan Dreweryis left empty.
1676ec54a57SEdward Tomasz NapieralaFor example, a filter that matches every rule could be written as ":::=/",
1686ec54a57SEdward Tomasz Napieralaor, in short, ":".
1696ec54a57SEdward Tomasz NapieralaA filter that matches all the login classes would be "loginclass:".
170*c0a04e01SBryan DreweryA filter that matches all defined rules for
171*c0a04e01SBryan Drewery.Sy maxproc
172*c0a04e01SBryan Dreweryresource would be
173a29460e0SEdward Tomasz Napierala"::maxproc".
174*c0a04e01SBryan Drewery.Sh SUBJECTS
175*c0a04e01SBryan Drewery.Bl -column -offset 3n "pseudoterminals" ".Sy username or numerical User ID"
176*c0a04e01SBryan Drewery.It Em subject Ta Em subject-id
177*c0a04e01SBryan Drewery.It Sy process Ta numerical Process ID
178*c0a04e01SBryan Drewery.It Sy user Ta user name or numerical User ID
179*c0a04e01SBryan Drewery.It Sy loginclass Ta login class from
180*c0a04e01SBryan Drewery.Xr login.conf 5
181*c0a04e01SBryan Drewery.It Sy jail Ta jail name
182*c0a04e01SBryan Drewery.El
1836ec54a57SEdward Tomasz Napierala.Sh RESOURCES
18485a2f1b4SEdward Tomasz Napierala.Bl -column -offset 3n "pseudoterminals"
185*c0a04e01SBryan Drewery.It Em resource
186*c0a04e01SBryan Drewery.It Sy cputime Ta "CPU time, in seconds"
187*c0a04e01SBryan Drewery.It Sy datasize Ta "data size, in bytes"
188*c0a04e01SBryan Drewery.It Sy stacksize Ta "stack size, in bytes"
189*c0a04e01SBryan Drewery.It Sy coredumpsize Ta "core dump size, in bytes"
190*c0a04e01SBryan Drewery.It Sy memoryuse Ta "resident set size, in bytes"
191*c0a04e01SBryan Drewery.It Sy memorylocked Ta "locked memory, in bytes"
192*c0a04e01SBryan Drewery.It Sy maxproc Ta "number of processes"
193*c0a04e01SBryan Drewery.It Sy openfiles Ta "file descriptor table size"
194*c0a04e01SBryan Drewery.It Sy vmemoryuse Ta "address space limit, in bytes"
195*c0a04e01SBryan Drewery.It Sy pseudoterminals Ta "number of PTYs"
196*c0a04e01SBryan Drewery.It Sy swapuse Ta "swap usage, in bytes"
197*c0a04e01SBryan Drewery.It Sy nthr Ta "number of threads"
198*c0a04e01SBryan Drewery.It Sy msgqqueued Ta "number of queued SysV messages"
199*c0a04e01SBryan Drewery.It Sy msgqsize Ta "SysV message queue size, in bytes"
200*c0a04e01SBryan Drewery.It Sy nmsgq Ta "number of SysV message queues"
201*c0a04e01SBryan Drewery.It Sy nsem Ta "number of SysV semaphores"
202*c0a04e01SBryan Drewery.It Sy nsemop Ta "number of SysV semaphores modified in a single semop(2) call"
203*c0a04e01SBryan Drewery.It Sy nshm Ta "number of SysV shared memory segments"
204*c0a04e01SBryan Drewery.It Sy shmsize Ta "SysV shared memory size, in bytes"
205*c0a04e01SBryan Drewery.It Sy wallclock Ta "wallclock time, in seconds"
206*c0a04e01SBryan Drewery.It Sy pcpu Ta "%CPU, in percents of a single CPU core"
2076ec54a57SEdward Tomasz Napierala.El
2086ec54a57SEdward Tomasz Napierala.Sh ACTIONS
20985a2f1b4SEdward Tomasz Napierala.Bl -column -offset 3n "pseudoterminals"
210*c0a04e01SBryan Drewery.It Em action
211*c0a04e01SBryan Drewery.It Sy deny Ta deny the allocation; not supported for
212*c0a04e01SBryan Drewery.Sy cpu
213*c0a04e01SBryan Dreweryand
214*c0a04e01SBryan Drewery.Sy wallclock
215*c0a04e01SBryan Drewery.It Sy log Ta "log a warning to the console"
216*c0a04e01SBryan Drewery.It Sy devctl Ta "send notification to"
2176ec54a57SEdward Tomasz Napierala.Xr devd 8
218*c0a04e01SBryan Dreweryusing
219*c0a04e01SBryan Drewery.Sy system
220*c0a04e01SBryan Drewery= "RCTL",
221*c0a04e01SBryan Drewery.Sy subsystem
222*c0a04e01SBryan Drewery= "rule",
223*c0a04e01SBryan Drewery.Sy type
224*c0a04e01SBryan Drewery= "matched"
225*c0a04e01SBryan Drewery.It sig*	e.g.
226*c0a04e01SBryan Drewery.Sy sigterm ;
227*c0a04e01SBryan Drewerysend a signal to the offending process.
2286ec54a57SEdward Tomasz NapieralaSee
2296ec54a57SEdward Tomasz Napierala.Xr signal 3
230*c0a04e01SBryan Dreweryfor a list of supported signals
231*c0a04e01SBryan Drewery.El
2326ec54a57SEdward Tomasz Napierala.Pp
2336ec54a57SEdward Tomasz NapieralaNot all actions are supported for all resources.
234*c0a04e01SBryan DreweryAttempting to add a rule with an action not supported by a given resource will
235*c0a04e01SBryan Dreweryresult in error.
2366ec54a57SEdward Tomasz Napierala.Sh EXIT STATUS
2376ec54a57SEdward Tomasz Napierala.Ex -std
2386ec54a57SEdward Tomasz Napierala.Sh EXAMPLES
2390a44395eSBryan DreweryPrevent user "joe" from allocating more than 1GB of virtual memory:
2400a44395eSBryan Drewery.Dl Nm Fl a Ar user:joe:vmemoryuse:deny=1g
2416ec54a57SEdward Tomasz Napierala.Pp
2420a44395eSBryan DreweryRemove all RCTL rules:
2430a44395eSBryan Drewery.Dl Nm Fl r Ar \&:
2446ec54a57SEdward Tomasz Napierala.Pp
2450a44395eSBryan DreweryDisplay resource usage information for jail named "www":
2460a44395eSBryan Drewery.Dl Nm Fl hu Ar jail:www
2476ec54a57SEdward Tomasz Napierala.Pp
2480a44395eSBryan DreweryDisplay all the rules applicable to process with PID 512:
2490a44395eSBryan Drewery.Dl Nm Fl l Ar process:512
250*c0a04e01SBryan Drewery.Pp
251*c0a04e01SBryan DreweryDisplay all rules:
252*c0a04e01SBryan Drewery.Dl Nm
253*c0a04e01SBryan Drewery.Pp
254*c0a04e01SBryan DreweryDisplay all rules matching user "joe":
255*c0a04e01SBryan Drewery.Dl Nm Ar user:joe
256*c0a04e01SBryan Drewery.Pp
257*c0a04e01SBryan DreweryDisplay all rules matching login classes:
258*c0a04e01SBryan Drewery.Dl Nm Ar loginclass:
2596ec54a57SEdward Tomasz Napierala.Sh SEE ALSO
260d8c4c833SEdward Tomasz Napierala.Xr rctl.conf 5
2616ec54a57SEdward Tomasz Napierala.Sh HISTORY
2626ec54a57SEdward Tomasz NapieralaThe
2636ec54a57SEdward Tomasz Napierala.Nm
2646ec54a57SEdward Tomasz Napieralacommand appeared in
2656ec54a57SEdward Tomasz Napierala.Fx 9.0 .
2666ec54a57SEdward Tomasz Napierala.Sh AUTHORS
2676ec54a57SEdward Tomasz Napierala.An -nosplit
2686ec54a57SEdward Tomasz NapieralaThe
2696ec54a57SEdward Tomasz Napierala.Nm
2706ec54a57SEdward Tomasz Napieralacommand was written by
2716ec54a57SEdward Tomasz Napierala.An Edward Tomasz Napierala Aq trasz@FreeBSD.org .
272*c0a04e01SBryan Drewery.Sh BUGS
273*c0a04e01SBryan DreweryLimiting
274*c0a04e01SBryan Drewery.Sy memoryuse
275*c0a04e01SBryan Drewerymay kill the machine due to thrashing.
276