CakeFest 2024: The Official CakePHP Conference

snmp2_real_walk

(PHP >= 5.2.0, PHP 7, PHP 8)

snmp2_real_walk指定したすべてのオブジェクトとそのオブジェクト ID を返す

説明

snmp2_real_walk(
    string $hostname,
    string $community,
    array|string $object_id,
    int $timeout = -1,
    int $retries = -1
): array|false

snmp2_real_walk() 関数は、 object_id から始まる SNMP オブジェクトを走査し、その値とオブジェクト ID を返します。

パラメータ

hostname

SNMP エージェント (サーバー) のホスト名。

community

リードコミュニティ。

object_id

前にある SNMP オブジェクト ID。

timeout

最初のタイムアウトまでのマイクロ秒数。

retries

タイムアウト発生時の再試行回数。

戻り値

成功した場合に SNMP オブジェクト ID とその値の連想配列。エラー時に false を返します。 エラー時には E_WARNING が発生します。

例1 snmp2_real_walk() の使用法

<?php
print_r
(snmp2_real_walk("localhost", "public", "IF-MIB::ifName"));
?>

上の例の結果は次のようになります。

Array
      (
      [IF-MIB::ifName.1] => STRING: lo
      [IF-MIB::ifName.2] => STRING: eth0
      [IF-MIB::ifName.3] => STRING: eth2
      [IF-MIB::ifName.4] => STRING: sit0
      [IF-MIB::ifName.5] => STRING: sixxs
    )

参考

  • snmp2_walk() - すべての SNMP オブジェクトをエージェントから取得する

add a note

User Contributed Notes 1 note

up
1
mike dot mackintosh at angrystatic dot com
12 years ago
Remember that the timeout includes trip time for transport, so setting it too low and sending it across the country will time out and return a 'No response from x.x.x.x'
To Top