PHP 8.3.4 Released!

snmpwalkoid

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

snmpwalkoidRuft den Informationsbaum einer Netzwerkeinheit ab

Beschreibung

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

Die Funktion snmpwalkoid() wird verwendet, um alle Objektkennungen und deren Werte von dem SNMP-Agenten zu lesen, der bei hostname angegeben wurde.

Die Existenz von snmpwalkoid() und snmpwalk() hat historische Gründe. Beide Funktionen gibt es aus Kompatiblitätsgründen. Stattdessen ist snmprealwalk() zu verwenden.

Parameter-Liste

hostname

Der SNMP-Agent.

community

Die "read community".

object_id

Wenn null, wird object_id als Wurzel des SNMP-Objektbaums interpretiert und alle Objekte in diesem Baum werden als Array zurückgegeben.

Wird object_id angegeben, werden alle SNMP-Objekte unter dieser object_id zurückgegeben.

timeout

Die Anzahl der Mikrosekunden bis zum ersten Timeout.

retries

Die Anzahl der Wiederholungsversuche, wenn Timeouts auftreten.

Rückgabewerte

Gibt ein assoziatives Array mit Objektkennungen und deren entsprechenden Objektwerten, beginnend mit object_id als Wurzel, zurück oder false im Fehlerfall.

Beispiele

Beispiel #1 snmpwalkoid()-Beispiel

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

Der obige Funktionsaufruf gibt alle SNMP-Objekte des SNMP-Agenten, der auf localhost läuft, zurück. In einer Schleife können alle Werte durchlaufen werden.

Siehe auch

  • snmprealwalk() - Return all objects including their respective object ID within the specified one

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