Explorar el Código

Agregue metodos para consultar ip y mac de cablemodems en cmts

Luciano Andrade hace 11 años
padre
commit
3a879cfcb1
Se han modificado 2 ficheros con 38 adiciones y 7 borrados
  1. 33 4
      OSS_SNMP/MIBS/DocsIfCmts.php
  2. 5 3
      OSS_SNMP/SNMP.php

+ 33 - 4
OSS_SNMP/MIBS/DocsIfCmts.php

@@ -21,6 +21,34 @@ class DocsIfCmts extends \OSS_SNMP\MIB {
     const OID_docsIfSigQSignalNoise		= "1.3.6.1.2.1.10.127.1.1.4.1.5";
     const OID_docsIfSigQMicroreflections        = "1.3.6.1.2.1.10.127.1.1.4.1.6";
     const docsIfCmtsChannelUtilization        = "1.3.6.1.2.1.10.127.1.3.9.1.3";
+    const OID_ipNetToMediaPhysAddress 		= "1.3.6.1.2.1.4.22.1.2";
+    const OID_docsIfCmtsCmPtr  			= "1.3.6.1.2.1.10.127.1.3.7.1.2";
+
+
+    public function docsIfCmtsCmPtr(){
+	$ptr = array();
+	$ptr2 = $this->docsIfCmtsCmStatusIpAddress();
+	foreach($this->getSNMP()->realWalk(self::OID_docsIfCmtsCmPtr) as $key => $val){
+		$mac =implode('',array_map(function($x) { return sprintf("%02x", $x);}, array_slice(explode(".",$key),14,6)));
+		$ptr[$mac] = $ptr2[$this->getSNMP()->parseSnmpValue($val)];
+	}
+	return $ptr;
+    }
+
+    public function ipNetToMediaPhysAddress(){
+	$rtr = array();
+        foreach($this->getSNMP()->realWalk(self::OID_ipNetToMediaPhysAddress) as $k => $m){
+////tring(40) ".1.3.6.1.2.1.4.22.1.2.2000001.10.14.8.69"
+//string(23) "STRING: 0:c:e5:7d:93:d0"                  
+////
+		$karray = preg_split("|\.|",$k);
+		$mac = preg_split("|:|", trim(substr($m,8)));
+		$mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x",$mac[0], $mac[1], $mac[2], $mac[3], $mac[4], $mac[5]);
+		$l_ke = count($karray);
+		$rtr[$mac] = sprintf("%d.%d.%d.%d",$karray[$l_ke - 4],$karray[$l_ke - 3], $karray[$l_ke - 2], $karray[$l_ke-1]);
+	}
+	return $rtr;
+    }
 
     public function docsQos3ServiceFlowDirection(){
 	try{
@@ -120,9 +148,9 @@ accessDenied(7)   The CMTS has sent a Registration Aborted message   to the CM
     	return $this->getSNMP()->walk1d(self::OID_docsIfCmtsCmStatusDownChannelIfIndex);
     }
 
-    //public function docsIfCmtsCmStatusIpAddress(){
-    //    return $this->getSNMP()->walk1d(self::OID_docsIfCmtsCmStatusIpAddress);
-    //}
+    public function docsIfCmtsCmStatusIpAddress(){
+        return $this->getSNMP()->walk1d(self::OID_docsIfCmtsCmStatusIpAddress);
+    }
 
 
     public function docsIfCmtsCmStatusValue(){	
@@ -136,7 +164,8 @@ accessDenied(7)   The CMTS has sent a Registration Aborted message   to the CM
     }
 
     public function docsIfCmtsCmStatusRxPower(){
-	return $this->getSNMP()->walk1d(self::OID_docsIfCmtsCmStatusRxPower);
+	$rtr = $this->getSNMP()->walk1d(self::OID_docsIfCmtsCmStatusRxPower);
+	return $rtr;
     }
 
     public function docsIfSigQSignalNoise(){

+ 5 - 3
OSS_SNMP/SNMP.php

@@ -358,10 +358,12 @@ class SNMP
                 break;
 
             case 'INTEGER':
-                if( !is_numeric( $value ) )
-                    $rtn = (int)substr( substr( $value, strpos( $value, '(' ) + 1 ), 0, -1 );
+                if( !is_numeric( $value ) and substr($value, 0,1) != '-')
+                    $rtn = (float)substr( substr( $value, strpos( $value, '(' ) + 1 ), 0, -1 );
                 else
-                    $rtn = (int)$value;
+                    $rtn = (float)$value;
+
+		if($rtn == (int)$rtn) $rtn = (int) $rtn;
                 break;
 
             case 'Counter32':