1*6ec54a57SEdward Tomasz Napierala.\"- 2*6ec54a57SEdward Tomasz Napierala.\" Copyright (c) 2009 Edward Tomasz Napierala 3*6ec54a57SEdward Tomasz Napierala.\" All rights reserved. 4*6ec54a57SEdward Tomasz Napierala.\" 5*6ec54a57SEdward Tomasz Napierala.\" Redistribution and use in source and binary forms, with or without 6*6ec54a57SEdward Tomasz Napierala.\" modification, are permitted provided that the following conditions 7*6ec54a57SEdward Tomasz Napierala.\" are met: 8*6ec54a57SEdward Tomasz Napierala.\" 1. Redistributions of source code must retain the above copyright 9*6ec54a57SEdward Tomasz Napierala.\" notice, this list of conditions and the following disclaimer. 10*6ec54a57SEdward Tomasz Napierala.\" 2. Redistributions in binary form must reproduce the above copyright 11*6ec54a57SEdward Tomasz Napierala.\" notice, this list of conditions and the following disclaimer in the 12*6ec54a57SEdward Tomasz Napierala.\" documentation and/or other materials provided with the distribution. 13*6ec54a57SEdward Tomasz Napierala.\" 14*6ec54a57SEdward Tomasz Napierala.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*6ec54a57SEdward Tomasz Napierala.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*6ec54a57SEdward Tomasz Napierala.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*6ec54a57SEdward Tomasz Napierala.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE 18*6ec54a57SEdward Tomasz Napierala.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19*6ec54a57SEdward Tomasz Napierala.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20*6ec54a57SEdward Tomasz Napierala.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21*6ec54a57SEdward Tomasz Napierala.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22*6ec54a57SEdward Tomasz Napierala.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23*6ec54a57SEdward Tomasz Napierala.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24*6ec54a57SEdward Tomasz Napierala.\" POSSIBILITY OF SUCH DAMAGE. 25*6ec54a57SEdward Tomasz Napierala.\" 26*6ec54a57SEdward Tomasz Napierala.\" $FreeBSD$ 27*6ec54a57SEdward Tomasz Napierala.\" 28*6ec54a57SEdward Tomasz Napierala.Dd February 13, 2011 29*6ec54a57SEdward Tomasz Napierala.Dt RCTL 8 30*6ec54a57SEdward Tomasz Napierala.Os 31*6ec54a57SEdward Tomasz Napierala.Sh NAME 32*6ec54a57SEdward Tomasz Napierala.Nm rctl 33*6ec54a57SEdward Tomasz Napierala.Nd display and update resource limits database 34*6ec54a57SEdward Tomasz Napierala.Sh SYNOPSIS 35*6ec54a57SEdward Tomasz Napierala.Nm 36*6ec54a57SEdward Tomasz Napierala.Op Fl h 37*6ec54a57SEdward Tomasz Napierala.Op Fl n 38*6ec54a57SEdward Tomasz Napierala.Op Ar filter 39*6ec54a57SEdward Tomasz Napierala.Nm 40*6ec54a57SEdward Tomasz Napierala.Fl a 41*6ec54a57SEdward Tomasz Napierala.Op Ar rule 42*6ec54a57SEdward Tomasz Napierala.Nm 43*6ec54a57SEdward Tomasz Napierala.Op Fl h 44*6ec54a57SEdward Tomasz Napierala.Op Fl n 45*6ec54a57SEdward Tomasz Napierala.Fl l 46*6ec54a57SEdward Tomasz Napierala.Op Ar filter 47*6ec54a57SEdward Tomasz Napierala.Nm 48*6ec54a57SEdward Tomasz Napierala.Fl r 49*6ec54a57SEdward Tomasz Napierala.Op Ar filter 50*6ec54a57SEdward Tomasz Napierala.Nm 51*6ec54a57SEdward Tomasz Napierala.Op Fl h 52*6ec54a57SEdward Tomasz Napierala.Fl u 53*6ec54a57SEdward Tomasz Napierala.Op Ar filter 54*6ec54a57SEdward Tomasz Napierala.Sh DESCRIPTION 55*6ec54a57SEdward Tomasz NapieralaWhen called without options, the 56*6ec54a57SEdward Tomasz Napierala.Nm 57*6ec54a57SEdward Tomasz Napieralacommand writes currently defined RCTL rules to standard output. 58*6ec54a57SEdward Tomasz Napierala.Pp 59*6ec54a57SEdward Tomasz NapieralaIf a 60*6ec54a57SEdward Tomasz Napierala.Ar filter 61*6ec54a57SEdward Tomasz Napieralaargument is specified, only rules matching the filter are displayed. 62*6ec54a57SEdward Tomasz NapieralaThe options are as follows: 63*6ec54a57SEdward Tomasz Napierala.Bl -tag -width indent 64*6ec54a57SEdward Tomasz Napierala.It Fl a Ar rule 65*6ec54a57SEdward Tomasz NapieralaAdd 66*6ec54a57SEdward Tomasz Napierala.Ar rule 67*6ec54a57SEdward Tomasz Napieralato the RCTL database. 68*6ec54a57SEdward Tomasz Napierala.It Fl l Ar filter 69*6ec54a57SEdward Tomasz NapieralaDisplay rules applicable to the process defined by 70*6ec54a57SEdward Tomasz Napierala.Ar filter . 71*6ec54a57SEdward Tomasz Napierala.It Fl r Ar filter 72*6ec54a57SEdward Tomasz NapieralaRemove rules matching 73*6ec54a57SEdward Tomasz Napierala.Ar filter 74*6ec54a57SEdward Tomasz Napieralafrom the RCTL database. 75*6ec54a57SEdward Tomasz Napierala.It Fl u Ar filter 76*6ec54a57SEdward Tomasz NapieralaDisplay resource usage for a subject (process, user, login class 77*6ec54a57SEdward Tomasz Napieralaor jail) matching the 78*6ec54a57SEdward Tomasz Napierala.Ar filter . 79*6ec54a57SEdward Tomasz Napierala.It Fl h 80*6ec54a57SEdward Tomasz Napierala"Human-readable" output. 81*6ec54a57SEdward Tomasz NapieralaUse unit suffixes: Byte, Kilobyte, Megabyte, 82*6ec54a57SEdward Tomasz NapieralaGigabyte, Terabyte and Petabyte. 83*6ec54a57SEdward Tomasz Napierala.It Fl n 84*6ec54a57SEdward Tomasz NapieralaDisplay user IDs numerically rather than converting them to a user name. 85*6ec54a57SEdward Tomasz Napierala.Pp 86*6ec54a57SEdward Tomasz Napierala.Sh RULE SYNTAX 87*6ec54a57SEdward Tomasz NapieralaSyntax for a rule is subject:subject-id:resource:action=amount/per. 88*6ec54a57SEdward Tomasz Napierala.Pp 89*6ec54a57SEdward Tomasz NapieralaSubject defines the kind of entity the rule applies to. 90*6ec54a57SEdward Tomasz NapieralaIt can be either process, user, login class, or jail. 91*6ec54a57SEdward Tomasz Napierala.Pp 92*6ec54a57SEdward Tomasz NapieralaSubject ID identifies the subject. It can be user name, 93*6ec54a57SEdward Tomasz Napieralanumerical user ID, login class name, jail name, or numerical jail ID. 94*6ec54a57SEdward Tomasz Napierala.Pp 95*6ec54a57SEdward Tomasz NapieralaResource identifies the resource the rule controls. 96*6ec54a57SEdward Tomasz Napierala.Pp 97*6ec54a57SEdward Tomasz NapieralaAction defines what will happen when a process exceeds the allowed amount. 98*6ec54a57SEdward Tomasz Napierala.Pp 99*6ec54a57SEdward Tomasz NapieralaAmount defines how much of the resource a process can use before 100*6ec54a57SEdward Tomasz Napieralathe defined action triggers. 101*6ec54a57SEdward Tomasz Napierala.Pp 102*6ec54a57SEdward Tomasz NapieralaThe per field defines what entity the amount gets accounted for. 103*6ec54a57SEdward Tomasz NapieralaFor example, rule "loginclass:users:vmem:deny=100M/process" means 104*6ec54a57SEdward Tomasz Napieralathat each process of any user belonging to login class "users" may allocate 105*6ec54a57SEdward Tomasz Napieralaup to 100MB of virtual memory. 106*6ec54a57SEdward Tomasz NapieralaRule "loginclass:users:vmem:deny=100M/user" would mean that for each 107*6ec54a57SEdward Tomasz Napieralauser belonging to the login class "users", the sum of virtual memory allocated 108*6ec54a57SEdward Tomasz Napieralaby all the processes of a that user will not exceed 100MB. 109*6ec54a57SEdward Tomasz NapieralaRule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of 110*6ec54a57SEdward Tomasz Napieralavirtual memory allocated by all processes of all users belonging to that login 111*6ec54a57SEdward Tomasz Napieralaclass will not exceed 100MB. 112*6ec54a57SEdward Tomasz Napierala.Pp 113*6ec54a57SEdward Tomasz NapieralaValid rule has all those fields specified, except for the per, which defaults 114*6ec54a57SEdward Tomasz Napieralato the value of subject. 115*6ec54a57SEdward Tomasz Napierala.Pp 116*6ec54a57SEdward Tomasz NapieralaA filter is a rule for which one of more fields other than per is left empty. 117*6ec54a57SEdward Tomasz NapieralaFor example, a filter that matches every rule could be written as ":::=/", 118*6ec54a57SEdward Tomasz Napieralaor, in short, ":". 119*6ec54a57SEdward Tomasz NapieralaA filter that matches all the login classes would be "loginclass:". 120*6ec54a57SEdward Tomasz NapieralaA filter that matches all defined rules for nproc resource would be 121*6ec54a57SEdward Tomasz Napierala"::nproc". 122*6ec54a57SEdward Tomasz Napierala.Pp 123*6ec54a57SEdward Tomasz Napierala.Sh RESOURCES 124*6ec54a57SEdward Tomasz Napierala.Bl -column -offset 3n "msgqqueued" 125*6ec54a57SEdward Tomasz Napierala.It cpu CPU time, in milliseconds 126*6ec54a57SEdward Tomasz Napierala.It fsize maximum file size, in bytes 127*6ec54a57SEdward Tomasz Napierala.It data data size, in bytes 128*6ec54a57SEdward Tomasz Napierala.It stack stack size, in bytes 129*6ec54a57SEdward Tomasz Napierala.It core core dump size, in bytes 130*6ec54a57SEdward Tomasz Napierala.It rss resident set size, in bytes 131*6ec54a57SEdward Tomasz Napierala.It memlock locked memory, in bytes 132*6ec54a57SEdward Tomasz Napierala.It nproc number of processes 133*6ec54a57SEdward Tomasz Napierala.It nofile file descriptor table size 134*6ec54a57SEdward Tomasz Napierala.It sbsize memory consumed by socket buffers, in bytes 135*6ec54a57SEdward Tomasz Napierala.It vmem address space limit, in bytes 136*6ec54a57SEdward Tomasz Napierala.It npts number of PTYs 137*6ec54a57SEdward Tomasz Napierala.It swap swap usage, in bytes 138*6ec54a57SEdward Tomasz Napierala.It nthr number of threads 139*6ec54a57SEdward Tomasz Napierala.It msgqqueued number of queued SysV messages 140*6ec54a57SEdward Tomasz Napierala.It msgqsize SysV message queue size, in bytes 141*6ec54a57SEdward Tomasz Napierala.It nmsgq number of SysV message queues 142*6ec54a57SEdward Tomasz Napierala.It nsem number of SysV semaphores 143*6ec54a57SEdward Tomasz Napierala.It nsemop number of SysV semaphores modified in a single semop(2) call 144*6ec54a57SEdward Tomasz Napierala.It nshm number of SysV shared memory segments 145*6ec54a57SEdward Tomasz Napierala.It shmsize SysV shared memory size, in bytes 146*6ec54a57SEdward Tomasz Napierala.It wallclock wallclock time, in milliseconds 147*6ec54a57SEdward Tomasz Napierala.It pctcpu %cpu time 148*6ec54a57SEdward Tomasz Napierala.El 149*6ec54a57SEdward Tomasz Napierala.Pp 150*6ec54a57SEdward Tomasz Napierala.Sh ACTIONS 151*6ec54a57SEdward Tomasz Napierala.Bl -column -offset 3n "msgqqueued" 152*6ec54a57SEdward Tomasz Napierala.It deny deny the allocation; not supported for cpu and wallclock 153*6ec54a57SEdward Tomasz Napierala.It log log a warning to the console 154*6ec54a57SEdward Tomasz Napierala.It devctl send notification to 155*6ec54a57SEdward Tomasz Napierala.Xr devd 8 156*6ec54a57SEdward Tomasz Napierala.It sig* e.g. sigterm; send a signal to the offending process 157*6ec54a57SEdward Tomasz Napierala.El 158*6ec54a57SEdward Tomasz Napierala.Pp 159*6ec54a57SEdward Tomasz NapieralaSee 160*6ec54a57SEdward Tomasz Napierala.Xr signal 3 161*6ec54a57SEdward Tomasz Napieralafor a list of supported signals. 162*6ec54a57SEdward Tomasz Napierala.Pp 163*6ec54a57SEdward Tomasz NapieralaNot all actions are supported for all resources. 164*6ec54a57SEdward Tomasz NapieralaAttempt to add rule with action not supported by a given resouce will result 165*6ec54a57SEdward Tomasz Napieralain error. 166*6ec54a57SEdward Tomasz Napierala.Pp 167*6ec54a57SEdward Tomasz NapieralaNote that limiting RSS may kill the machine due to thrashing. 168*6ec54a57SEdward Tomasz Napierala.Pp 169*6ec54a57SEdward Tomasz Napierala.Sh EXIT STATUS 170*6ec54a57SEdward Tomasz Napierala.Ex -std 171*6ec54a57SEdward Tomasz Napierala.Sh EXAMPLES 172*6ec54a57SEdward Tomasz Napierala.Dl rctl -a user:joe:vmem:deny=1g 173*6ec54a57SEdward Tomasz Napierala.Pp 174*6ec54a57SEdward Tomasz NapieralaPrevent user "joe" from allocating more than 1GB of virtual memory. 175*6ec54a57SEdward Tomasz Napierala.Pp 176*6ec54a57SEdward Tomasz Napierala.Dl rctl -r : 177*6ec54a57SEdward Tomasz Napierala.Pp 178*6ec54a57SEdward Tomasz NapieralaRemove all RCTL rules. 179*6ec54a57SEdward Tomasz Napierala.Pp 180*6ec54a57SEdward Tomasz Napierala.Dl rctl -hu jail:5 181*6ec54a57SEdward Tomasz Napierala.Pp 182*6ec54a57SEdward Tomasz NapieralaDisplay resource usage information for jail with JID 5. 183*6ec54a57SEdward Tomasz Napierala.Pp 184*6ec54a57SEdward Tomasz Napierala.Dl rctl -l process:512 185*6ec54a57SEdward Tomasz Napierala.Pp 186*6ec54a57SEdward Tomasz NapieralaDisplay all the rules applicable to process with PID 512. 187*6ec54a57SEdward Tomasz Napierala.Sh SEE ALSO 188*6ec54a57SEdward Tomasz Napierala.Xr jailstat 8 , 189*6ec54a57SEdward Tomasz Napierala.Xr userstat 8 190*6ec54a57SEdward Tomasz Napierala.Sh HISTORY 191*6ec54a57SEdward Tomasz NapieralaThe 192*6ec54a57SEdward Tomasz Napierala.Nm 193*6ec54a57SEdward Tomasz Napieralacommand appeared in 194*6ec54a57SEdward Tomasz Napierala.Fx 9.0. 195*6ec54a57SEdward Tomasz Napierala.Sh AUTHORS 196*6ec54a57SEdward Tomasz Napierala.An -nosplit 197*6ec54a57SEdward Tomasz NapieralaThe 198*6ec54a57SEdward Tomasz Napierala.Nm 199*6ec54a57SEdward Tomasz Napieralacommand was written by 200*6ec54a57SEdward Tomasz Napierala.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . 201