#!/bin/sh # # $Pittgoth: projects/scripts/doctune/run.sh,v 1.27 2004/03/16 18:48:45 darklogik Exp $ # $FreeBSD$ # ################################################################# # Missing Features: # It would be nice to have OIDs separated into composite groups # using the subsection mdoc(7) feature (.Ss) without adding extra # files. # # This still does not grab certain sysctls, ACPI for example. ################################################################# # Set our path up. PATH=/bin:/usr/bin:/sbin:/usr/sbin # Ugly hack to set the manual page date format, I'm sure this could # have been done so much cleaner. DATE=`date | awk '($2 == "Jan") {$2 = "January"}; ($2 == "Feb") {$2 = "February"}; \ ($2 == "Mar") {$2 = "March"}; ($2 == "Apr") {$2 == "April"}; \ ($2 == "May") {$2 = "May"}; ($2 == "Jun") {$2 == "June"}; \ ($2 == "Jul") {$2 = "July"}; ($2 == "Aug") {$2 = "August"}; \ ($2 == "Sep") {$2 = "September"}; ($2 == "Oct") {$2 = "October"}; \ ($2 == "Nov") {$2 = "November"}; ($2 == "Dec") {$2 = "December"} \ { print $2, $3",", $6}'` # The awk1 function is an attempt at working around some # problems I noticed. awk1() { sysctls=$( grep -vh '^[[:space:]]*#' "$@" | cpp -include `pwd`/stubs.h | grep XXX_SYSCTL | sed 's/^.*XXX_SYSCTL//' ) cat > sysctl1.awk << EOF BEGIN { $sysctls } function warn(msg) { print msg > "/dev/stderr" } function nodename(node) { nm=name[node] while (parent[node] != "") { node=parent[node] if (!(node in name)) { warn(node ": node not found"); return } nm=name[node] "." nm } return nm } END { for (node in name) { if (type[node] != "node") { nm=nodename(node) if (nm != "") { print nm " (" type[node] "): " descr[node] } } } } EOF } # Produce the sysctl1.awk file: awk1 `find /sys/[a-m]* -name '*.c'` # The awk2 function is an attempt at working some problems # I noticed. awk2() { sysctls=$( grep -vh '^[[:space:]]*#' "$@" | cpp -include `pwd`/stubs.h | grep XXX_SYSCTL | sed 's/^.*XXX_SYSCTL//' ) cat > sysctl2.awk << EOF BEGIN { $sysctls } function warn(msg) { print msg > "/dev/stderr" } function nodename(node) { nm=name[node] while (parent[node] != "") { node=parent[node] if (!(node in name)) { warn(node ": node not found"); return } nm=name[node] "." nm } return nm } END { for (node in name) { if (type[node] != "node") { nm=nodename(node) if (nm != "") { print nm " (" type[node] "): " descr[node] } } } } EOF } # Produce the sysctl2.awk file: awk2 `find /sys/[n-z]* -name '*.c'` # The endman function closes the list and adds the bottom # part of our manual page. endman() { cat <> ./tunables.8 .El .Sh IMPLEMENTATION NOTES Much, if not all of this manual page has been generated by a simple script written in .Xr sh 1 which generates the .Xr mdoc 7 markup. For information on .Xr sysctl 8 implementation notes, see the respecting manual pages. .Sh SEE ALSO .Xr loader.conf 5 , .Xr sysctl.conf 5 , .Xr boot 8 , .Xr loader 8 , .Xr sysctl 8 , .Xr sysctl_add_oid 9 , .Xr sysctl_ctx_init 9 .Sh AUTHORS This manual page automatically generated from a set of tools developed by .An -nosplit .An Tom Rhodes Aq trhodes@FreeBSD.org , with significant contributions from .An Giorgos Keramidas Aq keramida@FreeBSD.org , .An Ruslan Ermilov Aq ru@FreeBSD.org , and .An Marc Silver Aq marcs@draenor.org . .Sh BUGS Sometimes .Fx .Nm can be left undocumented by the individuals who originally implemented them; thus this script was forged as a way to automatically produce a manual page to aid in the administration and configuration of a .Fx system. EOF } # This function creates a list of available sysctls. makenames() { awk -f sysctl1.awk < /dev/null | awk '{ print $1 }' \ > _names; awk -f sysctl2.awk < /dev/null | awk '{ print $1 }' \ >> _names; # This is a band-aid until I figure out how to deal with # the TUNABLE_INT part of sysctl. find /usr/src/sys/ -name '*.c' | xargs grep 'TUNABLE_INT' |\ awk -F\" '{ print $2 }' >> _names; } # The markup_create() function builds the actual # markup file to be dropped into. In essence, # compare our list of tunables with the documented # tunables in our tunables.mdoc file and generate # the final 'inner circle' of our manual page. markup_create() { sort < _names | \ xargs -n 1 /bin/sh ./ctl.sh \ > markup.file \ 2> tunables.TODO # rm _names } # Finally, the following lines will call our functions and # and create our document using the following function: page_create() { startman /bin/cat ./markup.file >> tunables.8 endman } # The startman function creates the initial mdoc(7) formatted # manual page. This is required before we populate it with # tunables both loader and sysctl(8) oids. startman() { cat <> ./tunables.8 .\" .\" Copyright (c) 2003 Tom Rhodes .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. .\" .\" .Dd $DATE .Dt TUNABLES 8 .Os .Sh NAME .Nm tunables .Nd list of system tunables .Sh DESCRIPTION .Fx supports kernel alterations on the fly or at system initialization by using a feature known as the .Dq Management Information Base or .Dq MIBs for short. .Pp The .Fx kernel environment is initialized from the .Xr loader 8 variables, and can later be viewed and modified with the .Xr kenv 1 utility. Some of these variables allow an administrator to .Dq tune some aspect of system's behavior at startup, hence .Dq tunables . Most tunables have corresponding sysctls. While some sysctls may be used to alter the system behavior on-the-fly, some aspects of the system, for example the size of some critical buffers, may be changed only at the system initialization time, hence the need for tunables. .Pp When the need to alter a read-only variable arises, they can be added to the .Xr loader.conf 5 configuration file. For more information on how this file is structured, see the manual page. .Pp Furthermore, changes to certain .Nm can be made by using .Pa /etc/rc.conf , as many .Nm are set during the boot stage while reading values from this file. See .Xr rc.conf 5 for more information. .Pp Some sysctls in this manual page will not be available on every system as they rely on specific kernel options being present. In those cases a cross reference to another manual page will be supplied. That manual page will explain what kernel options are required and most likely provide more in depth information on using the corresponding tunables. The .Nm supported by .Xr sysctl 8 are: .Pp .Bl -ohang -offset indent EOF } # Final bit of code here, call the functions required to create # our manual page. makenames markup_create page_create