|Home » Learning Curve
Cool Clever Stuff with CLIX III
A look at sysctl.
A Unix user need never complain about a lack of statistics. With sysctl you have statistics coming out of your ears - and some of it might even be useful too.
And the CLIX starter command database has a lot of suggestions how you might use it.
|sysctl hw.activecpu||show number of active CPUs|
|sysctl hw.byteorder||show machine byte order|
|sysctl hw.l2cachesize||show size of L2 cache|
|sysctl hw.machine||show machine designation|
|sysctl hw.memsize||show amount of installed RAM|
|sysctl hw.model||show model designation|
|sysctl hw.ncpu||show number of CPUs|
|sysctl hw.optional.altivec||show presence of Altivec|
|sysctl hw.optional.floatingpoint||show presence of floating point unit|
|sysctl hw.pagesize||show system page size|
|sysctl hw.usermem||show amount of RAM available to user|
|sysctl kern.boottime||show boot time|
|sysctl kern.clockrate||show clock rate|
|sysctl kern.ipc.maxsockbuf||show maximum socket buffer size|
|sysctl kern.ipc.maxsocketsf||show maximum number of sockets|
|sysctl kern.maxfiles||show maximum file handles|
|sysctl kern.maxproc||show maximum processes|
|sysctl kern.maxvnodes||show max vnodes|
|sysctl kern.ngroups||show number of supplemental GIDs|
|sysctl kern.osrelease||show OS release|
|sysctl kern.osrevision||show OS revision|
|sysctl kern.ostype||show OS type|
|sysctl kern.posix1version||show POSIX 1 version|
|sysctl kern.posix2version||show POSIX 2 version|
|sysctl kern.securelevel||show secure level|
|sysctl kern.version||show kernel version|
|sysctl net.inet.ip.forwarding||show IP forwarding flag|
|sysctl net.inet.ip.maxfragpackets||show max frag packets|
|sysctl net.inet.ip.ttl||show default TTL|
|sysctl net.inet.raw.maxdgram||show max raw socket datagram|
|sysctl net.inet.tcp.path_mtu_discovery||show path MTU discovery flag|
|sysctl vm.loadavg||show load averages|
Connect the Dots
What's obvious from the above table is that sysctl accesses a database where categories and subcategories are separated by dots. The categories hw, kern, net, and vm are self-explanatory. (And if they're not, they're 'hardware', 'kernel', 'network', and 'virtual memory' respectively.)
This type of system is often referred to as a 'MIB' - a 'management information base'. You can use the '-a' switch to list all the current integer and string values in your system; other data in table form will be available only to specially written programs; exactly what values are available will vary from system to system.
Some of these values are even modifiable, but it's perfectly possible to shoot oneself in the foot too, so it's best not to tread into those waters.
At least it's safe to make mistakes if you're only enquiring.
% sysctl beer.price
top level name beer in beer.price is invalid
One at a Time
You might find the output of sysctl -a intimidating; then again you might not; but the safest way is to begin with one category at a time to see what's out there.
% sysctl hw
And so forth. Try using the command line sysctl -a | sort to see everything grouped together and in alphabetical order. Try at least the four categories mentioned above. You might not be able to figure out what each and every value means, but you will be able to guess your way to quite a few. Give it a whirl.