<?php
  require_once('snmp.php');

  $ip = '172.16.0.77'; 		// ip address or hostname
  $community = 'public';	// community string
  $oid = '.1.3.6.1.2.1.1';	// only numerical oids are supported

  $snmp = new snmp();

//  $snmp->version = 2;	// version 2 is not fully tested/working

  print_r($snmp->walk($ip, $oid, $community));

  // get system uptime
  print_r($snmp->get($ip, '.1.3.6.1.2.1.1.3', $community));

  // reset a cable modem
  $oid = docsis_dev($ip) . '.1.1.3.0';
  $snmp = new snmp();
  $snmp->set($ip, $oid, 1, 'i', 'private');

/**
 * Get the DOCSIS cable modem revision oid prefix
 *
 * @param string $ip IP Address
 * @return string oid prefix
 */
  function docsis_dev($ip)
  {
    $snmp = new snmp();
    $a = @$snmp->get($ip, '.1.3.6.1.3.83.1.1.4.0');
    $b = @$snmp->get($ip, '.1.3.6.1.2.1.69.1.1.4.0');
    if(count($a) && !count($b))
      return '.1.3.6.1.3.83';
    else
      return '.1.3.6.1.2.1.69';
  }
?>
  
