1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.10 $ -->
<reference id="ref.snmp">
<title>SNMP関数</title>
<titleabbrev>SNMP</titleabbrev>
<partintro>
<simpara>
UNIX上でSNMP関数を使用するためには、<ulink url="&url.ucd-snmp;">
UCD SNMP</ulink>パッケージをインストールする必要があります。
Windows上では、これらの関数は NT 上でのみ利用可能であり、
Win95/98 では利用できません。
</simpara>
<simpara>
重要: UCD SNMP パッケージを使用するには、コンパイル前に
NO_ZEROLENGTH_COMMUNITYを1に定義する必要があります。UCD SNMPのコン
フィグレーションを行った後、config.hを編集し、
NO_ZEROLENGTH_COMMUNITY を探してください。
#define の行のコメントを外してください。
これにより、次のようになるはずです。
</simpara>
<para>
<programlisting role="c">
<![CDATA[
#define NO_ZEROLENGTH_COMMUNITY 1
]]>
</programlisting>
</para>
<simpara>
SNMP コマンドと組み合わせた場合に奇妙なセグメント例外が生じる場合
は、上の指示に従っていないと思われます。UCD SNMPを再コンパイルした
くない場合は、この不具合に対処するため、PHPを
--enable-ucd-snmp-hack スイッチをつけてコンパイルしてください。
</simpara>
</partintro>
<refentry id="function.snmpget">
<refnamediv>
<refname>snmpget</refname>
<refpurpose>SNMPオブジェクトを取得する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>string</type><methodname>snmpget</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>timeout</optional></replaceable>
</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>retries</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
成功したらSNMPオブジェクトの値を、失敗した場合に&false;を返します。
</para>
<para>
<function>snmpget</function>は<parameter>object_id</parameter>で
指定されるSNMPオブジェクトの値を読みとるために使用されます。
SNMPエージェントを<parameter>hostname</parameter>で指定し、
リードコミュニティをパラメータ<parameter>community</parameter>
で指定します。
</para>
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
$syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0");
]]>
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.snmpset">
<refnamediv>
<refname>snmpset</refname>
<refpurpose>SNMP オブジェクトを設定する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>snmpset</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam><type>string</type><parameter>type</parameter></methodparam>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>timeout</optional></replaceable>
</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>retries</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
指定した SNMP オブジェクトの値を設定し、成功時に&true;、エラー時
に&false;を返します。
</para>
<para>
<function>snmpset</function> 関数は、
<parameter>object_id</parameter>で指定された SNMP オブジェクトの
値を設定するために使用されます。SNMP エージェントを
<parameter>hostname</parameter>で指定し、リードコミュニティを
<parameter>community</parameter>パラメータで指定します。
</para>
</refsect1>
</refentry>
<refentry id="function.snmpwalk">
<refnamediv>
<refname>snmpwalk</refname>
<refpurpose>エージェントから全てのSNMPオブジェクトを取りだす</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>array</type><methodname>snmpwalk</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>timeout</optional></replaceable>
</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>retries</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
<function>object_id</function>からルートとしてSNMPオブジェクト
の値を配列として返します。エラーの場合に&false;を返します。
</para>
<para>
<function>snmpwalk</function>関数は<parameter>hostname</parameter>
で指定したSNMPエージェントから全ての値を読みとるのに使用されます。
<parameter>community</parameter>は、そのエージェントに対する
リードコミュニティを指定します。空の<parameter>object_id</parameter>
は、SNMPオブジェクトツリーのルートとして解釈され、ツリーの下の全ての
オブジェクトが配列として返されます。
<parameter>object_id</parameter>が指定された場合、
その <parameter>object_id</parameter>の下の
全てのSNMPオブジェクトが返されます。
<informalexample>
<programlisting role="php">
<![CDATA[
$a = snmpwalk("127.0.0.1", "public", "");
]]>
</programlisting>
</informalexample>
</para>
<para>
上記の関数コールは、ローカルホスト上で稼働するSNMP
エージェントから全てのSNMPオブジェクトを返します。
ループ処理により値を一つずつとりだすことができます。
<informalexample>
<programlisting role="php">
<![CDATA[
for ($i=0; $i < count($a); $i++) {
echo $a[$i];
}
]]>
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.snmpwalkoid">
<refnamediv>
<refname>snmpwalkoid</refname>
<refpurpose>ネットワークエンティティに関する情報ツリーの検索
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>array</type><methodname>snmpwalkoid</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>timeout</optional></replaceable>
</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>retries</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
各オブジェクトのIDとその値をルートとして指定した
<parameter>object_id</parameter> から始まる連想配列として返します。
エラーの場合は&false;を返します。
</para>
<para>
<function>snmpwalkoid</function> 関数は、hostname で指定した
SNMP エージェントから全てのオブジェクトIDとその値を読みこむ
ために使用されます。
<parameter>community</parameter> は、そのエージェントの
リードコミュニティを指定します。
<parameter>object_id</parameter> を&null;とした場合は、
そのSNMPオブジェクトツリーのルートを指定したことになり、
そのツリー以下の全てのオブジェクトが配列として返されます。
<parameter>object_id</parameter> が指定された場合、
<parameter>object_id</parameter> 以下の
全ての SNMP オブジェクトが返されます。
</para>
<para>
<function>snmpwalkoid</function> および
<function>snmpwalk</function> があるのは、これまでの経緯
によります。
両方の関数は、下位互換のために提供されています。
<informalexample>
<programlisting role="php">
<![CDATA[
$a = snmpwalkoid("127.0.0.1", "public", "");
]]>
</programlisting>
</informalexample>
</para>
<para>
上の関数コールは、localhost で実行されている SNMP エージェントから
全ての SNMP オブジェクトを返します。
各値は、次のループにより取り出すことができます。
<informalexample>
<programlisting role="php">
<![CDATA[
for (reset($a); $i = key($a); next($a)) {
echo "$i: $a[$i]<br>\n";
}
]]>
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.snmp-get-quick-print">
<refnamediv>
<refname>snmp_get_quick_print</refname>
<refpurpose>
UCD ライブラリの quick_print の現在の設定値を取得する
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>snmp_get_quick_print</methodname>
<void/>
</methodsynopsis>
<para>
UCD ライブラリに保持された quick_print の現在の値を返します。
デフォルトでは、quick_print はオフです。
<informalexample>
<programlisting role="php">
<![CDATA[
$quickprint = snmp_get_quick_print();
]]>
</programlisting>
</informalexample>
</para>
<para>
上の関数コールは、quick_print がオフの場合に&false;、quick_print
がオンの場合に&true;を返します。
</para>
<para>
<function>snmp_get_quick_print</function> は、UCB SNMP ライブラリを
使用している場合のみ利用可能です。
この関数は、Windows SNMP ライブラリを使用している場合は利用できま
せん。
</para>
<para>
参照: <function>snmp_set_quick_print</function> に quick_print の
役割に関する詳細な説明があります。
</para>
</refsect1>
</refentry>
<refentry id="function.snmp-set-quick-print">
<refnamediv>
<refname>snmp_set_quick_print</refname>
<refpurpose>UCB SNMP ライブラリで quick_print の値を設定する
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>void</type><methodname>snmp_set_quick_print</methodname>
<methodparam><type>bool</type><parameter>quick_print</parameter></methodparam>
</methodsynopsis>
<para>
UCB SNMP ライブラリで quick_print の値を設定します。この値を
(1) に設定した場合、SNMP ライブラリは、'簡潔に表示された
(quick printed)' 値を返します。
これは、値のみが出力されることを意味します。
quick_print が有効でない場合(デフォルト)、UCD SNMP ライブラリは、
(IPアドレスまたは OIDのような)その値の種類を含むより詳細な情報を
出力します。
加えて、quick_print が有効でない場合、ライブラリは3文字以下の全ての
文字列について16進数値も出力します。
</para>
<para>
quick_print の設定は、返される情報を吟味してから表示する場合に
使用されることが多いです。
<informalexample>
<programlisting role="php">
<![CDATA[
snmp_set_quick_print(0);
$a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1");
echo "$a<BR>\n";
snmp_set_quick_print(1);
$a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1");
echo "$a<BR>\n";
]]>
</programlisting>
</informalexample>
</para>
<para>
最初に出力される値は、'Timeticks: (0) 0:00:00.00' のようになります。
一方、quick_print を有効にした後は、0:00:00.00' が出力されます。
</para>
<para>
デフォルトで、UCD SNMP ライブラリは冗長な値を返します。
quick_print は、値のみを返すために用いられます。
</para>
<para>
現在、文字列は引用符で括られて返されますが、この動作は将来の
リリースでは修正される予定です。
</para>
<para>
<function>snmp_set_quick_print</function> は、UCD SNMP ライブラリ
を使用している場合のみ利用可能です。
この関数は、Windows SNMP ライブラリを使用している場合には
利用できません。
</para>
</refsect1>
</refentry>
<refentry id='function.snmprealwalk'>
<refnamediv>
<refname>snmprealwalk</refname>
<refpurpose>
指定したオブジェクトに関するオブジェクトIDを含む全てのオブジェク
トを返す
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>array</type><methodname>snmprealwalk</methodname>
<methodparam><type>string</type><parameter>host</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>retries</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
|