瀏覽代碼

Se actualiza comando para consultar cm, añadiendo una reducción de tiempo en SNMP para los casos que no responden y cortando las consultas al tercer envío SNMP sin respuesta.

Maxi Schvindt 7 年之前
父節點
當前提交
01f3985c37
共有 2 個文件被更改,包括 27 次插入4 次删除
  1. 23 2
      Command/CmtsCmStatsCommand.php
  2. 4 2
      SNMP/MIBS/OIDSBase.php

+ 23 - 2
Command/CmtsCmStatsCommand.php

@@ -2,6 +2,8 @@
 # bin/console cmts:cm:stats --cmts-device-id=14 --cmts-server-id=1 --cm-ip=10.42.0.27 --cm-mac=00237406d524 --cm-community=public
 # http://200.50.168.115/Provisioning/admin/cablemodem/00237406d524
 
+# bin/console cmts:cm:stats --cmts-device-id=14 --cmts-server-id=1 --cm-ip=10.42.0.27 --cm-mac=0011e3039a4a --cm-community=public
+
 namespace CmtsBundle\Command;
 
 use BaseStatsBundle\Command\BaseCmCommand;
@@ -46,13 +48,27 @@ class CmtsCmStatsCommand extends BaseCmCommand
         $inicio = microtime(true);
 
         $SNMP = new SNMP($this->cmIp, $this->cmCommunity);
-        $SNMP->setTimeout(5000000); // 5 seconds of timeout
+        $SNMP->setTimeout(2500000); // 2.5 seconds of timeout
         $SNMP->setRetry(1); // 1 query per metric
         $library = "use".$this->cmSnmpLibrary;
         $this->apiSNMP = $SNMP->$library();
         
+        $uptime = $this->getSNMP("sysUpTimeInstance","cmUptime");
+        if(!$uptime) $SNMP->setTimeout(1000000); // 1 seconds of timeout
+        
         $txPower = $this->getSNMP("docsIfCmStatusTxPower","cmTxPower");
+        if($txPower) $SNMP->setTimeout(2500000);
+
         $rxPower = $this->getSNMP("docsIfDownChannelPower","cmRxPower");
+
+        if(!$txPower && !$rxPower) {
+            $this->removeLock($this->flag);
+            $fin = microtime(true);
+            $time = $fin - $inicio;
+            $this->output->writeln("CM no responde uptime, tx y rx => cortamos! Tiempo: $time segundos");
+            return true;
+        }
+
         $signal = $this->getSNMP("docsIfSigQSignalNoise","cmSignal");
         $microreflection = $this->getSNMP("docsIfSigQMicroreflections","cmMicroreflection");
         $unerroreds = $this->getSNMP("docsIfSigQUnerroreds","cmUnerroreds");
@@ -81,6 +97,11 @@ class CmtsCmStatsCommand extends BaseCmCommand
             }
         }
 
+        if($uptime) {
+            foreach($uptime as $oid => $value) {
+                $data['uptime'] = $value;
+            }
+        }
 
         $this->hset($key_cm_stats, $this->cmMac, $data, true);
 
@@ -92,7 +113,7 @@ class CmtsCmStatsCommand extends BaseCmCommand
             $statsdService->send($sendData);
             $t_end_script = microtime(true); 
             $time = $t_end_script - $t_start_script;
-            print_r("Tiempo de envío al StatsD: {$time} ms / Cantidad: ".count($sendData).PHP_EOL);
+            $this->output->writeln("Tiempo de envío al StatsD: {$time} ms / Cantidad: ".count($sendData));
         }
 
         /* End Of Blockout */

+ 4 - 2
SNMP/MIBS/OIDSBase.php

@@ -21,8 +21,7 @@ class OIDSBase extends \CmtsBundle\SNMP\MIB {
     const OID_docsIfSigQCorrecteds = "1.3.6.1.2.1.10.127.1.1.4.1.3"; //SNMP contra CM .channelCm > Correcteds
     const OID_docsIfSigQUncorrectables = "1.3.6.1.2.1.10.127.1.1.4.1.4"; //SNMP contra CM .channelCm > Uncorrectables
 
-
-
+    const OID_sysUpTimeInstance = "1.3.6.1.2.1.1.3.0"; //SNMP contra CM > uptime CM Format: Timeticks: (213988400) 24 days, 18:24:44.00
 
 
 
@@ -128,5 +127,8 @@ class OIDSBase extends \CmtsBundle\SNMP\MIB {
     public function docsIfSigQUncorrectables() {
         return $this->getSNMP()->lastOidWalk(self::OID_docsIfSigQUncorrectables,14);
     }
+    public function sysUpTimeInstance() {
+        return $this->getSNMP()->realWalkV1(self::OID_sysUpTimeInstance);
+    }
     
 }