PHP Doku:: Abfrage über einen Baum einer Netzwerkeinheit. - function.snmpwalkoid.html

Verlauf / Chronik / History: (12) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteSNMPSNMP-Funktionensnmpwalkoid

Ein Service von Reinhard Neidl - Webprogrammierung.

SNMP-Funktionen

<<snmpwalk

Sockets>>

snmpwalkoid

(PHP 4, PHP 5)

snmpwalkoidAbfrage über einen Baum einer Netzwerkeinheit.

Beschreibung

array snmpwalkoid ( string $hostname , string $community , string $object_id [, int $timeout [, int $retries ]] )

Gibt ein assoziatives Array mit den Objekt Ids und den dazugehörigen Objektwerten zurück, der mit der object_id als Wurzel beginnt, oder FALSE bei einem Fehler.

Die snmpwalkoid() Funktion wird verwendet um alle Werte von dem SNMP Agenten zu lesen, der bei hostname angegeben wurde. Der Community Parameter bestimmt die Lese-"Community" für diesen Agenten. Ein NULL object_id wird als Wurzel des SNMP Objektbaums verwendet und alle Objekts unter diesem Baum als ein Array zurückgegeben. Wenn object_id angegeben wird, werden alle SNMP Objekte unterhalb der object_id zurückgegeben.

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

$a = snmpwalkoid("127.0.0.1", "public", "");

Der obige Funktionsaufruf gibt alle SNMP Objekte des Agenten, der auf localhost läuft, zurück. Man kann mit einer Schleife alle Werte durchlaufen.

for ($i=0; $i < count($a); $i++) {
    echo $a[$i];
}


3 BenutzerBeiträge:
- Beiträge aktualisieren...
thammer at rtccom dot com
14.06.2005 17:29
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
gene_wood at example dot com
14.10.2004 18:23
Looks like timeout is in MICRO seconds.
1,000,000 &micros = 1 s
jasper at pointless dot net
7.01.2001 4:21
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...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)