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*a29460e0SEdward Tomasz Napierala.Dd March 1, 2012 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 436ec54a57SEdward Tomasz Napierala.Op Fl h 446ec54a57SEdward Tomasz Napierala.Op Fl n 456ec54a57SEdward Tomasz Napierala.Fl l 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.Op Fl h 526ec54a57SEdward Tomasz Napierala.Fl u 536ec54a57SEdward Tomasz Napierala.Op Ar filter 546ec54a57SEdward Tomasz Napierala.Sh DESCRIPTION 556ec54a57SEdward Tomasz NapieralaWhen called without options, the 566ec54a57SEdward Tomasz Napierala.Nm 576ec54a57SEdward Tomasz Napieralacommand writes currently defined RCTL rules to standard output. 586ec54a57SEdward Tomasz Napierala.Pp 596ec54a57SEdward Tomasz NapieralaIf a 606ec54a57SEdward Tomasz Napierala.Ar filter 616ec54a57SEdward Tomasz Napieralaargument is specified, only rules matching the filter are displayed. 626ec54a57SEdward Tomasz NapieralaThe options are as follows: 636ec54a57SEdward Tomasz Napierala.Bl -tag -width indent 646ec54a57SEdward Tomasz Napierala.It Fl a Ar rule 656ec54a57SEdward Tomasz NapieralaAdd 666ec54a57SEdward Tomasz Napierala.Ar rule 676ec54a57SEdward Tomasz Napieralato the RCTL database. 686ec54a57SEdward Tomasz Napierala.It Fl l Ar filter 696ec54a57SEdward Tomasz NapieralaDisplay rules applicable to the process defined by 706ec54a57SEdward Tomasz Napierala.Ar filter . 716ec54a57SEdward Tomasz Napierala.It Fl r Ar filter 726ec54a57SEdward Tomasz NapieralaRemove rules matching 736ec54a57SEdward Tomasz Napierala.Ar filter 746ec54a57SEdward Tomasz Napieralafrom the RCTL database. 756ec54a57SEdward Tomasz Napierala.It Fl u Ar filter 766ec54a57SEdward Tomasz NapieralaDisplay resource usage for a subject (process, user, login class 776ec54a57SEdward Tomasz Napieralaor jail) matching the 786ec54a57SEdward Tomasz Napierala.Ar filter . 796ec54a57SEdward Tomasz Napierala.It Fl h 806ec54a57SEdward Tomasz Napierala"Human-readable" output. 816ec54a57SEdward Tomasz NapieralaUse unit suffixes: Byte, Kilobyte, Megabyte, 826ec54a57SEdward Tomasz NapieralaGigabyte, Terabyte and Petabyte. 836ec54a57SEdward Tomasz Napierala.It Fl n 846ec54a57SEdward Tomasz NapieralaDisplay user IDs numerically rather than converting them to a user name. 85b2e52cedSUlrich Spörlein.El 866ec54a57SEdward Tomasz Napierala.Sh RULE SYNTAX 876ec54a57SEdward Tomasz NapieralaSyntax for a rule is subject:subject-id:resource:action=amount/per. 886ec54a57SEdward Tomasz Napierala.Pp 896ec54a57SEdward Tomasz NapieralaSubject defines the kind of entity the rule applies to. 906ec54a57SEdward Tomasz NapieralaIt can be either process, user, login class, or jail. 916ec54a57SEdward Tomasz Napierala.Pp 92dce762ddSGlen BarberSubject ID identifies the subject. 93dce762ddSGlen BarberIt can be user name, numerical user ID, login class name, or jail name. 946ec54a57SEdward Tomasz Napierala.Pp 956ec54a57SEdward Tomasz NapieralaResource identifies the resource the rule controls. 966ec54a57SEdward Tomasz Napierala.Pp 976ec54a57SEdward Tomasz NapieralaAction defines what will happen when a process exceeds the allowed amount. 986ec54a57SEdward Tomasz Napierala.Pp 996ec54a57SEdward Tomasz NapieralaAmount defines how much of the resource a process can use before 1006ec54a57SEdward Tomasz Napieralathe defined action triggers. 1016ec54a57SEdward Tomasz Napierala.Pp 1026ec54a57SEdward Tomasz NapieralaThe per field defines what entity the amount gets accounted for. 1036ec54a57SEdward Tomasz NapieralaFor example, rule "loginclass:users:vmem:deny=100M/process" means 1046ec54a57SEdward Tomasz Napieralathat each process of any user belonging to login class "users" may allocate 1056ec54a57SEdward Tomasz Napieralaup to 100MB of virtual memory. 1066ec54a57SEdward Tomasz NapieralaRule "loginclass:users:vmem:deny=100M/user" would mean that for each 1076ec54a57SEdward Tomasz Napieralauser belonging to the login class "users", the sum of virtual memory allocated 10820d3bac0SEdward Tomasz Napieralaby all the processes of that user will not exceed 100MB. 1096ec54a57SEdward Tomasz NapieralaRule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of 1106ec54a57SEdward Tomasz Napieralavirtual memory allocated by all processes of all users belonging to that login 1116ec54a57SEdward Tomasz Napieralaclass will not exceed 100MB. 1126ec54a57SEdward Tomasz Napierala.Pp 1136ec54a57SEdward Tomasz NapieralaValid rule has all those fields specified, except for the per, which defaults 1146ec54a57SEdward Tomasz Napieralato the value of subject. 1156ec54a57SEdward Tomasz Napierala.Pp 1166ec54a57SEdward Tomasz NapieralaA filter is a rule for which one of more fields other than per is left empty. 1176ec54a57SEdward Tomasz NapieralaFor example, a filter that matches every rule could be written as ":::=/", 1186ec54a57SEdward Tomasz Napieralaor, in short, ":". 1196ec54a57SEdward Tomasz NapieralaA filter that matches all the login classes would be "loginclass:". 120*a29460e0SEdward Tomasz NapieralaA filter that matches all defined rules for maxproc resource would be 121*a29460e0SEdward Tomasz Napierala"::maxproc". 1226ec54a57SEdward Tomasz Napierala.Pp 1236ec54a57SEdward Tomasz Napierala.Sh RESOURCES 12485a2f1b4SEdward Tomasz Napierala.Bl -column -offset 3n "pseudoterminals" 125dce762ddSGlen Barber.It "cputime CPU time, in seconds" 126dce762ddSGlen Barber.It "datasize data size, in bytes" 127dce762ddSGlen Barber.It "stacksize stack size, in bytes" 128dce762ddSGlen Barber.It "coredumpsize core dump size, in bytes" 129dce762ddSGlen Barber.It "memoryuse resident set size, in bytes" 130dce762ddSGlen Barber.It "memorylocked locked memory, in bytes" 131dce762ddSGlen Barber.It "maxproc number of processes" 132dce762ddSGlen Barber.It "openfiles file descriptor table size" 133dce762ddSGlen Barber.It "vmemoryuse address space limit, in bytes" 134dce762ddSGlen Barber.It "pseudoterminals number of PTYs" 135dce762ddSGlen Barber.It "swapuse swap usage, in bytes" 136dce762ddSGlen Barber.It "nthr number of threads" 137dce762ddSGlen Barber.It "msgqqueued number of queued SysV messages" 138dce762ddSGlen Barber.It "msgqsize SysV message queue size, in bytes" 139dce762ddSGlen Barber.It "nmsgq number of SysV message queues" 140dce762ddSGlen Barber.It "nsem number of SysV semaphores" 141dce762ddSGlen Barber.It "nsemop number of SysV semaphores modified in a single semop(2) call" 142dce762ddSGlen Barber.It "nshm number of SysV shared memory segments" 143dce762ddSGlen Barber.It "shmsize SysV shared memory size, in bytes" 144dce762ddSGlen Barber.It "wallclock wallclock time, in seconds" 1456ec54a57SEdward Tomasz Napierala.El 1466ec54a57SEdward Tomasz Napierala.Pp 1476ec54a57SEdward Tomasz Napierala.Sh ACTIONS 14885a2f1b4SEdward Tomasz Napierala.Bl -column -offset 3n "pseudoterminals" 149dce762ddSGlen Barber.It "deny deny the allocation; not supported for cpu and wallclock" 150dce762ddSGlen Barber.It "log log a warning to the console" 151dce762ddSGlen Barber.It "devctl send notification to" 1526ec54a57SEdward Tomasz Napierala.Xr devd 8 153dce762ddSGlen Barber.It "sig* e.g. sigterm; send a signal to the offending process" 1546ec54a57SEdward Tomasz Napierala.El 1556ec54a57SEdward Tomasz Napierala.Pp 1566ec54a57SEdward Tomasz NapieralaSee 1576ec54a57SEdward Tomasz Napierala.Xr signal 3 1586ec54a57SEdward Tomasz Napieralafor a list of supported signals. 1596ec54a57SEdward Tomasz Napierala.Pp 1606ec54a57SEdward Tomasz NapieralaNot all actions are supported for all resources. 1616ec54a57SEdward Tomasz NapieralaAttempt to add rule with action not supported by a given resouce will result 1626ec54a57SEdward Tomasz Napieralain error. 1636ec54a57SEdward Tomasz Napierala.Pp 1646ec54a57SEdward Tomasz NapieralaNote that limiting RSS may kill the machine due to thrashing. 1656ec54a57SEdward Tomasz Napierala.Pp 1666ec54a57SEdward Tomasz Napierala.Sh EXIT STATUS 1676ec54a57SEdward Tomasz Napierala.Ex -std 1686ec54a57SEdward Tomasz Napierala.Sh EXAMPLES 16985a2f1b4SEdward Tomasz Napierala.Dl rctl -a user:joe:vmemoryuse:deny=1g 1706ec54a57SEdward Tomasz Napierala.Pp 1716ec54a57SEdward Tomasz NapieralaPrevent user "joe" from allocating more than 1GB of virtual memory. 1726ec54a57SEdward Tomasz Napierala.Pp 1736ec54a57SEdward Tomasz Napierala.Dl rctl -r : 1746ec54a57SEdward Tomasz Napierala.Pp 1756ec54a57SEdward Tomasz NapieralaRemove all RCTL rules. 1766ec54a57SEdward Tomasz Napierala.Pp 177a7ad07bfSEdward Tomasz Napierala.Dl rctl -hu jail:www 1786ec54a57SEdward Tomasz Napierala.Pp 179a7ad07bfSEdward Tomasz NapieralaDisplay resource usage information for jail named "www". 1806ec54a57SEdward Tomasz Napierala.Pp 1816ec54a57SEdward Tomasz Napierala.Dl rctl -l process:512 1826ec54a57SEdward Tomasz Napierala.Pp 1836ec54a57SEdward Tomasz NapieralaDisplay all the rules applicable to process with PID 512. 1846ec54a57SEdward Tomasz Napierala.Sh SEE ALSO 185ee2509d1SEdward Tomasz Napierala.Xr rctl.conf 5 , 1866ec54a57SEdward Tomasz Napierala.Xr jailstat 8 , 1876ec54a57SEdward Tomasz Napierala.Xr userstat 8 1886ec54a57SEdward Tomasz Napierala.Sh HISTORY 1896ec54a57SEdward Tomasz NapieralaThe 1906ec54a57SEdward Tomasz Napierala.Nm 1916ec54a57SEdward Tomasz Napieralacommand appeared in 1926ec54a57SEdward Tomasz Napierala.Fx 9.0. 1936ec54a57SEdward Tomasz Napierala.Sh AUTHORS 1946ec54a57SEdward Tomasz Napierala.An -nosplit 1956ec54a57SEdward Tomasz NapieralaThe 1966ec54a57SEdward Tomasz Napierala.Nm 1976ec54a57SEdward Tomasz Napieralacommand was written by 1986ec54a57SEdward Tomasz Napierala.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . 199