Home Docs List Table Tree Update Login Contacts

Overview

The FreeBSD Operating System provides the sysctl system call and utility to get and set system state at runtime. The kernel exposes available parameters for sysctl as objects in a Management Information Base (MIB). Today, FreeBSD includes thousands of sysctl parameters. Moreover, parameters can be added or removed dynamically.

Each computer likely builds a different MIB depending on:

Therefore, the kernel must provide additional features for exploring the MIB and retrieving extra information about each object (name, description, format, etc.).

To learn more:


Frequently Asked Questions

Where are Flags, Types, and Formats documented?
Flags and Types: see the "CONTROL FLAGS" section in the sysctl(9) manual.
Formats: see the "format" paragraph in the "DESCRIPTION OF ARGUMENTS" section of the same manual.
Is there a tutorial for sysctl?
Yes, check out the nsysctl tutorial. It explains all the features of sysctl step by step and how to use the information provided on this site.
How can I get parameter info (like shown on this site) for the kernel running on my machine?
Use the -D option of nsysctl:
% nsysctl -D kern.ostype
1.1: kern.ostype: : Operating system type: string: A: RD MPSAFE CAPRD: "Defined": FreeBSD

The -p option makes the output more human-readable:
% nsysctl -Dp kern.ostype
[OID]: 1.1: [NAME]: kern.ostype: [LABEL]: : [DESCRIPTION]: Operating system type: [TYPE]: string: [FORMAT]: A: [FLAGS]: RD MPSAFE CAPRD: [HANDLER]: "Defined": [VALUE]: FreeBSD

See the nsysctl(8) manual for all available options.
How is the data shown on this site generated?
By running the following commands on FreeBSD:
% echo "<!---" >> mib.xml ; nsysctl -e kern.osrelease kern.osreldate >> mib.xml ; echo "-->" >> mib.xml ; nsysctl --libxo=xml,pretty -r MIB -DNkISa >> mib.xml
What is the Handler?
sysctl looks up the node's OID in the MIB, then calls its associated handler - a function (in kernel space). Usually, the handler accesses a variable, but that's not mandatory. A node might not have a handler at all (it' s NULL). So knowing whether a node has a handler helps determine if it performs an action. Typically, internal nodes and those with type "node" have an "Undefined" handler, while leaves have a "Defined" handler.

Let’s analyze two cases where a MIB leaf is of type "node":

Suppose your kernel has a leaf dev.subsystemFOO (a node without children), and its type is "node" with an "Undefined" handler. Why? Because it's the root of a hardware subtree that hasn’t been instantiated (e.g., no device is present). So it's a "node" with no "Defined" handler - that makes sense.

Now, consider a more interesting case: a "node" type with a "Defined" handler. This is also the example in the sysctl(3) manual, it calls sysctl from kern.proc.pid.0 to kern.proc.pid.99, but:
  • kern.proc.pid is a leaf in the MIB (it has no children).
  • It’s of type "node" and has a "Defined" handler.
  • kern.proc.pid.[0-99] are not in the MIB!
What happens? sysctl finds kern.proc.pid in the MIB. Since it's a "node" with a "Defined" handler, it stops traversing the MIB and passes the remaining OID portion ([0-99]) to the handler. These kinds of entries are sometimes called *virtual nodes* or *addressed nodes*. Try it: install sysctlview or go to Tree, search for kern.proc.pid, and you’ll see it’s a leaf (no children), but has type "node" and a "Defined" handler.
Is there a GUI for sysctl?
Yes, it’s sysctlview.
From the menu: View, you can choose which nodes and properties to display.

How is the MIB implemented in the kernel?
Refer to the sysctlinfo README: Introduction.
Are there coding resources?
Get/Set a value: sysctl(3)
Add/Remove a node: sysctl(9)
Explore the MIB or get node properties: sysctlmibinfo2(3) and sysctlinfo(4)
Is WebSysctl open source?
WebSysctl is released under the 2-Clause BSD License.
It will definitely be open source in the future.
Currently, it’s still under development and resides in a private repository.