.\" 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 .\" %FreeBSD: src/sbin/sysctl/sysctl.8,v 1.23.2.12 2001/08/12 05:02:44 yar Exp % .\" .\" $FreeBSD: doc/ja_JP.eucJP/man/man8/sysctl.8,v 1.20 2001/08/15 03:17:01 horikawa Exp $ .\" .Dd May 28, 2001 .Dt SYSCTL 8 .Os .Sh 名称 .Nm sysctl .Nd カーネル状態の取得や設定 .Sh 書式 .Nm .Op Fl bNnox .Ar name Ns Op = Ns Ar value .Ar ... .Nm .Op Fl bNnox .Fl a .Sh 解説 .Nm はカーネル状態を取り出し、適切な権限があれば プロセスがカーネル状態を設定することを許します。取り出され たり、設定されたりした状態は、 .Pq Management Information Base .Pq Dq MIB 形式を使って記述されます。この形式では、要素はドット ``.'' で 接続されます。 .Pp 以下のオプションを使用可能です: .Bl -tag -width indent .It Fl A .Fl o a と等価です (互換性用)。 .It Fl a 現在利用可能な、データ形式を知らないもの(以下、形式不明の変数と称する) でない値を列挙します。 1 個以上の変数名がコマンドラインに指定された場合、 本オプションは無視されます。 .It Fl b 変数の値を加工せずに、バイナリ形式で表示します。 変数名や、最後の改行文字は出力されません。これは、単一の変数に対して 操作する際に便利でしょう。 .It Fl N 値の出力は抑制されて、変数名のみを表示します。 プログラム可能な補完機能を持つシェルで、有用です。 .Nm zsh で変数名を補完するには、次のコードを使用します: .Bd -literal -offset indent listsysctls () { set -A reply $(sysctl -AN ${1%.*}) } compctl -K listsysctls sysctl .Ed .It Fl n 変数名の出力は抑制されて、値だけが表示されます。 これはシェル変数を設定するのに役に立ちます。 たとえば、ページサイズを変数 .Va psize に保存するには、以下のようにします: .Bd -literal -offset indent -compact set psize=`sysctl -n hw.pagesize` .Ed .It Fl o 形式不明な値を表示します (通常は抑制されます)。 書式と長さが表示され、値の最初の 16 バイトが 16 進数でダンプされます。 .It Fl X .Fl x a と等価です (互換性用)。 .It Fl x .Fl o と同様ですが、 形式不明の変数の最初の数バイトの代りに全ての内容が 16 進数でダンプされます。 .El .Nm で得られる情報は、整数、文字列、形式不明の変数です。 .Nm はいくつかの形式不明の変数の形式を知っているだけで、それ以外のものに 対しては 16 進ダンプに頼ります。 形式不明の変数の情報は、 .Nm ps , .Nm systat , .Nm netstat などの特別な目的のプログラムによって取得された場合に、より効果的です。 .Pp 文字列と整数の情報を簡単にまとめて以下に示します。これらの 変数の詳細な説明は、 .Xr sysctl 3 を参照してください。 .Pp 変更可能の列は、適切な権限を持つプロセスがその値を変更 できるかどうかを示しています。 .Bl -column net.inet.ip.forwardingxxxxxx integerxxx .It Sy "名称 型 変更可能 .It "kern.ostype 文字列 no .It "kern.osrelease 文字列 no .It "kern.osrevision 整数 no .It "kern.version 文字列 no .It "kern.maxvnodes 整数 yes .It "kern.maxproc 整数 no .It "kern.maxprocperuid 整数 yes .It "kern.maxfiles 整数 yes .It "kern.maxfilesperproc 整数 yes .It "kern.argmax 整数 no .It "kern.securelevel 整数 増やすのみ .It "kern.hostname 文字列 yes .It "kern.hostid 整数 yes .It "kern.clockrate struct no .It "kern.posix1version 整数 no .It "kern.ngroups 整数 no .It "kern.job_control 整数 no .It "kern.saved_ids 整数 no .It "kern.boottime struct no .It "kern.domainname 文字列 yes .It "kern.filedelay 整数 yes .It "kern.dirdelay 整数 yes .It "kern.metadelay 整数 yes .It "kern.osreldate 文字列 no .It "kern.bootfile 文字列 yes .It "kern.corefile 文字列 yes .It "kern.logsigexit 整数 yes .It "vm.loadavg struct no .It "hw.machine 文字列 no .It "hw.model 文字列 no .It "hw.ncpu 整数 no .It "hw.byteorder 整数 no .It "hw.physmem 整数 no .It "hw.usermem 整数 no .It "hw.pagesize 整数 no .It "hw.floatingpoint 整数 no .It "hw.machine_arch 文字列 no .It "machdep.console_device dev_t no .It "machdep.adjkerntz 整数 yes .It "machdep.disable_rtc_set 整数 yes .It "user.cs_path 文字列 no .It "user.bc_base_max 整数 no .It "user.bc_dim_max 整数 no .It "user.bc_scale_max 整数 no .It "user.bc_string_max 整数 no .It "user.coll_weights_max 整数 no .It "user.expr_nest_max 整数 no .It "user.line_max 整数 no .It "user.re_dup_max 整数 no .It "user.posix2_version 整数 no .It "user.posix2_c_bind 整数 no .It "user.posix2_c_dev 整数 no .It "user.posix2_char_term 整数 no .It "user.posix2_fort_dev 整数 no .It "user.posix2_fort_run 整数 no .It "user.posix2_localedef 整数 no .It "user.posix2_sw_dev 整数 no .It "user.posix2_upe 整数 no .It "user.stream_max 整数 no .It "user.tzname_max 整数 no .El .Sh 使用例 たとえば、システム中で許されている最大のプロセス数を知りたい ときは、以下のようにします: .Pp .Dl "sysctl kern.maxproc" .Pp システム中で許されている最大のプロセス数を 1000 に設定する には、以下のようにします: .Pp .Dl "sysctl kern.maxprocperuid=1000" .Pp システムのクロックレートに関する情報を得るには、以下の ようにします: .Pp .Dl "sysctl kern.clockrate" .Pp システム負荷 (ロード・アベレージ) の履歴に関する情報を 得るには、以下のようにします: .Pp .Dl "sysctl vm.loadavg" .Pp ここに挙げたもの以外の変数も存在します。それらに関するより深い意味を知る もっとも良く、かつ、おそらく唯一の方法は、それらを定義しているソースコードを みる事であることは疑いのない事実でしょう。 .Sh 関連ファイル .Bl -tag -width ".Aq Pa netinet/icmp_var.h" -compact .It Aq Pa sys/sysctl.h トップレベルの識別子、第 2 レベルのカーネル/ハードウェア識別子、 そしてユーザレベル識別子の定義 .It Aq Pa sys/socket.h 第 2 レベルのネットワーク識別子の定義 .It Aq Pa sys/gmon.h 第 3 レベルのプロファイル識別子の定義 .It Aq Pa vm/vm_param.h 第 2 レベルの仮想メモリ識別子の定義 .It Aq Pa netinet/in.h 第 3 レベルのインターネット識別子と 第 4 レベルの IP 識別子の定義 .It Aq Pa netinet/icmp_var.h 第 4 レベルの ICMP 識別子の定義 .It Aq Pa netinet/udp_var.h 第 4 レベルの UDP 識別子の定義 .El .Sh 互換性 .Fl w オプションは推奨されておらず、黙って無視されます。 .Sh 関連項目 .Xr sysctl 3 , .Xr sysctl.conf 5 .Sh バグ 現状では .Nm は、sysctl ツリーの追跡、および、形式と名前の情報を得る際に、 文書化されていないカーネルの sysctl 機能へのインタフェースを使用しています。 この方法に関する正しいインタフェースは、現在検討中です。 .Sh 歴史 .Nm は .Bx 4.4 ではじめて登場しました。 .Pp .Fx 2.2 の .Nm は著しく改良されています。