sysctl.3   [plain text]


.\" Copyright (c) 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
.\" $FreeBSD$
.\"
.Dd May 17, 2013
.Dt SYSCTL 3
.Os
.Sh NAME
.Nm sysctl ,
.Nm sysctlbyname ,
.Nm sysctlnametomib
.Nd get or set system information
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/types.h
.In sys/sysctl.h
.Ft int
.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
.Ft int
.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
.Ft int
.Fn sysctlnametomib "const char *name" "int *mibp" "size_t *sizep"
.Sh DESCRIPTION
The
.Fn sysctl
function retrieves system information and allows processes with
appropriate privileges to set system information.
The information available from
.Fn sysctl
consists of integers, strings, and tables.
Information may be retrieved and set from the command interface
using the
.Xr sysctl 8
utility.
.Pp
Unless explicitly noted below,
.Fn sysctl
returns a consistent snapshot of the data requested.
Consistency is obtained by locking the destination
buffer into memory so that the data may be copied out without blocking.
Calls to
.Fn sysctl
are serialized to avoid deadlock.
.Pp
The state is described using a ``Management Information Base'' (MIB)
style name, listed in
.Fa name ,
which is a
.Fa namelen
length array of integers.
.Pp
The
.Fn sysctlbyname
function accepts an ASCII representation of the name and internally
looks up the integer name vector.
Apart from that, it behaves the same
as the standard
.Fn sysctl
function.
.Pp
The information is copied into the buffer specified by
.Fa oldp .
The size of the buffer is given by the location specified by
.Fa oldlenp
before the call,
and that location gives the amount of data copied after a successful call
and after a call that returns with the error code
.Er ENOMEM .
If the amount of data available is greater
than the size of the buffer supplied,
the call supplies as much data as fits in the buffer provided
and returns with the error code
.Er ENOMEM .
If the old value is not desired,
.Fa oldp
and
.Fa oldlenp
should be set to NULL.
.Pp
The size of the available data can be determined by calling
.Fn sysctl
with the
.Dv NULL
argument for
.Fa oldp .
The size of the available data will be returned in the location pointed to by
.Fa oldlenp .
For some operations, the amount of space may change often.
For these operations,
the system attempts to round up so that the returned size is
large enough for a call to return the data shortly thereafter.
.Pp
To set a new value,
.Fa newp
is set to point to a buffer of length
.Fa newlen
from which the requested value is to be taken.
If a new value is not to be set,
.Fa newp
should be set to NULL and
.Fa newlen
set to 0.
.Pp
The
.Fn sysctlnametomib
function accepts an ASCII representation of the name,
looks up the integer name vector,
and returns the numeric representation in the mib array pointed to by
.Fa mibp .
The number of elements in the mib array is given by the location specified by
.Fa sizep
before the call,
and that location gives the number of entries copied after a successful call.
The resulting
.Fa mib
and
.Fa size
may be used in subsequent
.Fn sysctl
calls to get the data associated with the requested ASCII name.
This interface is intended for use by applications that want to
repeatedly request the same variable (the
.Fn sysctl
function runs in about a third the time as the same request made via the
.Fn sysctlbyname
function).
.Pp
The top level names are defined with a CTL_ prefix in
.In sys/sysctl.h ,
and are as follows.
The next and subsequent levels down are found in the include files
listed here, and described in separate sections below.
.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
.It Sy "Name	Next level names	Description"
.It "CTL_DEBUG	sys/sysctl.h	Debugging"
.It "CTL_VFS	sys/mount.h	File system"
.It "CTL_HW	sys/sysctl.h	Generic CPU, I/O"
.It "CTL_KERN	sys/sysctl.h	High kernel limits"
.It "CTL_MACHDEP	sys/sysctl.h	Machine dependent"
.It "CTL_NET	sys/socket.h	Networking"
.It "CTL_USER	sys/sysctl.h	User-level"
.It "CTL_VM	sys/resources.h	Virtual memory (struct loadavg)"
.El
.Pp
For example, the following retrieves the maximum number of processes allowed
in the system:
.Pp
.Bd -literal -offset indent -compact
int maxproc;
size_t len = sizeof(maxproc);
sysctlbyname("kern.maxproc", &maxproc, &len, NULL, 0);
.Ed
.Pp
To retrieve the standard search path for the system utilities:
.Pp
.Bd -literal -offset indent -compact
char *p;
size_t len;
sysctlbyname("user.cs_path", NULL, &len, NULL, 0);
p = malloc(len);
sysctlbyname("user.cs_path", p, &len, NULL, 0);
.Ed
.Ss CTL_VFS
A distinguished second level name, VFS_GENERIC,
is used to get general information about all file systems.
One of its third level identifiers is VFS_MAXTYPENUM
that gives the highest valid file system type number.
Its other third level identifier is VFS_CONF that
returns configuration information about the file system
type given as a fourth level identifier (see
.Xr getvfsbyname 3
as an example of its use).
The remaining second level identifiers are the
file system type number returned by a
.Xr statfs 2
call or from VFS_CONF.
The third level identifiers available for each file system
are given in the header file that defines the mount
argument structure for that file system.
.Ss CTL_HW
The string and integer information available for the CTL_HW level
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
.Bl -column "xxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx" -offset indent
.It Sy "Name	Type	Changeable"
.It "hw.activecpu	int32_t	no"
.It "hw.byteorder	int32_t	no"
.It "hw.cacheconfig	uint64_t[] 	no"
.It "hw.cachelinesize	int64_t	no"
.It "hw.cachesize	uint64_t[] 	no"
.It "hw.cpu64bit_capable	int32_t	no"
.It "hw.cpufamily	int32_t	no"
.It "hw.cpufrequency	int64_t	no"
.It "hw.cpufrequency_max	int64_t	no"
.It "hw.cpufrequency_min	int64_t	no"
.It "hw.cpusubtype	int32_t	no"
.It "hw.cputhreadtype	int32_t	no"
.It "hw.cputype	int32_t	no"
.It "hw.l1dcachesize	int64_t	no"
.It "hw.l1icachesize	int64_t	no"
.It "hw.l2cachesize	int64_t	no"
.It "hw.l3cachesize	int64_t	no"
.It "hw.logicalcpu	int32_t	no"
.It "hw.logicalcpu_max	int32_t	no"
.It "hw.machine	char[]	no"
.It "hw.memsize	int64_t	no"
.It "hw.model	char[]	no"
.It "hw.ncpu	int32_t	no"
.It "hw.packages	int32_t	no"
.It "hw.pagesize	int64_t	no"
.It "hw.physicalcpu	int32_t	no"
.It "hw.physicalcpu_max	int32_t	no"
.It "hw.tbfrequency	int64_t	no"
.El
.Bl -tag -width 6n
.It Li "hw.byteorder"
The byte order (4321 or 1234).
.It Li "hw.model"
The machine model.
.It Li "hw.ncpu"
The number of cpus. This attribute is deprecated and it is recommended that
.Va "hw.logicalcpu" ,
.Va "hw.logicalcpu_max" ,
.Va "hw.physicalcpu" ,
or
.Va "hw.physicalcpu_max"
be used instead.
.It Li "hw.logicalcpu"
The number of logical processors available in the current power management mode.
.It Li "hw.logicalcpu_max"
The maximum number of logical processors that could be available this boot.
.It Li "hw.physicalcpu"
The number of physical processors available in the current power management mode.
.It Li "hw.physicalcpu_max"
The maximum number of physical processors that could be available this boot.
.It Li "hw.pagesize"
The software page size in bytes.
.El
.Ss CTL_KERN
The string and integer information available for the CTL_KERN level
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
The types of data currently available are process information,
system vnodes, the open file entries, routing table entries,
virtual memory statistics, load average history, and clock rate
information.
.Bl -column "xxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxx" -offset indent
.It Sy "Name	Type	Changeable"
.It "kern.argmax	int32_t	no"
.It "kern.bootargs	char[]	no"
.It "kern.boottime	struct timeval	no"
.It "kern.check_openevt	int32_t	yes"
.It "kern.clockrate	struct clockinfo	no"
.It "kern.coredump	int32_t	yes"
.It "kern.corefile	char[]	yes"
.It "kern.flush_cache_on_write	int32_t	yes"
.It "kern.hostid	int32_t	yes"
.It "kern.hostname	char[]	yes"
.It "kern.job_control	int32_t	no"
.It "kern.maxfiles	int32_t	yes"
.It "kern.maxfilesperproc	int32_t	yes"
.It "kern.maxnbuf	int32_t	yes"
.It "kern.maxproc	int32_t	yes"
.It "kern.maxprocperuid	int32_t	yes"
.It "kern.maxvnodes	int32_t	yes"
.It "kern.msgbuf	int32_t	yes"
.It "kern.nbuf	int32_t	no"
.It "kern.netboot	int32_t	no"
.It "kern.ngroups	int32_t	no"
.It "kern.nisdomainname	char[]	yes"
.It "kern.num_files	int32_t	no"
.It "kern.num_tasks	int32_t	no"
.It "kern.num_taskthreads	int32_t	no"
.It "kern.num_threads	int32_t	no"
.It "kern.num_vnodes	int32_t	no"
.It "kern.nx	int32_t	yes"
.It "kern.osrelease	char[]	no"
.It "kern.osrevision	int32_t	no"
.It "kern.ostype	char[]	no"
.It "kern.osversion	char[]	yes"
.It "kern.posix1version	int32_t	no"
.It "kern.procname	char[]	yes"
.It "kern.safeboot	int32_t	no"
.It "kern.saved_ids	int32_t	no"
.It "kern.secure_kernel	int32_t	no"
.It "kern.securelevel	int32_t	yes"
.It "kern.singleuser	int32_t	no"
.It "kern.sleeptime	struct timeval	no"
.It "kern.slide	int32_t	no"
.It "kern.stack_depth_max	int32_t	no"
.It "kern.stack_size	int32_t	no"
.It "kern.sugid_coredump	int32_t	yes"
.It "kern.sugid_scripts	int32_t	yes"
.It "kern.symfile	char[]	no"
.It "kern.usrstack	int32_t	no"
.It "kern.usrstack64	int64_t	no"
.It "kern.uuid	char[]	no"
.It "kern.version	char[]	no"
.It "kern.waketime	struct timeval	no"
.El
.Bl -tag -width 6n
.It Li "kern.argmax"
The maximum bytes of argument to
.Xr execve 2 .
.It Li "kern.boottime"
A
.Va struct timeval
structure is returned.
This structure contains the time that the system was booted.
.It Li "kern.clockrate"
A
.Va struct clockinfo
structure is returned.
This structure contains the clock, statistics clock and profiling clock
frequencies, the number of micro-seconds per hz tick and the skew rate.
.It Li "kern.hostid"
Get or set the host id.
.It Li "kern.hostname"
Get or set the hostname.
.It Li "kern.job_control"
Return 1 if job control is available on this system, otherwise 0.
.It Li "kern.maxfiles"
The maximum number of files that may be open in the system.
.It Li "kern.maxfilesperproc"
The maximum number of files that may be open for a single process.
This limit only applies to processes with an effective uid of nonzero
at the time of the open request.
Files that have already been opened are not affected if the limit
or the effective uid is changed.
.It Li "kern.maxproc"
The maximum number of concurrent processes the system will allow.
.It Li "kern.maxprocperuid"
The maximum number of concurrent processes the system will allow
for a single effective uid.
This limit only applies to processes with an effective uid of nonzero
at the time of a fork request.
Processes that have already been started are not affected if the limit
is changed.
.It Li "kern.maxvnodes"
The maximum number of vnodes available on the system.
.It Li "kern.ngroups"
The maximum number of supplemental groups.
.It Li "kern.nisdomainname"
The name of the current YP/NIS domain.
.It Li "kern.osrelease"
The system release string.
.It Li "kern.osrevision"
The system revision number.
.It Li "kern.ostype"
The system type string.
.It Li "kern.posix1version"
The version of
.St -p1003.1
with which the system
attempts to comply.
.It Li "kern.saved_ids"
Returns 1 if saved set-group and saved set-user ID is available.
.It Li "kern.securelevel"
The system security level.
This level may be raised by processes with appropriate privilege.
It may not be lowered.
.It Li "kern.version"
The system version string.
.El
.Ss CTL_MACHDEP
The set of variables defined is architecture dependent.
The following variables are defined for the i386 architecture.
.Bl -column "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx" -offset indent
.It Sy "Name	Type	Changeable"
.It "machdep.cpu.address_bits.physical	int32_t	no"
.It "machdep.cpu.address_bits.virtual	int32_t	no"
.It "machdep.cpu.brand	int32_t	no"
.It "machdep.cpu.brand_string	char[]	no"
.It "machdep.cpu.cache.L2_associativity	int32_t	no"
.It "machdep.cpu.cache.linesize	int32_t	no"
.It "machdep.cpu.cache.size	int32_t	no"
.It "machdep.cpu.core_count	int32_t	no"
.It "machdep.cpu.cores_per_package	int32_t	no"
.It "machdep.cpu.extfamily	int32_t	no"
.It "machdep.cpu.extfeature_bits	int64_t	no"
.It "machdep.cpu.extfeatures	char[]	no"
.It "machdep.cpu.extmodel	int32_t	no"
.It "machdep.cpu.family	int32_t	no"
.It "machdep.cpu.feature_bits	int64_t	no"
.It "machdep.cpu.features	char[]	no"
.It "machdep.cpu.leaf7_feature_bits	uint32_t	no"
.It "machdep.cpu.leaf7_features	char[]	no"
.It "machdep.cpu.logical_per_package	int32_t	no"
.It "machdep.cpu.max_basic	uint32_t	no"
.It "machdep.cpu.max_ext	uint32_t	no"
.It "machdep.cpu.microcode_version	int32_t	no"
.It "machdep.cpu.model	int32_t	no"
.It "machdep.cpu.processor_flag	int32_t	no"
.It "machdep.cpu.signature	int32_t	no"
.It "machdep.cpu.stepping	int32_t	no"
.It "machdep.cpu.thread_count	int32_t	no"
.It "machdep.cpu.tlb.data.large	int32_t	no"
.It "machdep.cpu.tlb.data.large_level1	int32_t	no"
.It "machdep.cpu.tlb.data.small	int32_t	no"
.It "machdep.cpu.tlb.data.small_level1	int32_t	no"
.It "machdep.cpu.tlb.inst.large	int32_t	no"
.It "machdep.cpu.tlb.inst.small	int32_t	no"
.It "machdep.cpu.tlb.shared	int32_t	no"
.It "machdep.cpu.ucupdate	int32_t	yes"
.It "machdep.cpu.vendor	char[]	no"
.It "machdep.cpu.xsave.extended_state	uint32_t	no"
.It "machdep.tsc.deep_idle_rebase	uint32_t	yes"
.It "machdep.tsc.frequency	int64_t	no"
.It "machdep.tsc.nanotime.generation	uint32_t	no"
.It "machdep.tsc.nanotime.shift	uint32_t	no"
.El
.Ss CTL_NET
The string and integer information available for the CTL_NET level
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
.It Sy "Second level name	Type	Changeable"
.It "PF_ROUTE	routing messages	no"
.It "PF_INET	IPv4 values	yes"
.It "PF_INET6	IPv6 values	yes"
.El
.Bl -tag -width 6n
.It Li PF_ROUTE
Return the entire routing table or a subset of it.
The data is returned as a sequence of routing messages (see
.Xr route 4
for the header file, format and meaning).
The length of each message is contained in the message header.
.Pp
The third level name is a protocol number, which is currently always 0.
The fourth level name is an address family, which may be set to 0 to
select all address families.
The fifth, sixth, and seventh level names are as follows:
.Bl -column -offset indent "Fifth level      Sixth level" "Seventh level"
.It Sy "Fifth level      Sixth level" Ta Sy "Seventh level"
.It "NET_RT_FLAGS     rtflags" Ta "None"
.It "NET_RT_DUMP      None" Ta "None or fib number"
.It "NET_RT_IFLIST    0 or if_index" Ta None
.It "NET_RT_IFMALIST  0 or if_index" Ta None
.It "NET_RT_IFLISTL   0 or if_index" Ta None
.El
.Pp
The
.Dv NET_RT_IFMALIST
name returns information about multicast group memberships on all interfaces
if 0 is specified, or for the interface specified by
.Va if_index .
.It Li PF_INET
Get or set various global information about the IPv4
(Internet Protocol version 4).
The third level name is the protocol.
The fourth level name is the variable name.
The currently defined protocols and names are:
.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX
.It Sy "Protocol	Variable	Type	Changeable"
.It "icmp	bmcastecho	integer	yes"
.It "icmp	maskrepl	integer	yes"
.It "ip	forwarding	integer	yes"
.It "ip	redirect	integer	yes"
.It "ip	ttl	integer	yes"
.It "udp	checksum	integer	yes"
.El
.Pp
The variables are as follows:
.Bl -tag -width 6n
.It Li icmp.bmcastecho
Returns 1 if an ICMP echo request to a broadcast or multicast address is
to be answered.
.It Li icmp.maskrepl
Returns 1 if ICMP network mask requests are to be answered.
.It Li ip.forwarding
Returns 1 when IP forwarding is enabled for the host,
meaning that the host is acting as a router.
.It Li ip.redirect
Returns 1 when ICMP redirects may be sent by the host.
This option is ignored unless the host is routing IP packets,
and should normally be enabled on all systems.
.It Li ip.ttl
The maximum time-to-live (hop count) value for an IP packet sourced by
the system.
This value applies to normal transport protocols, not to ICMP.
.It Li udp.checksum
Returns 1 when UDP checksums are being computed and checked.
Disabling UDP checksums is strongly discouraged.
.Pp
For variables net.inet.*.ipsec, please refer to
.Xr ipsec 4 .
.El
.It Li PF_INET6
Get or set various global information about the IPv6
(Internet Protocol version 6).
The third level name is the protocol.
The fourth level name is the variable name.
.Pp
For variables net.inet6.* please refer to
.Xr inet6 4 .
For variables net.inet6.*.ipsec6, please refer to
.Xr ipsec 4 .
.El
.Ss CTL_USER
The string and integer information available for the CTL_USER level
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
.Bl -column "xxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx" -offset indent
.It Sy "Name	Type	Changeable"
.It "user.bc_base_max	int32_t	no"
.It "user.bc_dim_max	int32_t	no"
.It "user.bc_scale_max	int32_t	no"
.It "user.bc_string_max	int32_t	no"
.It "user.coll_weights_max	int32_t	no"
.It "user.cs_path	char[]	no"
.It "user.expr_nest_max	int32_t	no"
.It "user.line_max	int32_t	no"
.It "user.posix2_c_bind	int32_t	no"
.It "user.posix2_c_dev	int32_t	no"
.It "user.posix2_char_term	int32_t	no"
.It "user.posix2_fort_dev	int32_t	no"
.It "user.posix2_fort_run	int32_t	no"
.It "user.posix2_localedef	int32_t	no"
.It "user.posix2_sw_dev	int32_t	no"
.It "user.posix2_upe	int32_t	no"
.It "user.posix2_version	int32_t	no"
.It "user.re_dup_max	int32_t	no"
.It "user.stream_max	int32_t	no"
.It "user.tzname_max	int32_t	no"
.El
.Bl -tag -width 6n
.Pp
.It Li "user.bc_base_max"
The maximum ibase/obase values in the
.Xr bc 1
utility.
.It Li "user.bc_dim_max"
The maximum array size in the
.Xr bc 1
utility.
.It Li "user.bc_scale_max"
The maximum scale value in the
.Xr bc 1
utility.
.It Li "user.bc_string_max"
The maximum string length in the
.Xr bc 1
utility.
.It Li "user.coll_weights_max"
The maximum number of weights that can be assigned to any entry of
the LC_COLLATE order keyword in the locale definition file.
.It Li "user.cs_path"
Return a value for the
.Ev PATH
environment variable that finds all the standard utilities.
.It Li "user.expr_nest_max"
The maximum number of expressions that can be nested within
parenthesis by the
.Xr expr 1
utility.
.It Li "user.line_max"
The maximum length in bytes of a text-processing utility's input
line.
.It Li "user.posix2_c_bind"
Return 1 if the system's C-language development facilities support the
C-Language Bindings Option, otherwise 0.
.It Li "user.posix2_c_dev"
Return 1 if the system supports the C-Language Development Utilities Option,
otherwise 0.
.It Li "user.posix2_char_term"
Return 1 if the system supports at least one terminal type capable of
all operations described in
.St -p1003.2 ,
otherwise 0.
.It Li "user.posix2_fort_dev"
Return 1 if the system supports the FORTRAN Development Utilities Option,
otherwise 0.
.It Li "user.posix2_fort_run"
Return 1 if the system supports the FORTRAN Runtime Utilities Option,
otherwise 0.
.It Li "user.posix2_localedef"
Return 1 if the system supports the creation of locales, otherwise 0.
.It Li "user.posix2_sw_dev"
Return 1 if the system supports the Software Development Utilities Option,
otherwise 0.
.It Li "user.posix2_upe"
Return 1 if the system supports the User Portability Utilities Option,
otherwise 0.
.It Li "user.posix2_version"
The version of
.St -p1003.2
with which the system attempts to comply.
.It Li "user.re_dup_max"
The maximum number of repeated occurrences of a regular expression
permitted when using interval notation.
.It Li "user.stream_max"
The minimum maximum number of streams that a process may have open
at any one time.
.It Li "user.tzname_max"
The minimum maximum number of types supported for the name of a
timezone.
.El
.Ss CTL_VM
The string and integer information available for the CTL_VM level
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
.Bl -column "xxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx" -offset indent
.It Sy "Name	Type	Changeable"
.It "vm.loadavg	struct loadavg	no"
.It "vm.swapusage	struct xsw_usage	no"
.El
.Pp
.Bl -tag -width 6n
.It Li "vm.loadavg"
Return the load average history.
The returned data consists of a
.Va struct loadavg .
.El
.Sh RETURN VALUES
.Rv -std
.Sh FILES
.Bl -tag -width <netinet/icmpXvar.h> -compact
.It In sys/sysctl.h
definitions for top level identifiers, second level kernel and hardware
identifiers, and user level identifiers
.It In sys/socket.h
definitions for second level network identifiers
.It In netinet/in.h
definitions for third level IPv4/IPv6 identifiers and
fourth level IPv4/v6 identifiers
.It In netinet/icmp_var.h
definitions for fourth level ICMP identifiers
.It In netinet/icmp6.h
definitions for fourth level ICMPv6 identifiers
.It In netinet/udp_var.h
definitions for fourth level UDP identifiers
.El
.Sh ERRORS
The following errors may be reported:
.Bl -tag -width Er
.It Bq Er EFAULT
The buffer
.Fa name ,
.Fa oldp ,
.Fa newp ,
or length pointer
.Fa oldlenp
contains an invalid address.
.It Bq Er EINVAL
The
.Fa name
array is less than two or greater than CTL_MAXNAME.
.It Bq Er EINVAL
A non-null
.Fa newp
is given and its specified length in
.Fa newlen
is too large or too small.
.It Bq Er ENOMEM
The length pointed to by
.Fa oldlenp
is too short to hold the requested value.
.It Bq Er ENOMEM
The smaller of either the length pointed to by
.Fa oldlenp
or the estimated size of the returned data exceeds the
system limit on locked memory.
.It Bq Er ENOMEM
Locking the buffer
.Fa oldp ,
or a portion of the buffer if the estimated size of the data
to be returned is smaller,
would cause the process to exceed its per-process locked memory limit.
.It Bq Er ENOTDIR
The
.Fa name
array specifies an intermediate rather than terminal name.
.It Bq Er EISDIR
The
.Fa name
array specifies a terminal name, but the actual name is not terminal.
.It Bq Er ENOENT
The
.Fa name
array specifies a value that is unknown.
.It Bq Er EPERM
An attempt is made to set a read-only value.
.It Bq Er EPERM
A process without appropriate privilege attempts to set a value.
.El
.Sh SEE ALSO
.Xr confstr 3 ,
.Xr sysconf 3 ,
.Xr sysctl 8
.Sh HISTORY
The
.Fn sysctl
function first appeared in
.Bx 4.4 .