xref: /netbsd-src/lib/libc/gen/sysctl.3 (revision fdecd6a253f999ae92b139670d9e15cc9df4497c)
1.\"	$NetBSD: sysctl.3,v 1.14 1997/06/06 23:24:00 veego 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\_MACHINE\_ARCH	string	no
199.\".It HW\_DISKNAMES	integer	no
200.\".It HW\_DISKSTATS	integer	no
201.El
202.Pp
203.Bl -tag -width "123456"
204.It Li HW_MACHINE
205The machine class.
206.It Li HW_MODEL
207The machine model
208.It Li HW_NCPU
209The number of cpus.
210.It Li HW_BYTEORDER
211The byteorder (4,321, or 1,234).
212.It Li HW_PHYSMEM
213The bytes of physical memory.
214.It Li HW_USERMEM
215The bytes of non-kernel memory.
216.It Li HW_PAGESIZE
217The software page size.
218.It Li HW_MACHINE_ARCH
219The machine cpu class.
220.\".It Fa HW_DISKNAMES
221.\".It Fa HW_DISKSTATS
222.El
223.Sh CTL_KERN
224The string and integer information available for the CTL_KERN level
225is detailed below.
226The changeable column shows whether a process with appropriate
227privilege may change the value.
228The types of data currently available are process information,
229system vnodes, the open file entries, routing table entries,
230virtual memory statistics, load average history, and clock rate
231information.
232.Bl -column "KERNXCHOWNXRESTRICTEDXXX" "struct clockrateXXX" -offset indent
233.It Sy Pa Second level name	Type	Changeable
234.It KERN\_ARGMAX	integer	no
235.It KERN\_AUTONICETIME	integer	yes
236.It KERN\_AUTONICEVAL	integer	yes
237.It KERN\_BOOTTIME	struct timeval	no
238.It KERN\_CHOWN\_RESTRICTED	integer	no
239.It KERN\_CLOCKRATE	struct clockinfo	no
240.It KERN\_DOMAINNAME	string	yes
241.It KERN\_FILE	struct file	no
242.It KERN\_HOSTID	integer	yes
243.It KERN\_HOSTNAME	string	yes
244.It KERN\_JOB\_CONTROL	integer	no
245.It KERN\_LINK\_MAX	integer	no
246.It KERN\_MAXFILES	integer	yes
247.It KERN\_MAXPARTITIONS	integer	no
248.It KERN\_MAXPROC	integer	yes
249.It KERN\_MAXVNODES	integer	yes
250.It KERN\_MAX\_CANON	integer	no
251.It KERN\_MAX\_INPUT	integer	no
252.It KERN\_NAME\_MAX	integer	no
253.It KERN\_NGROUPS	integer	no
254.It KERN\_NO\_TRUNC	integer	no
255.It KERN\_OSRELEASE	string	no
256.It KERN\_OSREV	integer	no
257.It KERN\_OSTYPE	string	no
258.It KERN\_PATH\_MAX	integer	no
259.It KERN\_PIPE\_BUF	integer	no
260.It KERN\_POSIX1	integer	no
261.It KERN\_PROC	struct proc	no
262.It KERN\_PROF	node	not applicable
263.It KERN\_RAWPARTITION	integer	no
264.It KERN\_SAVED\_IDS	integer	no
265.It KERN\_SECURELVL	integer	raise only
266.It KERN\_VDISABLE	integer	no
267.It KERN\_VERSION	string	no
268.It KERN\_VNODE	struct vnode	no
269.El
270.Pp
271.Bl -tag -width "123456"
272.It Li KERN_ARGMAX
273The maximum bytes of argument to
274.Xr exec 2 .
275.It Li KERN_AUTONICETIME
276The number of seconds of cpu-time a non-root process may accumulate before
277having its priority lowered from the default to the value of KERN_AUTONICEVAL.
278If set to 0, automatic lowering of priority is not performed, and if set to -1
279all non-root processes are immediately lowered.
280.It Li KERN_AUTONICEVAL
281The priority assigned for automatically niced processes.
282.It Li KERN_BOOTTIME
283A
284.Va struct timeval
285structure is returned.
286This structure contains the time that the system was booted.
287.It Li KERN_CHOWN_RESTRICTED
288Return 1 if appropriate privileges are required for the
289.Xr chown 2
290system call, otherwise 0.
291.It Li KERN_CLOCKRATE
292A
293.Va struct clockinfo
294structure is returned.
295This structure contains the clock, statistics clock and profiling clock
296frequencies, the number of micro-seconds per hz tick, and the clock
297skew rate.
298.It Li KERN_DOMAINNAME
299Get or set the YP domain name.
300.It Li KERN_FILE
301Return the entire file table.
302The returned data consists of a single
303.Va struct filehead
304followed by an array of
305.Va struct file ,
306whose size depends on the current number of such objects in the system.
307.It Li KERN_HOSTID
308Get or set the host id.
309.It Li KERN_HOSTNAME
310Get or set the hostname.
311.It Li KERN_JOB_CONTROL
312Return 1 if job control is available on this system, otherwise 0.
313.It Li KERN_LINK_MAX
314The maximum file link count.
315.It Li KERN_MAXFILES
316The maximum number of open files that may be open in the system.
317.It Li KERN_MAXPARTITIONS
318The maximum number of partitions allowed per disk.
319.It Li KERN_MAXPROC
320The maximum number of simultaneous processes the system will allow.
321.It Li KERN_MAXVNODES
322The maximum number of vnodes available on the system.
323.It Li KERN_MAX_CANON
324The maximum number of bytes in terminal canonical input line.
325.It Li KERN_MAX_INPUT
326The minimum maximum number of bytes for which space is available in
327a terminal input queue.
328.It Li KERN_NAME_MAX
329The maximum number of bytes in a file name.
330.It Li KERN_NGROUPS
331The maximum number of supplemental groups.
332.It Li KERN_NO_TRUNC
333Return 1 if file names longer than KERN_NAME_MAX are truncated.
334.It Li KERN_OSRELEASE
335The system release string.
336.It Li KERN_OSREV
337The system revision string.
338.It Li KERN_OSTYPE
339The system type string.
340.It Li KERN_PATH_MAX
341The maximum number of bytes in a pathname.
342.It Li KERN_PIPE_BUF
343The maximum number of bytes which will be written atomically to a pipe.
344.It Li KERN_POSIX1
345The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
346attempts to comply.
347.It Li KERN_PROC
348Return the entire process table, or a subset of it.
349An array of
350.Va struct kinfo_proc
351structures is returned,
352whose size depends on the current number of such objects in the system.
353The third and fourth level names are as follows:
354.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
355.It Pa Third level name	Fourth level is:
356.It KERN\_PROC\_ALL	None
357.It KERN\_PROC\_PID	A process ID
358.It KERN\_PROC\_PGRP	A process group
359.It KERN\_PROC\_TTY	A tty device
360.It KERN\_PROC\_UID	A user ID
361.It KERN\_PROC\_RUID	A real user ID
362.El
363.It Li KERN_PROF
364Return profiling information about the kernel.
365If the kernel is not compiled for profiling,
366attempts to retrieve any of the KERN_PROF values will
367fail with EOPNOTSUPP.
368The third level names for the string and integer profiling information
369is detailed below.
370The changeable column shows whether a process with appropriate
371privilege may change the value.
372.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
373.It Sy Pa Third level name	Type	Changeable
374.It GPROF\_STATE	integer	yes
375.It GPROF\_COUNT	u_short[\|]	yes
376.It GPROF\_FROMS	u_short[\|]	yes
377.It GPROF\_TOS	struct tostruct	yes
378.It GPROF\_GMONPARAM	struct gmonparam	no
379.El
380.Pp
381The variables are as follows:
382.Bl -tag -width "123456"
383.It Li GPROF_STATE
384Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling
385is running or stopped.
386.It Li GPROF_COUNT
387Array of statistical program counter counts.
388.It Li GPROF_FROMS
389Array indexed by program counter of call-from points.
390.It Li GPROF_TOS
391Array of
392.Va struct tostruct
393describing destination of calls and their counts.
394.It Li GPROF_GMONPARAM
395Structure giving the sizes of the above arrays.
396.El
397.It Li KERN_RAWPARTITION
398The raw partition of a disk (a == 0).
399.It Li KERN_SAVED_IDS
400Returns 1 if saved set-group and saved set-user ID is available.
401.It Li KERN_SECURELVL
402The system security level.
403This level may be raised by processes with appropriate privilege.
404It may only be lowered by process 1.
405.It Li KERN_VDISABLE
406Returns the terminal character disabling value.
407.It Li KERN_VERSION
408The system version string.
409.It Li KERN_VNODE
410Return the entire vnode table.
411Note, the vnode table is not necessarily a consistent snapshot of
412the system.
413The returned data consists of an array whose size depends on the
414current number of such objects in the system.
415Each element of the array contains the kernel address of a vnode
416.Va struct vnode *
417followed by the vnode itself
418.Va struct vnode .
419.El
420.Sh CTL_MACHDEP
421The set of variables defined is architecture dependent.
422Most architectures define at least the following variables.
423.Bl -column "CONSOLE_DEVICEXXX" "integerXXX" -offset indent
424.It Sy Pa Second level name	Type	Changeable
425.It Li CPU_CONSDEV	dev_t	no
426.El
427.Sh CTL_NET
428The string and integer information available for the CTL_NET level
429is detailed below.
430The changeable column shows whether a process with appropriate
431privilege may change the value.
432.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
433.It Sy Pa Second level name	Type	Changeable
434.It PF\_ROUTE	routing messages	no
435.It PF\_INET	internet values	yes
436.El
437.Pp
438.Bl -tag -width "123456"
439.It Li PF_ROUTE
440Return the entire routing table or a subset of it.
441The data is returned as a sequence of routing messages (see
442.Xr route 4
443for the header file, format and meaning).
444The length of each message is contained in the message header.
445.Pp
446The third level name is a protocol number, which is currently always 0.
447The fourth level name is an address family, which may be set to 0 to
448select all address families.
449The fifth and sixth level names are as follows:
450.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
451.It Pa Fifth level name	Sixth level is:
452.It NET\_RT\_FLAGS	rtflags
453.It NET\_RT\_DUMP	None
454.It NET\_RT\_IFLIST	None
455.El
456.It Li PF_INET
457Get or set various global information about the internet protocols.
458The third level name is the protocol.
459The fourth level name is the variable name.
460The currently defined protocols and names are:
461.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
462.It Pa Protocol name	Variable name	Type	Changeable
463.It ip	forwarding	integer	yes
464.It ip	redirect	integer	yes
465.It ip	ttl	integer	yes
466.It ip	forwsrcrt	integer	yes
467.It ip	directed-broadcast	integer	yes
468.It icmp	maskrepl	integer	yes
469.It tcp	rfc1323	integer	yes
470.It udp	checksum	integer	yes
471.El
472.Pp
473The variables are as follows:
474.Bl -tag -width "123456"
475.It Li ip.forwarding
476Returns 1 when IP forwarding is enabled for the host,
477meaning that the host is acting as a router.
478.It Li ip.redirect
479Returns 1 when ICMP redirects may be sent by the host.
480This option is ignored unless the host is routing IP packets,
481and should normally be enabled on all systems.
482.It Li ip.ttl
483The maximum time-to-live (hop count) value for an IP packet sourced by
484the system.
485This value applies to normal transport protocols, not to ICMP.
486.It Li ip.forwsrcrt
487Returns 1 when forwarding of source-routed packets is enabled for
488the host.  This value may only be changed if the kernel security
489level is less than 1.
490.It Li ip.directed-broadcast
491Returns 1 if directed broadcast behavior is enabled for the host.
492.It Li icmp.maskrepl
493Returns 1 if ICMP network mask requests are to be answered.
494.It Li tcp.rfc1323
495Returns 1 if RFC1323 extensions to TCP are enabled.
496.It Li udp.checksum
497Returns 1 when UDP checksums are being computed and checked.
498Disabling UDP checksums is strongly discouraged.
499.El
500.Sh CTL_USER
501The string and integer information available for the CTL_USER level
502is detailed below.
503The changeable column shows whether a process with appropriate
504privilege may change the value.
505.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
506.It Sy Pa Second level name	Type	Changeable
507.It USER\_BC\_BASE\_MAX	integer	no
508.It USER\_BC\_DIM\_MAX	integer	no
509.It USER\_BC\_SCALE\_MAX	integer	no
510.It USER\_BC\_STRING\_MAX	integer	no
511.It USER\_COLL\_WEIGHTS\_MAX	integer	no
512.It USER\_CS\_PATH	string	no
513.It USER\_EXPR\_NEST\_MAX	integer	no
514.It USER\_LINE\_MAX	integer	no
515.It USER\_POSIX2\_CHAR\_TERM	integer	no
516.It USER\_POSIX2\_C\_BIND	integer	no
517.It USER\_POSIX2\_C\_DEV	integer	no
518.It USER\_POSIX2\_FORT\_DEV	integer	no
519.It USER\_POSIX2\_FORT\_RUN	integer	no
520.It USER\_POSIX2\_LOCALEDEF	integer	no
521.It USER\_POSIX2\_SW\_DEV	integer	no
522.It USER\_POSIX2\_UPE	integer	no
523.It USER\_POSIX2\_VERSION	integer	no
524.It USER\_RE\_DUP\_MAX	integer	no
525.It USER\_STREAM\_MAX	integer	no
526.It USER\_TZNAME\_MAX	integer	no
527.El
528.Bl -tag -width "123456"
529.Pp
530.It Li USER_BC_BASE_MAX
531The maximum ibase/obase values in the
532.Xr bc 1
533utility.
534.It Li USER_BC_DIM_MAX
535The maximum array size in the
536.Xr bc 1
537utility.
538.It Li USER_BC_SCALE_MAX
539The maximum scale value in the
540.Xr bc 1
541utility.
542.It Li USER_BC_STRING_MAX
543The maximum string length in the
544.Xr bc 1
545utility.
546.It Li USER_COLL_WEIGHTS_MAX
547The maximum number of weights that can be assigned to any entry of
548the LC_COLLATE order keyword in the locale definition file.
549.It Li USER_CS_PATH
550Return a value for the
551.Ev PATH
552environment variable that finds all the standard utilities.
553.It Li USER_EXPR_NEST_MAX
554The maximum number of expressions that can be nested within
555parenthesis by the
556.Xr expr 1
557utility.
558.It Li USER_LINE_MAX
559The maximum length in bytes of a text-processing utility's input
560line.
561.It Li USER_POSIX2_CHAR_TERM
562Return 1 if the system supports at least one terminal type capable of
563all operations described in POSIX 1003.2, otherwise 0.
564.It Li USER_POSIX2_C_BIND
565Return 1 if the system's C-language development facilities support the
566C-Language Bindings Option, otherwise 0.
567.It Li USER_POSIX2_C_DEV
568Return 1 if the system supports the C-Language Development Utilities Option,
569otherwise 0.
570.It Li USER_POSIX2_FORT_DEV
571Return 1 if the system supports the FORTRAN Development Utilities Option,
572otherwise 0.
573.It Li USER_POSIX2_FORT_RUN
574Return 1 if the system supports the FORTRAN Runtime Utilities Option,
575otherwise 0.
576.It Li USER_POSIX2_LOCALEDEF
577Return 1 if the system supports the creation of locales, otherwise 0.
578.It Li USER_POSIX2_SW_DEV
579Return 1 if the system supports the Software Development Utilities Option,
580otherwise 0.
581.It Li USER_POSIX2_UPE
582Return 1 if the system supports the User Portability Utilities Option,
583otherwise 0.
584.It Li USER_POSIX2_VERSION
585The version of POSIX 1003.2 with which the system attempts to comply.
586.It Li USER_RE_DUP_MAX
587The maximum number of repeated occurrences of a regular expression
588permitted when using interval notation.
589.It Li USER_STREAM_MAX
590The minimum maximum number of streams that a process may have open
591at any one time.
592.It Li USER_TZNAME_MAX
593The minimum maximum number of types supported for the name of a
594timezone.
595.El
596.Sh CTL_VM
597The string and integer information available for the CTL_VM level
598is detailed below.
599The changeable column shows whether a process with appropriate
600privilege may change the value.
601.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
602.It Sy Pa Second level name	Type	Changeable
603.It VM\_LOADAVG	struct loadavg	no
604.It VM\_METER	struct vmtotal	no
605.El
606.Pp
607.Bl -tag -width "123456"
608.It Li VM_LOADAVG
609Return the load average history.
610The returned data consists of a
611.Va struct loadavg .
612.It Li VM_METER
613Return the system wide virtual memory statistics.
614The returned data consists of a
615.Va struct vmtotal .
616.El
617.Sh CTL_DDB
618The integer information available for the CTL_DDB level is detailed below.
619The changeable column shows whether a process with appropriate
620privilege may change the value.
621.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent
622.It Sy Pa Second level name	Type	Changeable
623.It DBCTL\_RADIX	integer	yes
624.It DBCTL\_MAXOFF	integer	yes
625.It DBCTL\_LINES	integer	yes
626.It DBCTL\_TABSTOPS	integer	yes
627.It DBCTL\_ONPANIC	integer	yes
628.El
629.Pp
630.Bl -tag -width "123456"
631.It Li DBCTL_RADIX
632The input and output radix.
633.It Li DBCTL_MAXOFF
634The maximum symbol offset.
635.It Li DBCTL_LINES
636Number of display lines.
637.It Li DBCTL_TABSTOPS
638Tab width.
639.It Li DBCTL_ONPANIC
640If non-zero, DDB will be entered when the kernel panics.
641.El
642.Pp
643These MIB nodes are also available as variables from within the
644DDB.  See
645.Xr ddb 4
646for more details.
647.Sh RETURN VALUES
648If the call to
649.Nm sysctl
650is successful, 0 is returned.
651Otherwise \-1 is returned and
652.Va errno
653is set appropriately.
654.Sh ERRORS
655The following errors may be reported:
656.Bl -tag -width Er
657.It Bq Er EFAULT
658The buffer
659.Fa name ,
660.Fa oldp ,
661.Fa newp ,
662or length pointer
663.Fa oldlenp
664contains an invalid address.
665.It Bq Er EINVAL
666The
667.Fa name
668array is less than two or greater than CTL_MAXNAME.
669.It Bq Er EINVAL
670A non-null
671.Fa newp
672is given and its specified length in
673.Fa newlen
674is too large or too small.
675.It Bq Er ENOMEM
676The length pointed to by
677.Fa oldlenp
678is too short to hold the requested value.
679.It Bq Er ENOTDIR
680The
681.Fa name
682array specifies an intermediate rather than terminal name.
683.It Bq Er EOPNOTSUPP
684The
685.Fa name
686array specifies a value that is unknown.
687.It Bq Er EPERM
688An attempt is made to set a read-only value.
689.It Bq Er EPERM
690A process without appropriate privilege attempts to set a value.
691.It Bq Er EPERM
692An attempt to change a value protected by the current kernel security
693level is made.
694.El
695.Sh FILES
696.Bl -tag -width <netinet/icmpXvar.h> -compact
697.It Pa <sys/sysctl.h>
698definitions for top level identifiers, second level kernel and hardware
699identifiers, and user level identifiers
700.It Pa <sys/socket.h>
701definitions for second level network identifiers
702.It Pa <sys/gmon.h>
703definitions for third level profiling identifiers
704.It Pa <vm/vm_param.h>
705definitions for second level virtual memory identifiers
706.It Pa <netinet/in.h>
707definitions for third level Internet identifiers and
708fourth level IP identifiers
709.It Pa <netinet/icmp_var.h>
710definitions for fourth level ICMP identifiers
711.It Pa <netinet/tcp_var.h>
712definitions for fourth level TCP identifiers
713.It Pa <netinet/udp_var.h>
714definitions for fourth level UDP identifiers
715.El
716.Sh SEE ALSO
717.Xr sysctl 8
718.Sh HISTORY
719The
720.Nm sysctl
721function first appeared in 4.4BSD.
722