1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 33.\" $FreeBSD$ 34.\" 35.Dd May 9, 1995 36.Dt SYSCTL 3 37.Os 38.Sh NAME 39.Nm sysctl , 40.Nm sysctlbyname 41.Nd get or set system information 42.Sh LIBRARY 43.Lb libc 44.Sh SYNOPSIS 45.Fd #include <sys/types.h> 46.Fd #include <sys/sysctl.h> 47.Ft int 48.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" 49.Ft int 50.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" 51.Sh DESCRIPTION 52The 53.Fn sysctl 54function retrieves system information and allows processes with 55appropriate privileges to set system information. 56The information available from 57.Fn sysctl 58consists of integers, strings, and tables. 59Information may be retrieved and set from the command interface 60using the 61.Xr sysctl 8 62utility. 63.Pp 64Unless explicitly noted below, 65.Fn sysctl 66returns a consistent snapshot of the data requested. 67Consistency is obtained by locking the destination 68buffer into memory so that the data may be copied out without blocking. 69Calls to 70.Fn sysctl 71are serialized to avoid deadlock. 72.Pp 73The state is described using a ``Management Information Base'' (MIB) 74style name, listed in 75.Fa name , 76which is a 77.Fa namelen 78length array of integers. 79.Pp 80The 81.Fn sysctlbyname 82function accepts an ASCII representation of the name and internally 83looks up the integer name vector. Apart from that, it behaves the same 84as the standard 85.Fn sysctl 86function. 87.Pp 88The information is copied into the buffer specified by 89.Fa oldp . 90The size of the buffer is given by the location specified by 91.Fa oldlenp 92before the call, 93and that location gives the amount of data copied after a successful call 94and after a call that returns with the error code 95.Er ENOMEM . 96If the amount of data available is greater 97than the size of the buffer supplied, 98the call supplies as much data as fits in the buffer provided 99and returns with the error code 100.Er ENOMEM . 101If the old value is not desired, 102.Fa oldp 103and 104.Fa oldlenp 105should be set to NULL. 106.Pp 107The size of the available data can be determined by calling 108.Fn sysctl 109with a NULL parameter for 110.Fa oldp . 111The size of the available data will be returned in the location pointed to by 112.Fa oldlenp . 113For some operations, the amount of space may change often. 114For these operations, 115the system attempts to round up so that the returned size is 116large enough for a call to return the data shortly thereafter. 117.Pp 118To set a new value, 119.Fa newp 120is set to point to a buffer of length 121.Fa newlen 122from which the requested value is to be taken. 123If a new value is not to be set, 124.Fa newp 125should be set to NULL and 126.Fa newlen 127set to 0. 128.Pp 129The top level names are defined with a CTL_ prefix in 130.Aq Pa sys/sysctl.h , 131and are as follows. 132The next and subsequent levels down are found in the include files 133listed here, and described in separate sections below. 134.Pp 135.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent 136.It Sy Pa Name Next level names Description 137.It CTL\_DEBUG sys/sysctl.h Debugging 138.It CTL\_VFS sys/mount.h Filesystem 139.It CTL\_HW sys/sysctl.h Generic CPU, I/O 140.It CTL\_KERN sys/sysctl.h High kernel limits 141.It CTL\_MACHDEP sys/sysctl.h Machine dependent 142.It CTL\_NET sys/socket.h Networking 143.It CTL\_USER sys/sysctl.h User-level 144.It CTL\_VM vm/vm_param.h Virtual memory 145.El 146.Pp 147For example, the following retrieves the maximum number of processes allowed 148in the system: 149.Pp 150.Bd -literal -offset indent -compact 151int mib[2], maxproc; 152size_t len; 153 154mib[0] = CTL_KERN; 155mib[1] = KERN_MAXPROC; 156len = sizeof(maxproc); 157sysctl(mib, 2, &maxproc, &len, NULL, 0); 158.Ed 159.Pp 160To retrieve the standard search path for the system utilities: 161.Pp 162.Bd -literal -offset indent -compact 163int mib[2]; 164size_t len; 165char *p; 166 167mib[0] = CTL_USER; 168mib[1] = USER_CS_PATH; 169sysctl(mib, 2, NULL, &len, NULL, 0); 170p = malloc(len); 171sysctl(mib, 2, p, &len, NULL, 0); 172.Ed 173.Ss CTL_DEBUG 174The debugging variables vary from system to system. 175A debugging variable may be added or deleted without need to recompile 176.Fn sysctl 177to know about it. 178Each time it runs, 179.Fn sysctl 180gets the list of debugging variables from the kernel and 181displays their current values. 182The system defines twenty 183.Ns ( Va struct ctldebug ) 184variables named 185.Nm debug0 186through 187.Nm debug19 . 188They are declared as separate variables so that they can be 189individually initialized at the location of their associated variable. 190The loader prevents multiple use of the same variable by issuing errors 191if a variable is initialized in more than one place. 192For example, to export the variable 193.Nm dospecialcheck 194as a debugging variable, the following declaration would be used: 195.Bd -literal -offset indent -compact 196int dospecialcheck = 1; 197struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck }; 198.Ed 199.Ss CTL_VFS 200A distinguished second level name, VFS_GENERIC, 201is used to get general information about all filesystems. 202One of its third level identifiers is VFS_MAXTYPENUM 203that gives the highest valid filesystem type number. 204Its other third level identifier is VFS_CONF that 205returns configuration information about the filesystem 206type given as a fourth level identifier (see 207.Xr getvfsbyname 3 208as an example of its use). 209The remaining second level identifiers are the 210filesystem type number returned by a 211.Xr statfs 2 212call or from VFS_CONF. 213The third level identifiers available for each filesystem 214are given in the header file that defines the mount 215argument structure for that filesystem. 216.Ss CTL_HW 217The string and integer information available for the CTL_HW level 218is detailed below. 219The changeable column shows whether a process with appropriate 220privilege may change the value. 221.Bl -column "Second level nameXXXXXX" integerXXX -offset indent 222.It Sy Pa Second level name Type Changeable 223.It HW\_MACHINE string no 224.It HW\_MODEL string no 225.It HW\_NCPU integer no 226.It HW\_BYTEORDER integer no 227.It HW\_PHYSMEM integer no 228.It HW\_USERMEM integer no 229.It HW\_PAGESIZE integer no 230.It HW\_FLOATINGPOINT integer no 231.It HW\_MACHINE\_ARCH string no 232.\".It HW\_DISKNAMES integer no 233.\".It HW\_DISKSTATS integer no 234.El 235.Pp 236.Bl -tag -width "123456" 237.It Li HW_MACHINE 238The machine class. 239.It Li HW_MODEL 240The machine model 241.It Li HW_NCPU 242The number of cpus. 243.It Li HW_BYTEORDER 244The byteorder (4,321, or 1,234). 245.It Li HW_PHYSMEM 246The bytes of physical memory. 247.It Li HW_USERMEM 248The bytes of non-kernel memory. 249.It Li HW_PAGESIZE 250The software page size. 251.It Li HW_FLOATINGPOINT 252Nonzero if the floating point support is in hardware. 253.It Li HW_MACHINE_ARCH 254The machine dependent architecture type. 255.\".It Fa HW_DISKNAMES 256.\".It Fa HW_DISKSTATS 257.El 258.Ss CTL_KERN 259The string and integer information available for the CTL_KERN level 260is detailed below. 261The changeable column shows whether a process with appropriate 262privilege may change the value. 263The types of data currently available are process information, 264system vnodes, the open file entries, routing table entries, 265virtual memory statistics, load average history, and clock rate 266information. 267.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent 268.It Sy Pa Second level name Type Changeable 269.It KERN\_ARGMAX integer no 270.It KERN\_BOOTFILE string yes 271.It KERN\_BOOTTIME struct timeval no 272.It KERN\_CLOCKRATE struct clockinfo no 273.It KERN\_FILE struct file no 274.It KERN\_HOSTID integer yes 275.It KERN\_HOSTNAME string yes 276.It KERN\_JOB\_CONTROL integer no 277.It KERN\_MAXFILES integer yes 278.It KERN\_MAXFILESPERPROC integer yes 279.It KERN\_MAXPROC integer no 280.It KERN\_MAXPROCPERUID integer yes 281.It KERN\_MAXVNODES integer yes 282.It KERN\_NGROUPS integer no 283.It KERN\_NISDOMAINNAME string yes 284.It KERN\_OSRELDATE integer no 285.It KERN\_OSRELEASE string no 286.It KERN\_OSREV integer no 287.It KERN\_OSTYPE string no 288.It KERN\_POSIX1 integer no 289.It KERN\_PROC struct proc no 290.It KERN\_PROF node not applicable 291.It KERN\_QUANTUM integer yes 292.It KERN\_SAVED\_IDS integer no 293.It KERN\_SECURELVL integer raise only 294.It KERN\_UPDATEINTERVAL integer no 295.It KERN\_VERSION string no 296.It KERN\_VNODE struct vnode no 297.El 298.Pp 299.Bl -tag -width "123456" 300.It Li KERN_ARGMAX 301The maximum bytes of argument to 302.Xr execve 2 . 303.It Li KERN_BOOTFILE 304The full pathname of the file from which the kernel was loaded. 305.It Li KERN_BOOTTIME 306A 307.Va struct timeval 308structure is returned. 309This structure contains the time that the system was booted. 310.It Li KERN_CLOCKRATE 311A 312.Va struct clockinfo 313structure is returned. 314This structure contains the clock, statistics clock and profiling clock 315frequencies, the number of micro-seconds per hz tick and the skew rate. 316.It Li KERN_FILE 317Return the entire file table. 318The returned data consists of a single 319.Va struct filehead 320followed by an array of 321.Va struct file , 322whose size depends on the current number of such objects in the system. 323.It Li KERN_HOSTID 324Get or set the host id. 325.It Li KERN_HOSTNAME 326Get or set the hostname. 327.It Li KERN_JOB_CONTROL 328Return 1 if job control is available on this system, otherwise 0. 329.It Li KERN_MAXFILES 330The maximum number of files that may be open in the system. 331.It Li KERN_MAXFILESPERPROC 332The maximum number of files that may be open for a single process. 333This limit only applies to processes with an effective uid of nonzero 334at the time of the open request. 335Files that have already been opened are not affected if the limit 336or the effective uid is changed. 337.It Li KERN_MAXPROC 338The maximum number of concurrent processes the system will allow. 339.It Li KERN_MAXPROCPERUID 340The maximum number of concurrent processes the system will allow 341for a single effective uid. 342This limit only applies to processes with an effective uid of nonzero 343at the time of a fork request. 344Processes that have already been started are not affected if the limit 345is changed. 346.It Li KERN_MAXVNODES 347The maximum number of vnodes available on the system. 348.It Li KERN_NGROUPS 349The maximum number of supplemental groups. 350.It Li KERN_NISDOMAINNAME 351The name of the current YP/NIS domain. 352.It Li KERN_OSRELDATE 353The system release date in YYYYMM format 354(January 1996 is encoded as 199601). 355.It Li KERN_OSRELEASE 356The system release string. 357.It Li KERN_OSREV 358The system revision string. 359.It Li KERN_OSTYPE 360The system type string. 361.It Li KERN_POSIX1 362The version of ISO/IEC 9945 (POSIX 1003.1) with which the system 363attempts to comply. 364.It Li KERN_PROC 365Return the entire process table, or a subset of it. 366An array of pairs of 367.Va struct proc 368followed by corresponding 369.Va struct eproc 370structures is returned, 371whose size depends on the current number of such objects in the system. 372The third and fourth level names are as follows: 373.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent 374.It Pa Third level name Fourth level is: 375.It KERN\_PROC\_ALL None 376.It KERN\_PROC\_PID A process ID 377.It KERN\_PROC\_PGRP A process group 378.It KERN\_PROC\_TTY A tty device 379.It KERN\_PROC\_UID A user ID 380.It KERN\_PROC\_RUID A real user ID 381.El 382.Pp 383If the third level name is KERN_PROC_ARGS then the command line argument 384array is returned in a flattened form, i.e. zero-terminated arguments 385follow each other. 386The total size of array is returned. 387It is also possible for a process to set its own process title this way. 388.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent 389.It Pa Third level name Fourth level is: 390.It KERN\_PROC\_ARGS A process ID 391.El 392.It Li KERN_PROF 393Return profiling information about the kernel. 394If the kernel is not compiled for profiling, 395attempts to retrieve any of the KERN_PROF values will 396fail with 397.Er EOPNOTSUPP . 398The third level names for the string and integer profiling information 399is detailed below. 400The changeable column shows whether a process with appropriate 401privilege may change the value. 402.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent 403.It Sy Pa Third level name Type Changeable 404.It GPROF\_STATE integer yes 405.It GPROF\_COUNT u_short[\|] yes 406.It GPROF\_FROMS u_short[\|] yes 407.It GPROF\_TOS struct tostruct yes 408.It GPROF\_GMONPARAM struct gmonparam no 409.El 410.Pp 411The variables are as follows: 412.Bl -tag -width "123456" 413.It Li GPROF_STATE 414Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling 415is running or stopped. 416.It Li GPROF_COUNT 417Array of statistical program counter counts. 418.It Li GPROF_FROMS 419Array indexed by program counter of call-from points. 420.It Li GPROF_TOS 421Array of 422.Va struct tostruct 423describing destination of calls and their counts. 424.It Li GPROF_GMONPARAM 425Structure giving the sizes of the above arrays. 426.El 427.It Li KERN_QUANTUM 428The maximum period of time, in microseconds, for which a process is allowed 429to run without being preempted if other processes are in the run queue. 430.It Li KERN_SAVED_IDS 431Returns 1 if saved set-group and saved set-user ID is available. 432.It Li KERN_SECURELVL 433The system security level. 434This level may be raised by processes with appropriate privilege. 435It may not be lowered. 436.It Li KERN_VERSION 437The system version string. 438.It Li KERN_VNODE 439Return the entire vnode table. 440Note, the vnode table is not necessarily a consistent snapshot of 441the system. 442The returned data consists of an array whose size depends on the 443current number of such objects in the system. 444Each element of the array contains the kernel address of a vnode 445.Va struct vnode * 446followed by the vnode itself 447.Va struct vnode . 448.El 449.Ss CTL_MACHDEP 450The set of variables defined is architecture dependent. 451The following variables are defined for the i386 architecture. 452.Bl -column "CONSOLE_DEVICEXXX" "struct bootinfoXXX" -offset indent 453.It Sy Pa Second level name Type Changeable 454.It Li CPU_CONSDEV dev_t no 455.It Li CPU_ADJKERNTZ int yes 456.It Li CPU_DISRTCSET int yes 457.It Li CPU_BOOTINFO struct bootinfo no 458.It Li CPU_WALLCLOCK int yes 459.El 460.Ss CTL_NET 461The string and integer information available for the CTL_NET level 462is detailed below. 463The changeable column shows whether a process with appropriate 464privilege may change the value. 465.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent 466.It Sy Pa Second level name Type Changeable 467.It PF\_ROUTE routing messages no 468.It PF\_INET IPv4 values yes 469.It PF\_INET6 IPv6 values yes 470.El 471.Pp 472.Bl -tag -width "123456" 473.It Li PF_ROUTE 474Return the entire routing table or a subset of it. 475The data is returned as a sequence of routing messages (see 476.Xr route 4 477for the header file, format and meaning). 478The length of each message is contained in the message header. 479.Pp 480The third level name is a protocol number, which is currently always 0. 481The fourth level name is an address family, which may be set to 0 to 482select all address families. 483The fifth and sixth level names are as follows: 484.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent 485.It Pa Fifth level name Sixth level is: 486.It NET\_RT\_FLAGS rtflags 487.It NET\_RT\_DUMP None 488.It NET\_RT\_IFLIST None 489.El 490.It Li PF_INET 491Get or set various global information about the IPv4 492.Pq Internet Protocol version 4 . 493The third level name is the protocol. 494The fourth level name is the variable name. 495The currently defined protocols and names are: 496.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX 497.It Pa Protocol Variable Type Changeable 498.It icmp bmcastecho integer yes 499.It icmp maskrepl integer yes 500.It ip forwarding integer yes 501.It ip redirect integer yes 502.It ip ttl integer yes 503.It udp checksum integer yes 504.El 505.Pp 506The variables are as follows: 507.Bl -tag -width "123456" 508.It Li icmp.bmcastecho 509Returns 1 if an ICMP echo request to a broadcast or multicast address is 510to be answered. 511.It Li icmp.maskrepl 512Returns 1 if ICMP network mask requests are to be answered. 513.It Li ip.forwarding 514Returns 1 when IP forwarding is enabled for the host, 515meaning that the host is acting as a router. 516.It Li ip.redirect 517Returns 1 when ICMP redirects may be sent by the host. 518This option is ignored unless the host is routing IP packets, 519and should normally be enabled on all systems. 520.It Li ip.ttl 521The maximum time-to-live (hop count) value for an IP packet sourced by 522the system. 523This value applies to normal transport protocols, not to ICMP. 524.It Li udp.checksum 525Returns 1 when UDP checksums are being computed and checked. 526Disabling UDP checksums is strongly discouraged. 527.Pp 528For variables net.inet.*.ipsec, please refer to 529.Xr ipsec 4 . 530.El 531.It Li PF_INET6 532Get or set various global information about the IPv6 533.Pq Internet Protocol version 6 . 534The third level name is the protocol. 535The fourth level name is the variable name. 536.Pp 537For variables net.inet6.* please refer to 538.Xr inet6 4 . 539For variables net.inet6.*.ipsec6, please refer to 540.Xr ipsec 4 . 541.El 542.Ss CTL_USER 543The string and integer information available for the CTL_USER level 544is detailed below. 545The changeable column shows whether a process with appropriate 546privilege may change the value. 547.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent 548.It Sy Pa Second level name Type Changeable 549.It USER\_BC\_BASE\_MAX integer no 550.It USER\_BC\_DIM\_MAX integer no 551.It USER\_BC\_SCALE\_MAX integer no 552.It USER\_BC\_STRING\_MAX integer no 553.It USER\_COLL\_WEIGHTS\_MAX integer no 554.It USER\_CS\_PATH string no 555.It USER\_EXPR\_NEST\_MAX integer no 556.It USER\_LINE\_MAX integer no 557.It USER\_POSIX2\_CHAR\_TERM integer no 558.It USER\_POSIX2\_C\_BIND integer no 559.It USER\_POSIX2\_C\_DEV integer no 560.It USER\_POSIX2\_FORT\_DEV integer no 561.It USER\_POSIX2\_FORT\_RUN integer no 562.It USER\_POSIX2\_LOCALEDEF integer no 563.It USER\_POSIX2\_SW\_DEV integer no 564.It USER\_POSIX2\_UPE integer no 565.It USER\_POSIX2\_VERSION integer no 566.It USER\_RE\_DUP\_MAX integer no 567.It USER\_STREAM\_MAX integer no 568.It USER\_TZNAME\_MAX integer no 569.El 570.Bl -tag -width "123456" 571.Pp 572.It Li USER_BC_BASE_MAX 573The maximum ibase/obase values in the 574.Xr bc 1 575utility. 576.It Li USER_BC_DIM_MAX 577The maximum array size in the 578.Xr bc 1 579utility. 580.It Li USER_BC_SCALE_MAX 581The maximum scale value in the 582.Xr bc 1 583utility. 584.It Li USER_BC_STRING_MAX 585The maximum string length in the 586.Xr bc 1 587utility. 588.It Li USER_COLL_WEIGHTS_MAX 589The maximum number of weights that can be assigned to any entry of 590the LC_COLLATE order keyword in the locale definition file. 591.It Li USER_CS_PATH 592Return a value for the 593.Ev PATH 594environment variable that finds all the standard utilities. 595.It Li USER_EXPR_NEST_MAX 596The maximum number of expressions that can be nested within 597parenthesis by the 598.Xr expr 1 599utility. 600.It Li USER_LINE_MAX 601The maximum length in bytes of a text-processing utility's input 602line. 603.It Li USER_POSIX2_CHAR_TERM 604Return 1 if the system supports at least one terminal type capable of 605all operations described in POSIX 1003.2, otherwise 0. 606.It Li USER_POSIX2_C_BIND 607Return 1 if the system's C-language development facilities support the 608C-Language Bindings Option, otherwise 0. 609.It Li USER_POSIX2_C_DEV 610Return 1 if the system supports the C-Language Development Utilities Option, 611otherwise 0. 612.It Li USER_POSIX2_FORT_DEV 613Return 1 if the system supports the FORTRAN Development Utilities Option, 614otherwise 0. 615.It Li USER_POSIX2_FORT_RUN 616Return 1 if the system supports the FORTRAN Runtime Utilities Option, 617otherwise 0. 618.It Li USER_POSIX2_LOCALEDEF 619Return 1 if the system supports the creation of locales, otherwise 0. 620.It Li USER_POSIX2_SW_DEV 621Return 1 if the system supports the Software Development Utilities Option, 622otherwise 0. 623.It Li USER_POSIX2_UPE 624Return 1 if the system supports the User Portability Utilities Option, 625otherwise 0. 626.It Li USER_POSIX2_VERSION 627The version of POSIX 1003.2 with which the system attempts to comply. 628.It Li USER_RE_DUP_MAX 629The maximum number of repeated occurrences of a regular expression 630permitted when using interval notation. 631.It Li USER_STREAM_MAX 632The minimum maximum number of streams that a process may have open 633at any one time. 634.It Li USER_TZNAME_MAX 635The minimum maximum number of types supported for the name of a 636timezone. 637.El 638.Ss CTL_VM 639The string and integer information available for the CTL_VM level 640is detailed below. 641The changeable column shows whether a process with appropriate 642privilege may change the value. 643.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent 644.It Sy Pa Second level name Type Changeable 645.It VM\_LOADAVG struct loadavg no 646.It VM\_METER struct vmtotal no 647.It VM\_PAGEOUT\_ALGORITHM integer yes 648.It VM\_SWAPPING\_ENABLED integer maybe 649.It VM\_V\_CACHE\_MAX integer yes 650.It VM\_V\_CACHE\_MIN integer yes 651.It VM\_V\_FREE\_MIN integer yes 652.It VM\_V\_FREE\_RESERVED integer yes 653.It VM\_V\_FREE\_TARGET integer yes 654.It VM\_V\_INACTIVE\_TARGET integer yes 655.It VM\_V\_PAGEOUT\_FREE\_MIN integer yes 656.El 657.Pp 658.Bl -tag -width "123456" 659.It Li VM_LOADAVG 660Return the load average history. 661The returned data consists of a 662.Va struct loadavg . 663.It Li VM_METER 664Return the system wide virtual memory statistics. 665The returned data consists of a 666.Va struct vmtotal . 667.It Li VM_PAGEOUT_ALGORITHM 6680 if the statistics-based page management algorithm is in use 669or 1 if the near-LRU algorithm is in use. 670.It Li VM_SWAPPING_ENABLED 6711 if process swapping is enabled or 0 if disabled. This variable is 672permanently set to 0 if the kernel was built with swapping disabled. 673.It Li VM_V_CACHE_MAX 674Maximum desired size of the cache queue. 675.It Li VM_V_CACHE_MIN 676Minimum desired size of the cache queue. If the cache queue size 677falls very far below this value, the pageout daemon is awakened. 678.It Li VM_V_FREE_MIN 679Minimum amount of memory (cache memory plus free memory) 680required to be available before a process waiting on memory will be 681awakened. 682.It Li VM_V_FREE_RESERVED 683Processes will awaken the pageout daemon and wait for memory if the 684number of free and cached pages drops below this value. 685.It Li VM_V_FREE_TARGET 686The total amount of free memory (including cache memory) that the 687pageout daemon tries to maintain. 688.It Li VM_V_INACTIVE_TARGET 689The desired number of inactive pages that the pageout daemon should 690achieve when it runs. Inactive pages can be quickly inserted into 691process address space when needed. 692.It Li VM_V_PAGEOUT_FREE_MIN 693If the amount of free and cache memory falls below this value, the 694pageout daemon will enter "memory conserving mode" to avoid deadlock. 695.El 696.Sh RETURN VALUES 697.Fn sysctl 698and 699.Fn sysctlbyname 700return 0 when successful. 701Otherwise \-1 is returned and 702.Va errno 703is set appropriately. 704.Sh ERRORS 705The following errors may be reported: 706.Bl -tag -width Er 707.It Bq Er EFAULT 708The buffer 709.Fa name , 710.Fa oldp , 711.Fa newp , 712or length pointer 713.Fa oldlenp 714contains an invalid address. 715.It Bq Er EINVAL 716The 717.Fa name 718array is less than two or greater than CTL_MAXNAME. 719.It Bq Er EINVAL 720A non-null 721.Fa newp 722is given and its specified length in 723.Fa newlen 724is too large or too small. 725.It Bq Er ENOMEM 726The length pointed to by 727.Fa oldlenp 728is too short to hold the requested value. 729.It Bq Er ENOTDIR 730The 731.Fa name 732array specifies an intermediate rather than terminal name. 733.It Bq Er EISDIR 734The 735.Fa name 736array specifies a terminal name, but the actual name is not terminal. 737.It Bq Er EOPNOTSUPP 738The 739.Fa name 740array specifies a value that is unknown. 741.It Bq Er EPERM 742An attempt is made to set a read-only value. 743.It Bq Er EPERM 744A process without appropriate privilege attempts to set a value. 745.El 746.Sh FILES 747.Bl -tag -width <netinet/icmpXvar.h> -compact 748.It Aq Pa sys/sysctl.h 749definitions for top level identifiers, second level kernel and hardware 750identifiers, and user level identifiers 751.It Aq Pa sys/socket.h 752definitions for second level network identifiers 753.It Aq Pa sys/gmon.h 754definitions for third level profiling identifiers 755.It Aq Pa vm/vm_param.h 756definitions for second level virtual memory identifiers 757.It Aq Pa netinet/in.h 758definitions for third level IPv4/IPv6 identifiers and 759fourth level IPv4/v6 identifiers 760.It Aq Pa netinet/icmp_var.h 761definitions for fourth level ICMP identifiers 762.It Aq Pa netinet/icmp6.h 763definitions for fourth level ICMPv6 identifiers 764.It Aq Pa netinet/udp_var.h 765definitions for fourth level UDP identifiers 766.El 767.Sh SEE ALSO 768.Xr sysconf 3 , 769.Xr sysctl 8 770.Sh HISTORY 771The 772.Fn sysctl 773function first appeared in 774.Bx 4.4 . 775