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*20d3bac0SEdward Tomasz Napierala.Dd March 30, 2011 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. 856ec54a57SEdward Tomasz Napierala.Pp 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 926ec54a57SEdward Tomasz NapieralaSubject ID identifies the subject. It can be user name, 936ec54a57SEdward Tomasz Napieralanumerical user ID, login class name, jail name, or numerical jail ID. 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 108*20d3bac0SEdward 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:". 1206ec54a57SEdward Tomasz NapieralaA filter that matches all defined rules for nproc resource would be 1216ec54a57SEdward Tomasz Napierala"::nproc". 1226ec54a57SEdward Tomasz Napierala.Pp 1236ec54a57SEdward Tomasz Napierala.Sh RESOURCES 1246ec54a57SEdward Tomasz Napierala.Bl -column -offset 3n "msgqqueued" 1256ec54a57SEdward Tomasz Napierala.It cpu CPU time, in milliseconds 1266ec54a57SEdward Tomasz Napierala.It fsize maximum file size, in bytes 1276ec54a57SEdward Tomasz Napierala.It data data size, in bytes 1286ec54a57SEdward Tomasz Napierala.It stack stack size, in bytes 1296ec54a57SEdward Tomasz Napierala.It core core dump size, in bytes 1306ec54a57SEdward Tomasz Napierala.It rss resident set size, in bytes 1316ec54a57SEdward Tomasz Napierala.It memlock locked memory, in bytes 1326ec54a57SEdward Tomasz Napierala.It nproc number of processes 1336ec54a57SEdward Tomasz Napierala.It nofile file descriptor table size 1346ec54a57SEdward Tomasz Napierala.It sbsize memory consumed by socket buffers, in bytes 1356ec54a57SEdward Tomasz Napierala.It vmem address space limit, in bytes 1366ec54a57SEdward Tomasz Napierala.It npts number of PTYs 1376ec54a57SEdward Tomasz Napierala.It swap swap usage, in bytes 1386ec54a57SEdward Tomasz Napierala.It nthr number of threads 1396ec54a57SEdward Tomasz Napierala.It msgqqueued number of queued SysV messages 1406ec54a57SEdward Tomasz Napierala.It msgqsize SysV message queue size, in bytes 1416ec54a57SEdward Tomasz Napierala.It nmsgq number of SysV message queues 1426ec54a57SEdward Tomasz Napierala.It nsem number of SysV semaphores 1436ec54a57SEdward Tomasz Napierala.It nsemop number of SysV semaphores modified in a single semop(2) call 1446ec54a57SEdward Tomasz Napierala.It nshm number of SysV shared memory segments 1456ec54a57SEdward Tomasz Napierala.It shmsize SysV shared memory size, in bytes 1466ec54a57SEdward Tomasz Napierala.It wallclock wallclock time, in milliseconds 1476ec54a57SEdward Tomasz Napierala.It pctcpu %cpu time 1486ec54a57SEdward Tomasz Napierala.El 1496ec54a57SEdward Tomasz Napierala.Pp 1506ec54a57SEdward Tomasz Napierala.Sh ACTIONS 1516ec54a57SEdward Tomasz Napierala.Bl -column -offset 3n "msgqqueued" 1526ec54a57SEdward Tomasz Napierala.It deny deny the allocation; not supported for cpu and wallclock 1536ec54a57SEdward Tomasz Napierala.It log log a warning to the console 1546ec54a57SEdward Tomasz Napierala.It devctl send notification to 1556ec54a57SEdward Tomasz Napierala.Xr devd 8 1566ec54a57SEdward Tomasz Napierala.It sig* e.g. sigterm; send a signal to the offending process 1576ec54a57SEdward Tomasz Napierala.El 1586ec54a57SEdward Tomasz Napierala.Pp 1596ec54a57SEdward Tomasz NapieralaSee 1606ec54a57SEdward Tomasz Napierala.Xr signal 3 1616ec54a57SEdward Tomasz Napieralafor a list of supported signals. 1626ec54a57SEdward Tomasz Napierala.Pp 1636ec54a57SEdward Tomasz NapieralaNot all actions are supported for all resources. 1646ec54a57SEdward Tomasz NapieralaAttempt to add rule with action not supported by a given resouce will result 1656ec54a57SEdward Tomasz Napieralain error. 1666ec54a57SEdward Tomasz Napierala.Pp 1676ec54a57SEdward Tomasz NapieralaNote that limiting RSS may kill the machine due to thrashing. 1686ec54a57SEdward Tomasz Napierala.Pp 1696ec54a57SEdward Tomasz Napierala.Sh EXIT STATUS 1706ec54a57SEdward Tomasz Napierala.Ex -std 1716ec54a57SEdward Tomasz Napierala.Sh EXAMPLES 1726ec54a57SEdward Tomasz Napierala.Dl rctl -a user:joe:vmem:deny=1g 1736ec54a57SEdward Tomasz Napierala.Pp 1746ec54a57SEdward Tomasz NapieralaPrevent user "joe" from allocating more than 1GB of virtual memory. 1756ec54a57SEdward Tomasz Napierala.Pp 1766ec54a57SEdward Tomasz Napierala.Dl rctl -r : 1776ec54a57SEdward Tomasz Napierala.Pp 1786ec54a57SEdward Tomasz NapieralaRemove all RCTL rules. 1796ec54a57SEdward Tomasz Napierala.Pp 1806ec54a57SEdward Tomasz Napierala.Dl rctl -hu jail:5 1816ec54a57SEdward Tomasz Napierala.Pp 1826ec54a57SEdward Tomasz NapieralaDisplay resource usage information for jail with JID 5. 1836ec54a57SEdward Tomasz Napierala.Pp 1846ec54a57SEdward Tomasz Napierala.Dl rctl -l process:512 1856ec54a57SEdward Tomasz Napierala.Pp 1866ec54a57SEdward Tomasz NapieralaDisplay all the rules applicable to process with PID 512. 1876ec54a57SEdward Tomasz Napierala.Sh SEE ALSO 1886ec54a57SEdward Tomasz Napierala.Xr jailstat 8 , 1896ec54a57SEdward Tomasz Napierala.Xr userstat 8 1906ec54a57SEdward Tomasz Napierala.Sh HISTORY 1916ec54a57SEdward Tomasz NapieralaThe 1926ec54a57SEdward Tomasz Napierala.Nm 1936ec54a57SEdward Tomasz Napieralacommand appeared in 1946ec54a57SEdward Tomasz Napierala.Fx 9.0. 1956ec54a57SEdward Tomasz Napierala.Sh AUTHORS 1966ec54a57SEdward Tomasz Napierala.An -nosplit 1976ec54a57SEdward Tomasz NapieralaThe 1986ec54a57SEdward Tomasz Napierala.Nm 1996ec54a57SEdward Tomasz Napieralacommand was written by 2006ec54a57SEdward Tomasz Napierala.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . 201