snmprealwalk

(PHP 3 >= 3.0.8, PHP 4, PHP 5)

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

Description

array snmprealwalk ( string host, string community, string object_id [, int timeout [, int retries]] )

Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.



snmprealwalk
railson at amixsi dot com dot br
30-May-2006 10:52
Attention: timeout is in microseconds (multiply by 1,000,000 for seconds)
Stephen Cope
09-Sep-2004 08:38
Here's a way to find the uptime and number of users on a machine. (Note that uptime is the uptime of the snmpd daemon, which should be fairly close to the uptime for the host.)

<?php
       $state
= snmprealwalk($host, "public", ".1.3.6.1.2.1.25.1", 50, 1);
      
$uptime = ereg_replace("^.*\) ([0-9]+ .*):[0-9][0-9]\.[0-9]{2}.*$", "\\1", $state['host.hrSystem.hrSystemUptime.0']);
      
$users  = (int)ereg_replace("Gauge32: ", "", $state['host.hrSystem.hrSystemNumUsers.0']);
      
printf('<div class="machine"><dt>%s</dt><dd>%s</dd>', $host, $desc);
      
printf('<dd>up %s</dd>', $uptime);
       if (
$users ) printf('<dd>%d user%s</dd>', $users, ($users > 1) ? 's' : '');
      
printf('</div>');
?>
Lars Troen
24-Feb-2003 05:30
snmprealwalk indexes the values using the oid instead of an integer. This is useful when you need data that is contained in the oid as well as the value.

Here's an example for retrieving and printing vlan info:
//
// I have collected the vlan identifiers earlier from the 3com mib and they are stored in the $vlan table.
//
  for($n=0;$n<count($vlan);$n++){
   print $vlan[$n][id]."  ".$vlan[$n][name]."<br>\n";
   $ifStackStatusTable=@snmprealwalk($switch, $community, ".1.3.6.1.2.1.31.1.2.1.3.".$vlan[$n][id]); // ifMIB.ifMIBObjects.ifStackTable.ifStackEntry.ifStackStatus
   for(reset($ifStackStatusTable);  $port = key($ifStackStatusTable);  next($ifStackStatusTable)){
     print "$port=$ifStackStatusTable[$port]<br>";
     }

<snmpgetnextsnmpset>
 Last updated: Tue, 15 Nov 2005