.\" Copyright (c) 1993 .\" The Regents of the University of California. 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. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. .\" .\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 .\" %Id: sysctl.8,v 1.18 1999/01/10 02:10:08 des Exp % .\" jpman %Id: sysctl.8,v 1.2 1997/05/30 00:57:58 yugawa Stab % .\" .Dd September 23, 1994 .Dt SYSCTL 8 .Os .Sh 名称 .Nm sysctl .Nd カーネル状態の取得や設定 .Sh 書式 .Nm sysctl .Op Fl bdn .Ar name ... .Nm sysctl .Op Fl bn .Fl w .Ar name=value ... .Nm sysctl .Op Fl bdn .Fl aAX .Sh 解説 .Nm はカーネル状態を取り出し、適切な権限があれば プロセスがカーネル状態を設定することを許します。取り出され たり、設定されたりした状態は、``Management Information Base''(``MIB'') 形式を使って記述されます。この形式では、要素はドット ``.'' で 接続されます。 .Pp 以下のオプションを使用可能です: .Bl -tag -width indent .It Fl a 現在有効な文字列や整数値をすべて表示します。 .It Fl A データ形式を知らないもの(以下、形式不明の変数と称する) を含めて、 存在している全ての MIB を表示します。 .Fl a フラグ同様、文字列や整数値も表示されます。 形式不明の変数に関しては、 そのフォーマットおよび長さに関する情報と、その変数の内容の最初の数バイトを 16 進数でダンプします。 .It Fl X フラグは、形式不明の変数の全ての内容が 16 進数でダンプされる以外は .Fl A と同じです。 .It Fl n フィールド名の出力は抑制されて、値 だけが表示されます。これはシェル変数を設定するのに役に 立ちます。たとえば、ページサイズを変数 psize に保存する には、以下のようにします: .Bd -literal -offset indent -compact set psize=`sysctl -n hw.pagesize` .Ed .Pp .It Fl b 変数の値を加工せずに、バイナリ形式で表示します。 変数名や、最後の改行文字は出力されません。これは、単一の変数に対して 操作する際に便利でしょう。 .It Fl d 指定した変数の値ではなく、内容記述を表示します。 .It Fl w Ar name=value ... MIB の .Ar name を新しい値 .Ar value に設定します。 MIB 形式 .Ar name だけが指定された場合、その名前に対応する値が得られます。 .El .Nm で得られる情報は、整数、文字列、形式不明の変数です。 .Nm はいくつかの形式不明の変数の形式を知っているだけで、それ以外のものに 対しては 16 進ダンプに頼ります。 形式不明の変数の情報は、 .Nm ps や .Nm systat , .Nm netstat などの特別な目的のプログラムによって取得された場合に、より効果的です。 .Pp 文字列と整数の情報を簡単にまとめて以下に示します。これらの 変数の詳細な説明は、 .Xr sysctl 3 を参照してください。 .Pp changeable の列は、適切な権限を持つプロセスがその値を変更 できるかどうかを示しています。 .Bl -column net.inet.ip.forwardingxxxxxx integerxxx .It Sy Name Type Changeable .It kern.ostype string no .It kern.osrelease string no .It kern.osrevision integer no .It kern.version string no .It kern.maxvnodes integer yes .It kern.maxproc integer no .It kern.maxprocperuid integer yes .It kern.maxfiles integer yes .It kern.maxfilesperproc integer yes .It kern.argmax integer no .It kern.securelevel integer raise only .It kern.hostname string yes .It kern.hostid integer yes .It kern.clockrate struct no .It kern.posix1version integer no .It kern.ngroups integer no .It kern.job_control integer no .It kern.saved_ids integer no .It kern.boottime struct no .It kern.domainname string yes .It kern.update integer yes .It kern.osreldate string no .It kern.bootfile string yes .It kern.corefile string yes .It kern.logsigexit integer yes .It vm.loadavg struct no .It hw.machine string no .It hw.model string no .It hw.ncpu integer no .It hw.byteorder integer no .It hw.physmem integer no .It hw.usermem integer no .It hw.pagesize integer no .It hw.floatingpoint integer no .It hw.machine_arch string no .It machdep.console_device dev_t no .It machdep.adjkerntz integer yes .It machdep.disable_rtc_set integer yes .It user.cs_path string no .It user.bc_base_max integer no .It user.bc_dim_max integer no .It user.bc_scale_max integer no .It user.bc_string_max integer no .It user.coll_weights_max integer no .It user.expr_nest_max integer no .It user.line_max integer no .It user.re_dup_max integer no .It user.posix2_version integer no .It user.posix2_c_bind integer no .It user.posix2_c_dev integer no .It user.posix2_char_term integer no .It user.posix2_fort_dev integer no .It user.posix2_fort_run integer no .It user.posix2_localedef integer no .It user.posix2_sw_dev integer no .It user.posix2_upe integer no .It user.stream_max integer no .It user.tzname_max integer no .El .Pp .Sh 使用例 たとえば、システム中で許されている最大のプロセス数を知りたい ときは、以下のようにします: .Bd -literal -offset indent -compact sysctl kern.maxproc .Ed .Pp システム中で許されている最大のプロセス数を 1000 に設定する には、以下のようにします: .Bd -literal -offset indent -compact sysctl -w kern.maxproc=1000 .Ed .Pp システムのクロックレートに関する情報を得るには、以下の ようにします: .Bd -literal -offset indent -compact sysctl kern.clockrate .Ed .Pp システム負荷(ロード・アベレージ)の履歴に関する情報を 得るには、以下のようにします: .Bd -literal -offset indent -compact sysctl vm.loadavg .Ed .Pp ここに挙げたもの以外の変数も存在します。それらに関するより深い意味を知る もっとも良く、かつ、おそらく唯一の方法は、それらを定義しているソースコードを みる事であることは疑いのない事実でしょう。 .Sh 関連ファイル .Bl -tag -width -compact .It Pa トップレベルの識別子、第 2 レベルのカーネル/ハードウェア識別子、 そしてユーザレベル識別子の定義 .It Pa 第 2 レベルのネットワーク識別子の定義 .It Pa 第 3 レベルのプロファイル識別子の定義 .It Pa 第 2 レベルの仮想メモリ識別子の定義 .It Pa 第 3 レベルのインターネット識別子と 第 4 レベルの IP 識別子の定義 .It Pa 第 4 レベルの ICMP 識別子の定義 .It Pa 第 4 レベルの UDP 識別子の定義 .El .Sh 関連項目 .Xr sysctl 3 .Sh バグ 現状では .Nm は、sysctl ツリーの追跡、および、形式と名前の情報を得る際に、 文書化されていないカーネルの sysctl 機能へのインタフェースを使用しています。 この方法に関する正しいインタフェースは、現在検討中です。 .Sh 歴史 .Nm sysctl は .Bx 4.4 ではじめて登場しました。 .Pp .Fx 2.2 の .Nm sysctl は著しく改良されています。