PHP 8.1.28 Released!

snmpwalkoid

(PHP 4, PHP 5, PHP 7, PHP 8)

snmpwalkoidネットワークエンティティに関する情報ツリーを検索する

説明

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

snmpwalkoid() 関数は、hostname で指定した SNMP エージェントから すべてのオブジェクト ID とその値を読みこむために使用します。

snmpwalkoid() および snmpwalk() は、歴史的経緯により残されているものです。 どちらも、下位互換のために提供されています。 代わりに snmprealwalk() を使用してください。

パラメータ

hostname

SNMP エージェント。

community

リードコミュニティ。

object_id

null の場合は、object_id が SNMP オブジェクトツリーのルートとして解釈され、 ツリーの配下のすべてのオブジェクトを配列として返します。

object_id を指定した場合は、 その object_id の配下のすべての SNMP オブジェクトを返します。

timeout

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

retries

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

戻り値

object_id() からの SNMP オブジェクトの値の配列をルートとして返します。 エラーの場合に false を返します。

例1 snmpwalkoid() の例

<?php
$a
= snmpwalkoid("127.0.0.1", "public", "");
for (
reset($a); $i = key($a); next($a)) {
echo
"$i: $a[$i]<br />\n";
}
?>

上記の関数コールは、ローカルホスト上で稼働する SNMP エージェントからすべての SNMP オブジェクトを返します。 ループ処理により値を一つずつとりだすことができます。

参考

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

add a note

User Contributed Notes 4 notes

up
0
Anonymous
9 years ago
make sure you install "snmp-mibs-downloader" in debian.

apt-get install snmp-mibs-downloader

you my also need to edit your /etc/apt/sources.list

deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free
up
0
thammer at rtccom dot com
18 years ago
The above note mentions that the MAC addresses come back converted to integers or something funky like that. Not sure why that is happening but I fixed that with a wrapper function.

function PadMAC($mac) {
$mac_arr = explode(':',$mac);
foreach($mac_arr as $atom) {
$atom = trim($atom);
$newarr[] = sprintf("%02s",$atom);
}
$newmac = implode(':',$newarr);
return $newmac;
}

Maybe that will help somebody with that issue. I know I personally use the heck out of these user contributed notes
up
0
gene_wood at example dot com
19 years ago
Looks like timeout is in MICRO seconds.
1,000,000 &micros = 1 s
up
0
jasper at pointless dot net
23 years ago
N.B. it's possible for snmpwalkoid to lose data - the "rmon.matrix.matrixSDTable" table for example uses binary mac addresses as part of the index, these get converted to ascii, and by the time they get to php they can be non-unique - so some entrys in the table get lost...
To Top