소스 검색

Updated Generate Remote Crontab and parameters

Jean Sumara Leopoldo 5 년 전
부모
커밋
7622942a3b
3개의 변경된 파일6개의 추가작업 그리고 119개의 파일을 삭제
  1. 1 1
      app/config/parameters.yml.dist
  2. 1 1
      app/config/parameters.yml.docker
  3. 4 117
      src/StatsBundle/Command/GenerateRemoteCrontabCommand.php

+ 1 - 1
app/config/parameters.yml.dist

@@ -28,7 +28,7 @@ parameters:
     db_session_name: fd_session
     db_session_user: root
     db_session_password: '%env(MYSQL_ROOT_PASSWORD)%'
-    app_path: '/opt/stats_command'
+    app_path: '/opt/stats'
     geoserver_service: false
     geoserver_host: '%env(HOST_GEOSERVER)%'
     geoserver_port: 8082

+ 1 - 1
app/config/parameters.yml.docker

@@ -35,7 +35,7 @@ parameters:
     db_session_name: fd_session
     db_session_user: root
     db_session_password: '%env(MYSQL_ROOT_PASSWORD)%'
-    app_path: '/opt/stats_command'
+    app_path: '/opt/stats'
     geoserver_service: false
     geoserver_host: '%env(HOST_GEOSERVER)%'
     geoserver_port: 8082

+ 4 - 117
src/StatsBundle/Command/GenerateRemoteCrontabCommand.php

@@ -128,37 +128,15 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $deviceIp = $device->getIp();
 
                 $timeScan = $data['timeScan'];
-                $timeOnuStats = $data['timeOnuStats'];
-                $timePonStats = $data['timePonStats'];
-                $timeOltOctets = $data['timeOltOctets'];
+                $timeOltScan = $data['timeOltScan'];
 
-                $params = "--olt-ip={$deviceIp} --olt-community={$snmpCommunity} --olt-snmp-library={$library} --olt-device-id={$deviceId} --olt-server-id={$serverId}";
+                $params = "--olt-ip={$deviceIp} --olt-community={$snmpCommunity} --olt-snmp-library={$library} --olt-device-id={$deviceId} --olt-server-id={$serverId} --save-historic={$saveHistoric}";
                 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}";
+                    $params = "--args=--olt-ip:{$deviceIp} --args=--olt-community:{$snmpCommunity} --args=--olt-snmp-library:{$library} --args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}  --args=--save-historic:{$saveHistoric}";
 
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:scan {$params} >> /var/log/cron.log 2>&1";
                 $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:scan {$params} >> /var/log/cron.log 2>&1";
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:olt:scan {$params} >> /var/log/cron.log 2>&1";
+                $commands[] = "*/{$timeOltScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:olt:scan {$params} >> /var/log/cron.log 2>&1";
                 
-                if ($amqp) {
-                    $params .= " --args=--save-historic:{$saveHistoric}";
-                } else {
-                    $params .= " --save-historic={$saveHistoric}";
-                }
-                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:stats {$params} >> /var/log/cron.log 2>&1";
-                $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:stats {$params} >> /var/log/cron.log 2>&1";
-                
-                if($mark == "huawei") 
-                    $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:octets {$params} >> /var/log/cron.log 2>&1";
-
-                $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:octets {$params} >> /var/log/cron.log 2>&1";
-
-                $params = "--olt-device-id={$deviceId} --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} >> /var/log/cron.log 2>&1";
-                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport {$params} >> /var/log/cron.log 2>&1";
-
                 $content .= PHP_EOL . "# OLT {$oltName} ({$deviceIp})" . PHP_EOL;
 
                 $content .= implode(PHP_EOL, $commands);
@@ -166,20 +144,6 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $content .= PHP_EOL . PHP_EOL;
             }
 
-            if ($this->getContainer()->getParameter('geoserver_service')) {
-                $content .= PHP_EOL . PHP_EOL . "# MAPAS" . PHP_EOL;
-
-                $params = "--olt-server-id={$serverId}";
-                if ($amqp) $params = "--args=--olt-server-id:{$serverId}";
-
-                $commands = array();
-                $commands[] = "*/5 * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu:geo {$params} >> /var/log/cron.log 2>&1";
-                $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport:geo {$params} >> /var/log/cron.log 2>&1";
-
-                $content .= implode(PHP_EOL, $commands);
-                $content .= PHP_EOL . PHP_EOL;
-            }
-
             // APARTADO NAS
             $nasDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'RadiusBundle\Entity\NAS', 'deviceServer' => $server));
 
@@ -217,83 +181,6 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $content .= implode(PHP_EOL, $commands);
                 $content .= 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'];
-                $docsVersion = $data['docsVersion'];
-                $description = $data['name'];
-                $deviceIp = $device->getIp();
-                $timeScan = $data['timeScan'];
-                $timeOctets = $data['timeCmtsOctets'];
-                
-                (isset($data['timeCmStats']))? $timeCmStats = $data['timeCmStats'] : $timeCmStats = 10;
-
-                $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} >> /var/log/cron.log 2>&1";
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:scan {$params} >> /var/log/cron.log 2>&1";
-                
-                if ($amqp) {
-                    $params .= " --args=--save-historic:{$saveHistoric}";
-                } else {
-                    $params .= " --save-historic={$saveHistoric}";
-                }
-                
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:stats {$params} >> /var/log/cron.log 2>&1";
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:description {$params} >> /var/log/cron.log 2>&1";
-                
-                if ($amqp) {
-                    $params .= " --args=--cmts-docs:{$docsVersion}";
-                } else {
-                    $params .= " --cmts-docs={$docsVersion}";
-                }
-                $commands[] = "*/{$timeOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:octets {$params} >> /var/log/cron.log 2>&1";
-
-                if ($amqp) {
-                    $params = "--args=--cmts-device-id:{$deviceId} --args=--cmts-server-id:{$serverId}";
-                } else {
-                    $params = "--cmts-device-id={$deviceId} --cmts-server-id={$serverId}";
-                }
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:interface {$params} >> /var/log/cron.log 2>&1";
-                
-                if ($amqp) {
-                    $params .= " --args=--generate-remote-commands:1";
-                } else {
-                    $params .= " --generate-remote-commands=1";
-                }
-                $commands[] = "*/{$timeCmStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:cm {$params} >> /var/log/cron.log 2>&1";
-                
-                $content .= PHP_EOL . "# CMTS {$description} ({$deviceIp})" . PHP_EOL;
-
-                $content .= implode(PHP_EOL, $commands);
-                $content .= PHP_EOL . PHP_EOL;
-            }
-
         }
 
         $content .= PHP_EOL."#END ".PHP_EOL.PHP_EOL;