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