Ver código fonte

Changed method that get cache to check before if redis is working, and modified the search for stats onus and applied command to check the serial pon from a ONU

Jean Sumara 5 anos atrás
pai
commit
1b7af24757
1 arquivos alterados com 17 adições e 4 exclusões
  1. 17 4
      src/StatsBundle/Controller/StatsController.php

+ 17 - 4
src/StatsBundle/Controller/StatsController.php

@@ -1785,7 +1785,19 @@ class StatsController extends Controller
         $cers = $snrs = $utilizations = $errors = $series = $targets = array();
 
         $key = "olt_scan_card_{$prefix}";
-        $dataCached = $redis->get($key);
+        $getCache = false;
+
+        try{
+            if($redis->ping() == "PONG"){
+                $getCache = true;
+            }
+        }catch (\Exception $e){
+            $getCache = false;
+        }
+
+        if($getCache){
+            $dataCached = $redis->get($key);
+        }
 
         /* % cpu & memory cards */
         (isset($dataCached['cpu'])) ? $cpu = $dataCached['cpu'] : $cpu = array();
@@ -1908,20 +1920,21 @@ class StatsController extends Controller
 
     public function onuSignal($oltDeviceId, $serverId)
     {
-
         $em = $this->get('doctrine')->getManager();
         $onus = $em->getRepository('StatsBundle:Onu')->createQueryBuilder('o')
             ->select('o.txPower', 'o.rxPowerOlt', 'o.ponSerialNumber')
             ->where('o.deviceServer = :serverId')
             ->andWhere('o.oltDeviceId = :oltDeviceId')
+            ->andWhere('o.txPower IS NOT NULL')
+            ->andWhere('o.rxPowerOlt IS NOT NULL')
             ->setParameter('serverId', $serverId)
             ->setParameter('oltDeviceId', $oltDeviceId)
             ->getQuery()->getResult();
 
-        $colors = $signals = array();
+        $signals = array();
 
         foreach ($onus as $data) {
-            if ($data['txPower'] == null || $data['rxPowerOlt'] == null) continue;
+            if (preg_match("/^[a-zA-Z0-9]+$/", $data['ponSerialNumber']) != 1) continue;
 
             $color = $this->getOnuRxColor($data['rxPowerOlt']);