Просмотр исходного кода

Se actualiza vista y comandos de stats.

Maxi Schvindt 7 лет назад
Родитель
Сommit
b4c6d1ed4a

+ 2 - 2
src/StatsBundle/Admin/CmtsInterfaceAdmin.php

@@ -70,8 +70,9 @@ class CmtsInterfaceAdmin extends BaseAdmin
             ->add('deviceServer')
             //->add('extraData','string', array('template' => 'StatsBundle:CmtsInterface:base_list_field_extraData.html.twig'))
             ->add('cmtsDeviceId', 'string', array('template' => 'StatsBundle:CmtsInterface:base_list_field_cmts.html.twig'))
-            ->addIdentifier('index')
+            ->add('index')
             ->addIdentifier('name')
+            ->add('jsonExtraData', 'string', array('template' => 'StatsBundle:CmtsInterface:interface_field_extra_data.html.twig'))
             ->add('signal','string', array('template' => 'StatsBundle:CmtsInterface:interface_field_signal.html.twig'))
             ->add('microreflection','string', array('template' => 'StatsBundle:CmtsInterface:interface_field_microreflection.html.twig'))
             ->add('utilization','string', array('template' => 'StatsBundle:CmtsInterface:interface_field_utilization.html.twig'))
@@ -79,7 +80,6 @@ class CmtsInterfaceAdmin extends BaseAdmin
             ->add('outOctets','string', array('template' => 'StatsBundle:CmtsInterface:interface_field_octets.html.twig'))
             ->add('online','string', array('template' => 'StatsBundle:CmtsInterface:interface_field_count_cablemodem.html.twig'))
             ->add('offline','string', array('template' => 'StatsBundle:CmtsInterface:interface_field_count_cablemodem.html.twig'))
-            //->add('arrayRxPower', 'ponport-rx-power', array('template' => 'StatsBundle:PonPort:base_list_field_rx.html.twig'))
             
         ;
     }

+ 47 - 0
src/StatsBundle/Command/GenerateCrontabCommand.php

@@ -122,6 +122,7 @@ class GenerateCrontabCommand extends ContainerAwareCommand
                 fwrite($handle, PHP_EOL);
             }
 
+            // APARTADO NAS
             $nasDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'RadiusBundle\Entity\NAS', 'deviceServer' => $server));
 
             foreach ($nasDevices as $device) {
@@ -154,6 +155,52 @@ class GenerateCrontabCommand extends ContainerAwareCommand
                 fwrite($handle, implode(PHP_EOL,$commands));
                 
             }
+
+            // APARTADO CMTS
+            $cmtsDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'CablemodemBundle\Entity\CMTS', 'deviceServer' => $server));
+
+            foreach ($cmtsDevices as $device) {
+                $commands = array();
+                $data = $device->jsonExtraData();
+                $deviceId = $device->getDeviceId();
+
+                if (is_null($data['snmpCommunity']) || empty($data['snmpCommunity'])){
+		            $content .= PHP_EOL . PHP_EOL . "# Device(CMTS) {$deviceId} skiped, snmpCommunity is null or empty" . PHP_EOL;
+                    continue;
+		        }   
+                if (!in_array($data['library'], array('OIDSBase'))){
+		            $content .= PHP_EOL . PHP_EOL . "# Device(CMTS) {$deviceId} skiped, library not exist" . PHP_EOL;
+                    continue;
+                }   
+                
+                if (!$data['executeSnmp']){
+		            $content .= PHP_EOL . PHP_EOL . "# Device(CMTS) {$deviceId} skiped, because executeSnmp is 0". PHP_EOL;
+                    continue;
+                }
+                
+                $library = $data['library'];
+                $snmpCommunity = $data['snmpCommunity'];
+                $description = $data['name'];
+                $deviceIp = $device->getIp();
+                $timeScan = $data['timeScan'];
+
+                $params = "--cmts-ip={$deviceIp} --cmts-community={$snmpCommunity} --cmts-snmp-library={$library} --cmts-device-id={$deviceId} --cmts-server-id={$serverId}";
+                
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:cm:scan {$params}";
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:scan {$params}";
+                
+                $params .= " --save-historic={$saveHistoric}";
+                
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:stats {$params}";
+                
+                $params = "--cmts-device-id={$deviceId} --cmts-server-id={$serverId}";
+
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:interface {$params}";
+                
+                fwrite($handle, PHP_EOL.PHP_EOL."# CMTS {$description} ({$deviceIp})".PHP_EOL);
+                fwrite($handle, PHP_EOL);
+                fwrite($handle, implode(PHP_EOL,$commands));
+            }
         }
 
         fclose($handle);

+ 59 - 12
src/StatsBundle/Command/GenerateRemoteCrontabCommand.php

@@ -122,9 +122,8 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $timeOltOctets = $data['timeOltOctets'];
 
                 $params = "--olt-ip={$deviceIp} --olt-community={$snmpCommunity} --olt-snmp-library={$library} --olt-device-id={$deviceId} --olt-server-id={$serverId}";
-                if ($amqp) {
+                if ($amqp) 
                     $params = "--args=--olt-ip:{$deviceIp} --args=--olt-community:{$snmpCommunity} --args=--olt-snmp-library:{$library} --args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
-                }
 
                 $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:scan {$params}";
                 $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:scan {$params}";
@@ -138,15 +137,14 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:stats {$params}";
                 $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:stats {$params}";
                 
-                if($mark == "huawei") {
+                if($mark == "huawei") 
                     $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:octets {$params}";
-                }
+
                 $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:octets {$params}";
 
                 $params = "--olt-device-id={$deviceId} --olt-server-id={$serverId}";
-                if ($amqp) {
-                    $params = "--args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
-                }
+                if ($amqp) $params = "--args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
+
                 $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu {$params}";
                 $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport {$params}";
 
@@ -159,9 +157,7 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $content .= PHP_EOL . PHP_EOL . "# MAPAS" . PHP_EOL;
 
                 $params = "--olt-server-id={$serverId}";
-                if ($amqp) {
-                    $params = "--args=--olt-server-id:{$serverId}";
-                }
+                if ($amqp) $params = "--args=--olt-server-id:{$serverId}";
 
                 $commands = array();
                 $commands[] = "*/5 * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu:geo {$params}";
@@ -171,6 +167,7 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $content .= PHP_EOL;
             }
 
+            // APARTADO NAS
             $nasDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'RadiusBundle\Entity\NAS', 'deviceServer' => $server));
 
             foreach ($nasDevices as $device) {
@@ -198,9 +195,8 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $deviceIp = $device->getIp();
 
                 $params = "--nas-ip={$deviceIp} --nas-community={$snmpCommunity} --nas-snmp-library={$library} --nas-device-id={$deviceId} --nas-server-id={$serverId} --save-historic=1";
-                if ($amqp) {
+                if ($amqp) 
                     $params = "--args=--nas-ip:{$deviceIp} --args=--nas-community:{$snmpCommunity} --args=--nas-snmp-library:{$library} --args=--nas-device-id:{$deviceId} --args=--nas-server-id:{$serverId} --args=--save-historic:1";
-                }
 
                 $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} {$routing_key} nas:onu:octets {$params}";
                 $content .= PHP_EOL . "# NAS {$description} ({$deviceIp})" . PHP_EOL;
@@ -208,6 +204,57 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $content .= implode(PHP_EOL, $commands) . PHP_EOL.PHP_EOL;
             }
 
+
+            // APARTADO CMTS
+            $cmtsDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'CablemodemBundle\Entity\CMTS', 'deviceServer' => $server));
+
+            foreach ($cmtsDevices as $device) {
+                $commands = array();
+                $data = $device->jsonExtraData();
+                $deviceId = $device->getDeviceId();
+
+                if (is_null($data['snmpCommunity']) || empty($data['snmpCommunity'])){
+		            $content .= PHP_EOL . PHP_EOL . "# Device(CMTS) {$deviceId} skiped, snmpCommunity is null or empty" . PHP_EOL;
+                    continue;
+		        }   
+                if (!in_array($data['library'], array('OIDSBase'))){
+		            $content .= PHP_EOL . PHP_EOL . "# Device(CMTS) {$deviceId} skiped, library not exist" . PHP_EOL;
+                    continue;
+                }   
+                
+                if (!$data['executeSnmp']){
+		            $content .= PHP_EOL . PHP_EOL . "# Device(CMTS) {$deviceId} skiped, because executeSnmp is 0". PHP_EOL;
+                    continue;
+                }
+                
+                $library = $data['library'];
+                $snmpCommunity = $data['snmpCommunity'];
+                $description = $data['name'];
+                $deviceIp = $device->getIp();
+                $timeScan = $data['timeScan'];
+
+                $params = "--cmts-ip={$deviceIp} --cmts-community={$snmpCommunity} --cmts-snmp-library={$library} --cmts-device-id={$deviceId} --cmts-server-id={$serverId}";
+                if ($amqp) 
+                    $params = "--args=--cmts-ip:{$deviceIp} --args=--cmts-community:{$snmpCommunity} --args=--cmts-snmp-library:{$library} --args=--cmts-device-id:{$deviceId} --args=--cmts-server-id:{$serverId}";
+                
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:cm:scan {$params}";
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:scan {$params}";
+                
+                $params .= " --save-historic={$saveHistoric}";
+                if ($amqp) $params .= " --args=--save-historic:{$saveHistoric}";
+                
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:stats {$params}";
+                
+                $params = "--cmts-device-id={$deviceId} --cmts-server-id={$serverId}";
+                if ($amqp) $params = "--args=--cmts-device-id:{$deviceId} --args=--cmts-server-id:{$serverId}";
+
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:interface {$params}";
+                
+                $content .= PHP_EOL . "# CMTS {$description} ({$deviceIp})" . PHP_EOL;
+
+                $content .= implode(PHP_EOL, $commands) . PHP_EOL.PHP_EOL;
+            }
+
         }
         file_put_contents($fileCrontab, $content);
 

+ 6 - 0
src/StatsBundle/Resources/translations/StatsBundle.es.yml

@@ -6,6 +6,8 @@ breadcrumb:
     link_device_create: Crear Dispositivo
     link_onu_list: Listado de ONUs
     link_pon_port_list: Listado de PonPorts
+    link_cmts_interface_list: Listado de Interfaces
+    link_cablemodem_list: Listado de Cablemodems
 
 filter:
     label_name: Nombre
@@ -38,6 +40,7 @@ filter:
     label_out_octets: OUT
     label_online: CM Online
     label_offline: CM Offline
+    label_json_extra_data: Características
 
 form:
     label_name: Nombre
@@ -61,6 +64,7 @@ form:
     label_out_octets: OUT
     label_online: CM Online
     label_offline: CM Offline
+    label_json_extra_data: Características
 
 show:
     label_name: Nombre
@@ -97,6 +101,7 @@ show:
     label_out_octets: OUT
     label_online: CM Online
     label_offline: CM Offline
+    label_json_extra_data: Características
 
 list:
     label_name: Nombre
@@ -137,6 +142,7 @@ list:
     label_out_octets: OUT
     label_online: CM Online
     label_offline: CM Offline
+    label_json_extra_data: Características
     
 help:
     url: Url a consultar dispositivos

+ 35 - 0
src/StatsBundle/Resources/views/CmtsInterface/interface_field_extra_data.html.twig

@@ -0,0 +1,35 @@
+{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}
+
+{% block field %}
+
+    {% if value.tr is defined and value.tr %}
+        <span class="label label-success">TR</span>
+    {% else %}
+        <span class="label label-danger">TR</span>
+    {% endif %}
+    
+    {% if value.rf is defined and value.rf %}
+        <span class="label label-success">RF</span>
+    {% else %}
+        <span class="label label-danger">RF</span>
+    {% endif %}
+    
+    {% if value.cm is defined and value.cm %}
+        <span class="label label-success">CM</span>
+    {% else %}
+        <span class="label label-danger">CM</span>
+    {% endif %}
+    
+    {% if value.upstream is defined and value.upstream %}
+        <span class="label label-success">Upstream</span>
+    {% else %}
+        <span class="label label-danger">Upstream</span>
+    {% endif %}
+    
+    {% if value.downstream is defined and value.downstream %}
+        <span class="label label-success">Downstream</span>
+    {% else %}
+        <span class="label label-danger">Downstream</span>
+    {% endif %}
+    
+{% endblock %}