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