瀏覽代碼

Se actualizan entidades y se generan similitudes de datos en las vistas de ONU y Cablemodem.

Maxi Schvindt 7 年之前
父節點
當前提交
a787b961db

+ 2 - 0
src/StatsBundle/Admin/CablemodemAdmin.php

@@ -92,6 +92,8 @@ class CablemodemAdmin extends BaseAdmin
             ->add('rxPower',null, array('template' => 'StatsBundle:Cablemodem:field_rx_power_in_cm.html.twig'))
             ->add('signal',null, array('template' => 'StatsBundle:Cablemodem:field_snr_power_in_cm.html.twig'))
             ->add('microreflection',null, array('template' => 'StatsBundle:Cablemodem:field_microreflection_power_in_cm.html.twig'))
+            ->add('inOctets',null, array('template' => 'StatsBundle:Cablemodem:field_octets.html.twig'))
+            ->add('outOctets',null, array('template' => 'StatsBundle:Cablemodem:field_octets.html.twig'))
             ->add('rxPowerCmts',null, array('template' => 'StatsBundle:Cablemodem:field_rx_power_in_cm.html.twig'))
             ->add('signalCmts',null, array('template' => 'StatsBundle:Cablemodem:field_snr_power_in_cm.html.twig'))
             /* ->add('microreflectionCmts',null, array('template' => 'StatsBundle:Cablemodem:field_microreflection_power_in_cm.html.twig')) */

+ 3 - 0
src/StatsBundle/Admin/OnuAdmin.php

@@ -68,12 +68,15 @@ class OnuAdmin extends BaseAdmin
             /* ->add('deviceServer') */
             ->add('oltDeviceId', 'string', array('template' => 'StatsBundle:Onu:base_list_field_olt.html.twig'))
             ->add('ponSerialNumber', 'string', array('template' => 'StatsBundle:Onu:show_link.html.twig'))
+            ->add('index')
             ->add('ponPort')
             ->add('status',null, array('template' => 'StatsBundle:Templates:field_status.html.twig'))
             ->add('txPower', 'string', array('template' => 'StatsBundle:Onu:field_tx.html.twig'))
             ->add('rxPower', 'string', array('template' => 'StatsBundle:Onu:field_rx.html.twig'))
             ->add('voltage', 'string', array('template' => 'StatsBundle:Onu:field_voltage.html.twig'))
             ->add('temperature', 'string', array('template' => 'StatsBundle:Onu:field_temperature.html.twig'))
+            ->add('inOctets',null, array('template' => 'StatsBundle:Onu:field_octets.html.twig'))
+            ->add('outOctets',null, array('template' => 'StatsBundle:Onu:field_octets.html.twig'))
             ->add('uptime', 'string', array('template' => 'StatsBundle:Onu:field_uptime.html.twig'))
             ->add('updated')
         ;

+ 9 - 1
src/StatsBundle/Command/StatsCmCommand.php

@@ -52,9 +52,11 @@ class StatsCmCommand extends BaseCommand
 
         $key_cmts_scan = "cmts_scan_{$subId}";
         $key_cmts_stats = "cm_stats_{$subId}";
+        $key_cm_octets = "cm_octets_{$subId}";
 
         $cmsCached = $this->getData($key_cmts_scan, true);
         $cmsStats = $this->hgetData($key_cmts_stats);
+        $cmOctets = $this->getData($key_cm_octets, true);
 
         $devices = $this->getCmsFromDevices($cmtsServerId);
 
@@ -115,6 +117,12 @@ class StatsCmCommand extends BaseCommand
             (isset($info['rxPower']))? $row['rxPowerCmts'] = $info['rxPower'] : $row['rxPowerCmts'] = "NULL";
             (isset($info['signal']))? $row['signalCmts'] = $info['signal'] : $row['signalCmts'] = "NULL";
             (isset($info['microreflection']))? $row['microreflectionCmts'] = $info['microreflection'] : $row['microreflectionCmts'] = "NULL";
+
+            $row['outOctets'] = $row['inOctets'] = "NULL";
+            if(isset($cmOctets[$mac])) {
+                $row['inOctets'] = $cmOctets[$mac]['inBand'];
+                $row['outOctets'] = $cmOctets[$mac]['outBand'];
+            }
             
             $data[] = "(".implode(",",$row).")".PHP_EOL;
         }
@@ -126,7 +134,7 @@ class StatsCmCommand extends BaseCommand
             $conn->close();
             
             $conn = $doctrine->getConnection();
-            $sql = "INSERT LOW_PRIORITY IGNORE INTO `cablemodem` (`id`, `device_server_id`, `cmts_device_id`, `device_id`, `ip`, `mac`, `index`, `up_if`, `down_if`, `status`, `tx_power`, `rx_power`, `signal`, `microreflection`, `correcteds`, `unerroreds`, `uncorrectables`, `uptime`, `updated`, `lat`, `lng`, `tenancy_id`, `extra_data`, `rx_power_cmts`, `signal_cmts`, `microreflection_cmts`) VALUES ".  implode(",", $data).";";
+            $sql = "INSERT LOW_PRIORITY IGNORE INTO `cablemodem` (`id`, `device_server_id`, `cmts_device_id`, `device_id`, `ip`, `mac`, `index`, `up_if`, `down_if`, `status`, `tx_power`, `rx_power`, `signal`, `microreflection`, `correcteds`, `unerroreds`, `uncorrectables`, `uptime`, `updated`, `lat`, `lng`, `tenancy_id`, `extra_data`, `rx_power_cmts`, `signal_cmts`, `microreflection_cmts`, `in_octets`, `out_octets`) VALUES ".  implode(",", $data).";";
             
             $conn->query($sql);
             $conn->close();

+ 52 - 1
src/StatsBundle/Command/StatsOnuCommand.php

@@ -49,6 +49,8 @@ class StatsOnuCommand extends BaseCommand
         $metrics = array("txPower" => "onu_tx_", "rxPower" => "onu_rx_", "temperature" => "onu_temperature_", "voltage" => "onu_voltage_", "status" => "onu_status_");
         $data = $stats = array();
 
+        $bandwidth = $this->getBandwidth($oltServerId, $oltDeviceId);
+
         foreach($metrics as $m => $metric) {
             $key_onu_stats = "{$metric}d_{$oltDeviceId}_s_{$oltServerId}";
             $stats[$metric] = $this->getData($key_onu_stats, true);
@@ -93,6 +95,16 @@ class StatsOnuCommand extends BaseCommand
             
             $row['lat'] = ($lat)?$lat:"NULL";
             $row['lng'] = ($lng)?$lng:"NULL";
+            
+            $row['index'] = $index;
+
+            if(isset($bandwidth[$lowSn])) {
+                $row['inOctets'] = $bandwidth[$lowSn]['inBand'];
+                $row['outOctets'] = $bandwidth[$lowSn]['outBand'];
+            } else {
+                $row['inOctets'] = "NULL";
+                $row['outOctets'] = "NULL";
+            }
 
             $data[] = "(".implode(",",$row).")".PHP_EOL;
         }
@@ -104,7 +116,7 @@ class StatsOnuCommand extends BaseCommand
             $conn->close();
             
             $conn = $doctrine->getConnection();
-            $sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`,`lat`,`lng`) VALUES ".  implode(",", $data).";";
+            $sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`,`lat`,`lng`,`index`,`in_octets`,`out_octets`) VALUES ".  implode(",", $data).";";
             $conn->query($sql);
             $conn->close();
         } else {
@@ -112,4 +124,43 @@ class StatsOnuCommand extends BaseCommand
         }
 
     }
+
+    private function getBandwidth($server, $olt) {
+
+        $bandwidth = array();
+        
+        $doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
+        $nass = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceServer' => $server, 'deviceType' => 'RadiusBundle\Entity\NAS'));
+
+        foreach($nass as $index => $nas) {
+            $nasId = $nas->getDeviceId();
+
+            $d_s = "d_{$nasId}_s_{$server}";
+            $key_nas_onu_bandwidth = "nas_bandwidth_onu_{$d_s}";
+
+            $bandwidthCached = $this->getData($key_nas_onu_bandwidth, true);
+
+            if(empty($bandwidthCached)) continue;
+
+            foreach($bandwidthCached as $index => $data) {
+                if(!isset($data['sn'])) continue;
+                $bandwidth[$data['sn']] = $data;
+            }
+        }
+        
+        $d_s = "d_{$olt}_s_{$server}";
+        $key_olt_onu_bandwidth = "olt_bandwidth_onu_{$d_s}";
+        
+        $bandwidthCached = $this->getData($key_olt_onu_bandwidth, true);
+        
+        if($bandwidthCached) {
+            foreach($bandwidthCached as $index => $data) {
+                if(!isset($data['sn'])) continue;
+                $bandwidth[$data['sn']] = $data;
+            }
+        }
+
+        return $bandwidth;
+            
+    }
 }

+ 58 - 0
src/StatsBundle/Entity/Cablemodem.php

@@ -159,6 +159,16 @@ class Cablemodem implements TenancyIdTraitInterface
      */
     public $microreflectionCmts;
 
+    /**
+     * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
+     */
+    public $inOctets;
+    
+    /**
+     * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
+     */
+    public $outOctets;
+
     /**
      * Get id
      *
@@ -731,4 +741,52 @@ class Cablemodem implements TenancyIdTraitInterface
     {
         return sprintf('%s', strtoupper($this->mac));
     }
+
+    /**
+     * Set inOctets
+     *
+     * @param float $inOctets
+     *
+     * @return Cablemodem
+     */
+    public function setInOctets($inOctets)
+    {
+        $this->inOctets = $inOctets;
+
+        return $this;
+    }
+
+    /**
+     * Get inOctets
+     *
+     * @return float
+     */
+    public function getInOctets()
+    {
+        return (float) $this->inOctets;
+    }
+
+    /**
+     * Set outOctets
+     *
+     * @param float $outOctets
+     *
+     * @return Cablemodem
+     */
+    public function setOutOctets($outOctets)
+    {
+        $this->outOctets = $outOctets;
+
+        return $this;
+    }
+
+    /**
+     * Get outOctets
+     *
+     * @return float
+     */
+    public function getOutOctets()
+    {
+        return (float) $this->outOctets;
+    }
 }

+ 87 - 0
src/StatsBundle/Entity/Onu.php

@@ -29,6 +29,11 @@ class Onu implements TenancyIdTraitInterface
      */
     private $id;
 
+    /**
+     * @ORM\Column(type="integer", nullable=true)
+     */
+    private $index;
+
     /**
      * @var string
      *
@@ -131,6 +136,16 @@ class Onu implements TenancyIdTraitInterface
      */
     public $lng;
 
+    /**
+     * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
+     */
+    public $inOctets;
+    
+    /**
+     * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
+     */
+    public $outOctets;
+
 
     /**
      * @return int
@@ -553,4 +568,76 @@ class Onu implements TenancyIdTraitInterface
        return (boolean)$this->status;
     }
 
+    /**
+     * Set index
+     *
+     * @param integer $index
+     *
+     * @return ONU
+     */
+    public function setIndex($index)
+    {
+        $this->index = $index;
+
+        return $this;
+    }
+
+    /**
+     * Get index
+     *
+     * @return integer
+     */
+    public function getIndex()
+    {
+        return $this->index;
+    }
+
+    /**
+     * Set inOctets
+     *
+     * @param float $inOctets
+     *
+     * @return ONU
+     */
+    public function setInOctets($inOctets)
+    {
+        $this->inOctets = $inOctets;
+
+        return $this;
+    }
+
+    /**
+     * Get inOctets
+     *
+     * @return float
+     */
+    public function getInOctets()
+    {
+        return (float) $this->inOctets;
+    }
+
+    /**
+     * Set outOctets
+     *
+     * @param float $outOctets
+     *
+     * @return ONU
+     */
+    public function setOutOctets($outOctets)
+    {
+        $this->outOctets = $outOctets;
+
+        return $this;
+    }
+
+    /**
+     * Get outOctets
+     *
+     * @return float
+     */
+    public function getOutOctets()
+    {
+        return (float) $this->outOctets;
+    }
+
 }

+ 9 - 9
src/StatsBundle/Resources/translations/StatsBundle.es.yml

@@ -34,7 +34,7 @@ filter:
     label_cmts_device_id: CMTS
     label_index: Index
     label_signal: SNR
-    label_microreflection: Microreflecciones
+    label_microreflection: Microreflexiones
     label_utilization: Uso
     label_in_octets: IN
     label_out_octets: OUT
@@ -44,7 +44,7 @@ filter:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: Rx Power Ups
+    label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
 
@@ -64,7 +64,7 @@ form:
     label_cmts_device_id: CMTS
     label_index: Index
     label_signal: SNR
-    label_microreflection: Microreflecciones
+    label_microreflection: Microreflexiones
     label_utilization: Uso
     label_in_octets: IN
     label_out_octets: OUT
@@ -74,7 +74,7 @@ form:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: Rx Power Ups
+    label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
 
@@ -107,7 +107,7 @@ show:
     label_cmts_device_id: CMTS
     label_index: Index
     label_signal: SNR
-    label_microreflection: Microreflecciones
+    label_microreflection: Microreflexiones
     label_utilization: Uso
     label_in_octets: IN
     label_out_octets: OUT
@@ -117,7 +117,7 @@ show:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: Rx Power Ups
+    label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
 
@@ -154,7 +154,7 @@ list:
     label_cmts_device_id: CMTS
     label_index: Index
     label_signal: SNR
-    label_microreflection: Microreflecciones
+    label_microreflection: Microreflexiones
     label_utilization: Uso
     label_in_octets: IN
     label_out_octets: OUT
@@ -164,9 +164,9 @@ list:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: Rx Power Ups
+    label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
-    label_microreflection_cmts: Microreflecciones Ups
+    label_microreflection_cmts: Microreflexiones Ups
     
 help:
     url: Url a consultar dispositivos

+ 10 - 0
src/StatsBundle/Resources/views/Cablemodem/field_octets.html.twig

@@ -0,0 +1,10 @@
+{% extends 'StatsBundle:Templates:base_field.html.twig' %}
+
+{% block field %}
+    {% if value is null %}
+        <span class="text_column_stats">{{ 'macroFields.notavailable'|trans({},'StatsBundle') }}</span>
+    {% else %}
+                                        {#   b/s   >  Kb/s > Mb/s #}
+        <span title="{{ value|number_format(3, '.', ',')}} b/s">{{ ((value / 1024) / 1024)|number_format(3, '.', ',')}}</span> <span class="text_column_stats">Mb/s</span>
+    {% endif %}
+{% endblock %}

+ 10 - 0
src/StatsBundle/Resources/views/Onu/field_octets.html.twig

@@ -0,0 +1,10 @@
+{% extends 'StatsBundle:Templates:base_field.html.twig' %}
+
+{% block field %}
+    {% if value is null %}
+        <span class="text_column_stats">{{ 'macroFields.notavailable'|trans({},'StatsBundle') }}</span>
+    {% else %}
+                                        {#   b/s   >  Kb/s > Mb/s #}
+        <span title="{{ value|number_format(3, '.', ',')}} b/s">{{ ((value / 1024) / 1024)|number_format(3, '.', ',')}}</span> <span class="text_column_stats">Mb/s</span>
+    {% endif %}
+{% endblock %}