Example #1
0
 function testNET_SNMP_Tree()
 {
     //
     // SNMP
     //
     $SNMPTree = new SNMPTree();
     $SNMPTree->Connect(SNMP_AGENT_IP, null, "public");
     $SNMPTree->SetMIB("HOST-RESOURCES-MIB", "hr");
     $result = $SNMPTree->GetSystemUptime();
     $this->assertTrue(is_string($result), "SNMP->GetSystemUptime() returned string");
     $result = $SNMPTree->GetAllStorageIndex();
     $this->assertTrue(is_array($result), "SNMP->GetAllDisks() returned array");
     //
     $descr = $SNMPTree->GetAllStorageDescr();
     $this->assertTrue(is_array($descr), "SNMP->GetAllStorageDescr() returned array");
     $sizes = $SNMPTree->GetAllStorageSize();
     $this->assertTrue(is_array($sizes), "SNMP->GetAllStorageSize() returned array");
     $useds = $SNMPTree->GetAllStorageUsed();
     $this->assertTrue(is_array($useds), "SNMP->GetAllStorageUsed() returned array");
     $procs_load = $SNMPTree->GetAllProcessorLoad();
     $this->assertTrue(is_array($procs_load), "SNMP->GetAllProcessorLoad() returned array");
 }
 public function RequestData()
 {
     $result = $this->SNMPTree->Get($this->OIDs);
     preg_match_all("/([^=]+)=([^\n]+)/", $result, $matches);
     $result = array();
     foreach ($matches[1] as $k => $v) {
         preg_match("/:[^0-9]+([0-9\\.]+)/", $matches[2][$k], $m);
         $OID = trim($v);
         $result[$OID] = $m[1];
     }
     $retval = array();
     foreach ($this->wOIDs as $wn => $oids) {
         //$retval[$wn] = array();
         $w_data = array();
         foreach ($oids as $oid) {
             $w_data[] = $result[$oid];
         }
         $this->Data[$wn] = $w_data;
     }
 }