فهرست منبع

Merged in FD3-763 (pull request #48)

Actualizar Devices de manera automática

Approved-by: Guillermo Espinoza <guillermo@interlink.com.ar>
Maximiliano Schvindt 6 سال پیش
والد
کامیت
074601fe1e

+ 31 - 32
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "9c35ef8addd3827a56efd4b9cd3e9c71",
+    "content-hash": "459b2183499a5a4ee718beb040889f81",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1216,27 +1216,27 @@
         },
         {
             "name": "graze/console-diff-renderer",
-            "version": "0.6.2",
+            "version": "0.6.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/graze/console-diff-renderer.git",
-                "reference": "aafdaf504a96e6889f284bb15c75330318318df1"
+                "reference": "42eb3f66ff13be4acb010c9a6c770b721fdadc4d"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/graze/console-diff-renderer/zipball/aafdaf504a96e6889f284bb15c75330318318df1",
-                "reference": "aafdaf504a96e6889f284bb15c75330318318df1",
+                "url": "https://api.github.com/repos/graze/console-diff-renderer/zipball/42eb3f66ff13be4acb010c9a6c770b721fdadc4d",
+                "reference": "42eb3f66ff13be4acb010c9a6c770b721fdadc4d",
                 "shasum": ""
             },
             "require": {
-                "php": "^5.6 | ^7.0",
-                "symfony/console": "^2.8 | ^3.2 | ^4.0"
+                "php": "^5.5 | ^7.0",
+                "symfony/console": "^2.8 | ^3.2"
             },
             "require-dev": {
-                "graze/standards": "^2.0",
-                "mockery/mockery": "^1",
-                "phpunit/phpunit": "^5.7.21 | ^6 | ^7",
-                "squizlabs/php_codesniffer": "^3"
+                "graze/standards": "^1.0",
+                "mockery/mockery": "^0.9.9",
+                "phpunit/phpunit": "^4.6 | ^5.2",
+                "squizlabs/php_codesniffer": "^2.6,!=2.8.1"
             },
             "type": "library",
             "autoload": {
@@ -1267,30 +1267,29 @@
                 "console-diff-renderer",
                 "graze"
             ],
-            "time": "2018-06-22T14:35:55+00:00"
+            "time": "2017-06-29T15:21:43+00:00"
         },
         {
             "name": "graze/data-structure",
-            "version": "2.1.0",
+            "version": "2.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/graze/data-structure.git",
-                "reference": "24e0544b7828f65b1b93ce69ad702c9efb4a64d0"
+                "reference": "cebaa76aacdea90037a33d8a87aab6641891ea8f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/graze/data-structure/zipball/24e0544b7828f65b1b93ce69ad702c9efb4a64d0",
-                "reference": "24e0544b7828f65b1b93ce69ad702c9efb4a64d0",
+                "url": "https://api.github.com/repos/graze/data-structure/zipball/cebaa76aacdea90037a33d8a87aab6641891ea8f",
+                "reference": "cebaa76aacdea90037a33d8a87aab6641891ea8f",
                 "shasum": ""
             },
             "require": {
                 "graze/sort": "~2.0",
-                "php": ">=5.5|^7.0"
+                "php": ">=5.5"
             },
             "require-dev": {
-                "graze/standards": "^2.0",
-                "phpunit/phpunit": "^4.2 | ^5.2",
-                "squizlabs/php_codesniffer": "^3"
+                "adlawson/timezone": "~1.0",
+                "phpunit/phpunit": "~4.0"
             },
             "type": "library",
             "autoload": {
@@ -1321,7 +1320,7 @@
                 "reduce",
                 "structure"
             ],
-            "time": "2017-11-29T09:06:31+00:00"
+            "time": "2015-11-20T12:13:51+00:00"
         },
         {
             "name": "graze/parallel-process",
@@ -1386,16 +1385,16 @@
         },
         {
             "name": "graze/sort",
-            "version": "2.0.1",
+            "version": "2.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/graze/sort.git",
-                "reference": "50f0896363f177f68be248d7bad9eb0c2f7f666c"
+                "reference": "b3a397c6a6df5ea94da06ef87c545314b2827b14"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/graze/sort/zipball/50f0896363f177f68be248d7bad9eb0c2f7f666c",
-                "reference": "50f0896363f177f68be248d7bad9eb0c2f7f666c",
+                "url": "https://api.github.com/repos/graze/sort/zipball/b3a397c6a6df5ea94da06ef87c545314b2827b14",
+                "reference": "b3a397c6a6df5ea94da06ef87c545314b2827b14",
                 "shasum": ""
             },
             "require": {
@@ -1437,7 +1436,7 @@
                 "sorting",
                 "transform"
             ],
-            "time": "2014-09-23T17:01:23+00:00"
+            "time": "2014-09-23T15:21:27+00:00"
         },
         {
             "name": "hwi/oauth-bundle",
@@ -2039,7 +2038,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "8919bf2fec49fa73cd31b07a83a542bbd0767136"
+                "reference": "a34cd41af82b8b063ef83f49460989d0b0101160"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -2069,7 +2068,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2018-11-23T13:16:02+00:00"
+            "time": "2018-12-06T17:51:35+00:00"
         },
         {
             "name": "incenteev/composer-parameter-handler",
@@ -2794,12 +2793,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/opensolutions/OSS_SNMP.git",
-                "reference": "64df767c1469a4b988b78f66ce1902bc64efead7"
+                "reference": "fded4fc443d841ee6211100d0924598a8afdac2f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/opensolutions/OSS_SNMP/zipball/64df767c1469a4b988b78f66ce1902bc64efead7",
-                "reference": "64df767c1469a4b988b78f66ce1902bc64efead7",
+                "url": "https://api.github.com/repos/opensolutions/OSS_SNMP/zipball/fded4fc443d841ee6211100d0924598a8afdac2f",
+                "reference": "fded4fc443d841ee6211100d0924598a8afdac2f",
                 "shasum": ""
             },
             "require": {
@@ -2827,7 +2826,7 @@
                 "oss_snmp",
                 "snmp"
             ],
-            "time": "2017-11-28T13:23:43+00:00"
+            "time": "2018-11-20T19:24:44+00:00"
         },
         {
             "name": "paragonie/random_compat",

+ 4 - 6
src/StatsBundle/Command/DevicesCommand.php

@@ -28,13 +28,11 @@ class DevicesCommand extends ContainerAwareCommand
         /* @var $statsDeviceManager DeviceManager */
         $statsDeviceManager = $this->getContainer()->get('stats.device.manager');
         $devices = $statsDeviceManager->getDevices();
-        if (count($devices)) {
-            $output->writeln('Nuevos StatsDevice:');
-            foreach ($devices as $device) {
-                $output->writeln(sprintf('<info>DeviceType:</info> %s <info>DeviceId:</info> %s <info>Ip:</info> %s', $device->getDeviceType(), $device->getDeviceId(), $device->getIp()));
-            }
+        $date = date("Y-m-d H:i:s");
+        if ($devices) {
+            $output->writeln("Update {$date} - Devices actualizados: {$devices}");
         } else {
-            $output->writeln('No hay nuevos StatsDevice');
+            $output->writeln("Update {$date} - No se encontraron Devices para actualizar.");
         }
     }
 

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

@@ -57,6 +57,7 @@ class GenerateCrontabCommand extends ContainerAwareCommand
         $oltLibraries = array('OIDSFiberHomeV1','OIDSHuaweiV1','OIDSFiberLinkV1','OIDSZTEV1','OIDSCalixV1');
 
         fwrite($handle, "*/5 * * * * {$pathConsole} generate:crontab".PHP_EOL);
+        fwrite($handle, "*/30 * * * * {$pathConsole} stats:devices".PHP_EOL);
 
         foreach($serverDevices as $server) {
 

+ 2 - 1
src/StatsBundle/Command/GenerateRemoteCrontabCommand.php

@@ -80,6 +80,7 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
         }
 
         $content .= "*/5 * * * * {$pathConsole} stats:crontab:remote >> /var/log/cron.log 2>&1" . PHP_EOL;
+        $content .= "*/20 * * * * {$pathConsole} stats:devices >> /var/log/cron.log 2>&1" . PHP_EOL;
 
         foreach ($serverDevices as $server) {
 
@@ -290,7 +291,7 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
         file_put_contents($fileCrontab, $content);
         sleep(5);
         print_r(shell_exec("/usr/bin/crontab /etc/cron.d/fd3_stats"));
-        print_r(shell_exec("/usr/local/bin/supervisorctl -uiksop -pqueRini6 restart cron"));
+        //print_r(shell_exec("/usr/local/bin/supervisorctl -uiksop -pqueRini6 restart cron"));
     }
 
 }

+ 3 - 1
src/StatsBundle/Services/DeviceManager.php

@@ -61,6 +61,7 @@ class DeviceManager
 
         $dateTime = new \DateTime("now");
         $date = $dateTime->format("Y-m-d H:i:s");
+        $count = 0;
 
         foreach ($deviceServers as $deviceServer) {
             $baseRoutes = json_decode($this->webservice->makeGetRequest($deviceServer->getUrl()), true);
@@ -108,6 +109,7 @@ class DeviceManager
                         $row = "(NULL, {$deviceServerId}, '{$deviceIp}','{$deviceType}', {$deviceId}, '{$deviceExtraData}', {$tenancyId}, '{$date}')";
 
                         $devices_values[] = $row;
+                        $count++;
                     }
 
                     $conn = $em->getConnection();
@@ -121,7 +123,7 @@ class DeviceManager
             }
         }
 
-        return;
+        return $count;
     }
 
     /*