xref: /freebsd/lib/libc/gen/sysctl.3 (revision 5129159789cc9d7bc514e4546b88e3427695002d)
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	internet values	yes
457.El
458.Pp
459.Bl -tag -width "123456"
460.It Li PF_ROUTE
461Return the entire routing table or a subset of it.
462The data is returned as a sequence of routing messages (see
463.Xr route 4
464for the header file, format and meaning).
465The length of each message is contained in the message header.
466.Pp
467The third level name is a protocol number, which is currently always 0.
468The fourth level name is an address family, which may be set to 0 to
469select all address families.
470The fifth and sixth level names are as follows:
471.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
472.It Pa Fifth level name	Sixth level is:
473.It NET\_RT\_FLAGS	rtflags
474.It NET\_RT\_DUMP	None
475.It NET\_RT\_IFLIST	None
476.El
477.It Li PF_INET
478Get or set various global information about the internet protocols.
479The third level name is the protocol.
480The fourth level name is the variable name.
481The currently defined protocols and names are:
482.ne 1i
483.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX
484.It Pa Protocol	Variable	Type	Changeable
485.It icmp	bmcastecho	integer	yes
486.It icmp	maskrepl	integer	yes
487.It ip	forwarding	integer	yes
488.It ip	redirect	integer	yes
489.It ip	ttl	integer	yes
490.It udp	checksum	integer	yes
491.El
492.Pp
493The variables are as follows:
494.Bl -tag -width "123456"
495.It Li icmp.bmcastecho
496Returns 1 if an ICMP echo request to a broadcast or multicast address is
497to be answered.
498.It Li icmp.maskrepl
499Returns 1 if ICMP network mask requests are to be answered.
500.It Li ip.forwarding
501Returns 1 when IP forwarding is enabled for the host,
502meaning that the host is acting as a router.
503.It Li ip.redirect
504Returns 1 when ICMP redirects may be sent by the host.
505This option is ignored unless the host is routing IP packets,
506and should normally be enabled on all systems.
507.It Li ip.ttl
508The maximum time-to-live (hop count) value for an IP packet sourced by
509the system.
510This value applies to normal transport protocols, not to ICMP.
511.It Li udp.checksum
512Returns 1 when UDP checksums are being computed and checked.
513Disabling UDP checksums is strongly discouraged.
514.El
515.Sh CTL_USER
516The string and integer information available for the CTL_USER level
517is detailed below.
518The changeable column shows whether a process with appropriate
519privilege may change the value.
520.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
521.It Sy Pa Second level name	Type	Changeable
522.It USER\_BC\_BASE\_MAX	integer	no
523.It USER\_BC\_DIM\_MAX	integer	no
524.It USER\_BC\_SCALE\_MAX	integer	no
525.It USER\_BC\_STRING\_MAX	integer	no
526.It USER\_COLL\_WEIGHTS\_MAX	integer	no
527.It USER\_CS\_PATH	string	no
528.It USER\_EXPR\_NEST\_MAX	integer	no
529.It USER\_LINE\_MAX	integer	no
530.It USER\_POSIX2\_CHAR\_TERM	integer	no
531.It USER\_POSIX2\_C\_BIND	integer	no
532.It USER\_POSIX2\_C\_DEV	integer	no
533.It USER\_POSIX2\_FORT\_DEV	integer	no
534.It USER\_POSIX2\_FORT\_RUN	integer	no
535.It USER\_POSIX2\_LOCALEDEF	integer	no
536.It USER\_POSIX2\_SW\_DEV	integer	no
537.It USER\_POSIX2\_UPE	integer	no
538.It USER\_POSIX2\_VERSION	integer	no
539.It USER\_RE\_DUP\_MAX	integer	no
540.It USER\_STREAM\_MAX	integer	no
541.It USER\_TZNAME\_MAX	integer	no
542.El
543.Bl -tag -width "123456"
544.Pp
545.It Li USER_BC_BASE_MAX
546The maximum ibase/obase values in the
547.Xr bc 1
548utility.
549.It Li USER_BC_DIM_MAX
550The maximum array size in the
551.Xr bc 1
552utility.
553.It Li USER_BC_SCALE_MAX
554The maximum scale value in the
555.Xr bc 1
556utility.
557.It Li USER_BC_STRING_MAX
558The maximum string length in the
559.Xr bc 1
560utility.
561.It Li USER_COLL_WEIGHTS_MAX
562The maximum number of weights that can be assigned to any entry of
563the LC_COLLATE order keyword in the locale definition file.
564.It Li USER_CS_PATH
565Return a value for the
566.Ev PATH
567environment variable that finds all the standard utilities.
568.It Li USER_EXPR_NEST_MAX
569The maximum number of expressions that can be nested within
570parenthesis by the
571.Xr expr 1
572utility.
573.It Li USER_LINE_MAX
574The maximum length in bytes of a text-processing utility's input
575line.
576.It Li USER_POSIX2_CHAR_TERM
577Return 1 if the system supports at least one terminal type capable of
578all operations described in POSIX 1003.2, otherwise 0.
579.It Li USER_POSIX2_C_BIND
580Return 1 if the system's C-language development facilities support the
581C-Language Bindings Option, otherwise 0.
582.It Li USER_POSIX2_C_DEV
583Return 1 if the system supports the C-Language Development Utilities Option,
584otherwise 0.
585.It Li USER_POSIX2_FORT_DEV
586Return 1 if the system supports the FORTRAN Development Utilities Option,
587otherwise 0.
588.It Li USER_POSIX2_FORT_RUN
589Return 1 if the system supports the FORTRAN Runtime Utilities Option,
590otherwise 0.
591.It Li USER_POSIX2_LOCALEDEF
592Return 1 if the system supports the creation of locales, otherwise 0.
593.It Li USER_POSIX2_SW_DEV
594Return 1 if the system supports the Software Development Utilities Option,
595otherwise 0.
596.It Li USER_POSIX2_UPE
597Return 1 if the system supports the User Portability Utilities Option,
598otherwise 0.
599.It Li USER_POSIX2_VERSION
600The version of POSIX 1003.2 with which the system attempts to comply.
601.It Li USER_RE_DUP_MAX
602The maximum number of repeated occurrences of a regular expression
603permitted when using interval notation.
604.ne 1i
605.It Li USER_STREAM_MAX
606The minimum maximum number of streams that a process may have open
607at any one time.
608.It Li USER_TZNAME_MAX
609The minimum maximum number of types supported for the name of a
610timezone.
611.El
612.Sh CTL_VM
613The string and integer information available for the CTL_VM level
614is detailed below.
615The changeable column shows whether a process with appropriate
616privilege may change the value.
617.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
618.It Sy Pa Second level name	Type	Changeable
619.It VM\_LOADAVG	struct loadavg	no
620.It VM\_METER	struct vmtotal	no
621.It VM\_PAGEOUT\_ALGORITHM	integer	yes
622.It VM\_SWAPPING\_ENABLED	integer	maybe
623.It VM\_V\_CACHE\_MAX	integer	yes
624.It VM\_V\_CACHE\_MIN	integer	yes
625.It VM\_V\_FREE\_MIN	integer	yes
626.It VM\_V\_FREE\_RESERVED	integer	yes
627.It VM\_V\_FREE\_TARGET	integer	yes
628.It VM\_V\_INACTIVE\_TARGET	integer	yes
629.It VM\_V\_PAGEOUT\_FREE\_MIN	integer	yes
630.El
631.Pp
632.Bl -tag -width "123456"
633.It Li VM_LOADAVG
634Return the load average history.
635The returned data consists of a
636.Va struct loadavg .
637.It Li VM_METER
638Return the system wide virtual memory statistics.
639The returned data consists of a
640.Va struct vmtotal .
641.It Li VM_PAGEOUT_ALGORITHM
6420 if the statistics-based page management algorithm is in use
643or 1 if the near-LRU algorithm is in use.
644.It Li VM_SWAPPING_ENABLED
6451 if process swapping is enabled or 0 if disabled.  This variable is
646permanently set to 0 if the kernel was built with swapping disabled.
647.It Li VM_V_CACHE_MAX
648Maximum desired size of the cache queue.
649.It Li VM_V_CACHE_MIN
650Minimum desired size of the cache queue.  If the cache queue size
651falls very far below this value, the pageout daemon is awakened.
652.It Li VM_V_FREE_MIN
653Minimum amount of memory (cache memory plus free memory)
654required to be available before a process waiting on memory will be
655awakened.
656.It Li VM_V_FREE_RESERVED
657Processes will awaken the pageout daemon and wait for memory if the
658number of free and cached pages drops below this value.
659.It Li VM_V_FREE_TARGET
660The total amount of free memory (including cache memory) that the
661pageout daemon tries to maintain.
662.It Li VM_V_INACTIVE_TARGET
663The desired number of inactive pages that the pageout daemon should
664achieve when it runs.  Inactive pages can be quickly inserted into
665process address space when needed.
666.It Li VM_V_PAGEOUT_FREE_MIN
667If the amount of free and cache memory falls below this value, the
668pageout daemon will enter "memory conserving mode" to avoid deadlock.
669.El
670.Sh RETURN VALUES
671.Fn sysctl
672and
673.Fn sysctlbyname
674return 0 when successful.
675Otherwise \-1 is returned and
676.Va errno
677is set appropriately.
678.Sh ERRORS
679The following errors may be reported:
680.Bl -tag -width Er
681.It Bq Er EFAULT
682The buffer
683.Fa name ,
684.Fa oldp ,
685.Fa newp ,
686or length pointer
687.Fa oldlenp
688contains an invalid address.
689.It Bq Er EINVAL
690The
691.Fa name
692array is less than two or greater than CTL_MAXNAME.
693.It Bq Er EINVAL
694A non-null
695.Fa newp
696is given and its specified length in
697.Fa newlen
698is too large or too small.
699.It Bq Er ENOMEM
700The length pointed to by
701.Fa oldlenp
702is too short to hold the requested value.
703.It Bq Er ENOTDIR
704The
705.Fa name
706array specifies an intermediate rather than terminal name.
707.It Bq Er EISDIR
708The
709.Fa name
710array specifies a terminal name, but the actual name is not terminal.
711.It Bq Er EOPNOTSUPP
712The
713.Fa name
714array specifies a value that is unknown.
715.It Bq Er EPERM
716An attempt is made to set a read-only value.
717.It Bq Er EPERM
718A process without appropriate privilege attempts to set a value.
719.El
720.Sh FILES
721.Bl -tag -width <netinet/icmpXvar.h> -compact
722.It Pa <sys/sysctl.h>
723definitions for top level identifiers, second level kernel and hardware
724identifiers, and user level identifiers
725.It Pa <sys/socket.h>
726definitions for second level network identifiers
727.It Pa <sys/gmon.h>
728definitions for third level profiling identifiers
729.It Pa <vm/vm_param.h>
730definitions for second level virtual memory identifiers
731.It Pa <netinet/in.h>
732definitions for third level Internet identifiers and
733fourth level IP identifiers
734.It Pa <netinet/icmp_var.h>
735definitions for fourth level ICMP identifiers
736.It Pa <netinet/udp_var.h>
737definitions for fourth level UDP identifiers
738.El
739.Sh SEE ALSO
740.Xr sysconf 3 ,
741.Xr sysctl 8
742.Sh HISTORY
743The
744.Fn sysctl
745function first appeared in
746.Bx 4.4 .
747