浏览代码

Merge remote-tracking branch 'origin/master' into demo

Conflicts:
	app/config/parameters.yml.docker
	composer.lock
iksop 7 年之前
父节点
当前提交
bf29cc452a

+ 18 - 11
.drone.yml

@@ -4,21 +4,17 @@ services:
     environment:
       - MYSQL_ROOT_PASSWORD=
       - MYSQL_ALLOW_EMPTY_PASSWORD=yes
+  amqp:
+    image: rabbitmq:3-management
+
+
 pipeline:
-  build:
-    image: debian:8.0
-    commands:
+ build:
+  image: debian:8.0
+  commands:
       - echo 'Acquire::http { Proxy "http://200.50.168.30:3142"; };' > /etc/apt/apt.conf.d/01proxy
       - apt-get update && apt-get install -yq build-essential git unzip php5-cli php5-mysql wget mysql-client php5-curl
       
-      # RabbitMQ apt repository
-      - echo 'deb http://www.rabbitmq.com/debian/ testing main' | tee /etc/apt/sources.list.d/rabbitmq.list
-      - wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add -
-      - apt-get update && apt-get install -yq rabbitmq-server
-      - echo 'export RABBITMQ_NODENAME=rabbit@localhost' | tee /etc/rabbitmq/rabbitmq-env.conf
-      - echo 'export RABBITMQ_NODE_IP_ADDRESS=127.0.0.1' | tee /etc/rabbitmq/rabbitmq-env.conf
-      - service rabbitmq-server restart
-      
       - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
       - php composer-setup.php --install-dir=/usr/local/bin/ --filename=composer
       - php -r "unlink('composer-setup.php');"
@@ -26,8 +22,10 @@ pipeline:
       - echo 'date.timezone="America/Argentina/Buenos_Aires"' >> /etc/php5/cli/php.ini
       - yes | mysqladmin -h 127.0.0.1 create flowdat_stats
       - mkdir -p /root/.ssh/
+      - ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
       - ssh-keyscan -p222 200.50.168.30 >> ~/.ssh/known_hosts
       - ssh-keyscan -p222 infra.flowdat.com >> ~/.ssh/known_hosts
+      - ssh-keyscan -p222 gogs.infra.flowdat.com >> ~/.ssh/known_hosts
       - chmod 0400 keys/bitbucket.id_rsa
       - eval $(ssh-agent); ssh-add keys/bitbucket.id_rsa
       - composer update -n
@@ -35,3 +33,12 @@ pipeline:
       - chmod 0777 -R var/logs var/cache var/sessions
       - php bin/console doctrine:schema:update --force -vvv --env=test
       - vendor/phpunit/phpunit/phpunit --tap
+
+ docker:
+   repo : docker.infra.flowdat.com/fd3/stats
+   image: plugins/docker
+   email: luciano@interlink.com.ar
+   registry: docker.infra.flowdat.com
+   username: drone
+   password: 6hd2dLfL
+   tag: latest

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 /app/config/parameters.yml
+/app/Resources/stats_crontab
 /build/
 /phpunit.xml
 /var/*

+ 3 - 1
Dockerfile

@@ -4,7 +4,7 @@ EXPOSE 8000
 #RUN echo "Acquire::http::Proxy \"http://172.17.0.5:3142\";" | tee /etc/apt/apt.conf.d/00aptproxy
 
 RUN apt-get update 
-RUN apt-get install -yq git wget vim tmux php5-cli php5-mysql php5-curl
+RUN apt-get install -yq python git wget vim tmux php5-cli php5-mysql php5-curl
 
 RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
 RUN php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
@@ -18,6 +18,8 @@ RUN rm /opt/stats/var/cache/* -rf
 RUN mkdir ~/.ssh
 RUN ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts
 RUN ssh-keyscan -H -p 222 200.50.168.30 >> ~/.ssh/known_hosts
+RUN ssh-keyscan -H -p 222 infra.flowdat.com >> ~/.ssh/known_hosts
+RUN ssh-keyscan -H -p 222 gogs.infra.flowdat.com >> ~/.ssh/known_hosts
 
 WORKDIR /opt/stats
 

+ 3 - 0
app/AppKernel.php

@@ -36,6 +36,9 @@ class AppKernel extends Kernel
             new OwnerVoterBundle\OwnerVoterBundle(),
             
             new StatsBundle\StatsBundle(),
+            new RedisBundle\RedisBundle(),
+            new FiberhomeBundle\FiberhomeBundle(),
+            new StatsDBundle\StatsDBundle()
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {

+ 0 - 1
app/config/bundles/ik/webservice-bundle/parameters.yml.docker

@@ -1,4 +1,3 @@
-# This file is auto-generated during the composer install
 parameters:
     url_base: 'http://%env(HOST_BASE)%'
     url_ftth: 'http://%env(HOST_FTTH)%'

+ 2 - 0
app/config/config.yml

@@ -12,6 +12,8 @@ imports:
     - { resource: "@WebserviceBundle/Resources/config/services.yml" }
     - { resource: "@ExtraDataBundle/Resources/config/services.yml" }
     - { resource: "@OwnerVoterBundle/Resources/config/services.yml" }
+    - { resource: "@RedisBundle/Resources/config/services.yml" }
+    - { resource: "@StatsDBundle/Resources/config/services.yml" }
    
     - { resource: "@StatsBundle/Resources/config/services.yml" }
 

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

@@ -27,4 +27,5 @@ parameters:
     db_session_port: null
     db_session_name: fd_session
     db_session_user: root
-    db_session_password: null
+    db_session_password: null
+    app_path: '/var/flowdat/stats'

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

@@ -37,3 +37,4 @@ parameters:
     db_session_name: fd_session
     db_session_user: root
     db_session_password: 235r2342gtfsw
+    app_path: '/var/flowdat/stats'

+ 39 - 14
composer.json

@@ -57,7 +57,28 @@
         },
         {
             "type": "vcs",
-			"url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/OwnerVoter.git",
+	    "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/OwnerVoter.git",
+            "options": {
+                    "local_pk": "./keys/bitbucket.id_rsa"
+            }
+        },
+        {
+            "type": "vcs",
+	    "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/RedisBundle.git",
+            "options": {
+                    "local_pk": "./keys/bitbucket.id_rsa"
+            }
+        },
+        {
+            "type": "vcs",
+	    "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/StatsDBundle.git",
+            "options": {
+                    "local_pk": "./keys/bitbucket.id_rsa"
+            }
+        },
+        {
+            "type": "vcs",
+			"url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/FiberhomeBundle.git",
             "options": {
                     "local_pk": "./keys/bitbucket.id_rsa"
             }
@@ -68,27 +89,31 @@
         "doctrine/doctrine-bundle": "^1.6",
         "doctrine/doctrine-cache-bundle": "^1.2",
         "doctrine/orm": "^2.5",
+        "ik/base-admin-bundle": "dev-master",
+        "ik/device-bundle": "dev-master",
+        "ik/extra-data-bundle": "dev-master",
+        "ik/oauthclient-bundle": "dev-master",
+        "ik/owner-voter-bundle": "dev-master",
+        "ik/redis-bundle": "dev-master",
+        "ik/stats/fiberhome-bundle": "dev-master",
+        "ik/statsd-bundle": "dev-master",
+        "ik/webservice-bundle": "dev-master",
         "incenteev/composer-parameter-handler": "^2.0",
+        "jms/serializer-bundle": "^1.1",
+        "opensolutions/oss-snmp": "dev-master",
+        "php-amqplib/rabbitmq-bundle": "^1.12",
+        "phpunit/phpunit": "5.5.*",
         "sensio/distribution-bundle": "^5.0",
         "sensio/framework-extra-bundle": "^3.0.2",
+        "sonata-project/admin-bundle": "^3.12",
+        "sonata-project/doctrine-orm-admin-bundle": "^3.1",
+        "stof/doctrine-extensions-bundle": "^1.2",
         "symfony/monolog-bundle": "^3.0.2",
         "symfony/polyfill-apcu": "^1.0",
         "symfony/swiftmailer-bundle": "^2.3.10",
         "symfony/symfony": "3.2.*",
         "twig/twig": "^1.0||^2.0",
-        "sonata-project/admin-bundle": "^3.12",
-        "sonata-project/doctrine-orm-admin-bundle": "^3.1",
-        "jms/serializer-bundle": "^1.1",
-        "phpunit/phpunit": "5.5.*",
-        "stof/doctrine-extensions-bundle": "^1.2",
-        "voryx/restgeneratorbundle": "dev-master",
-        "php-amqplib/rabbitmq-bundle": "^1.12",
-        "ik/base-admin-bundle": "dev-master",
-        "ik/oauthclient-bundle": "dev-master",
-        "ik/webservice-bundle": "dev-master",
-        "ik/device-bundle": "dev-master",
-        "ik/extra-data-bundle": "dev-master",
-        "ik/owner-voter-bundle": "dev-master"
+        "voryx/restgeneratorbundle": "dev-master"
     },
     "require-dev": {
         "sensio/generator-bundle": "^3.0",

+ 175 - 14
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": "ea46834f1379bc83646db9043b190d8d",
+    "content-hash": "e2fac7f525ddd3ceec7bffbd8f4259b9",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1262,7 +1262,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "fa2199c4a167b492d69e039a5a44c3eea8f16050"
+                "reference": "5b2777db360a34f54f1fe59125e0f7a0b3d0ff7b"
             },
             "type": "library",
             "autoload": {
@@ -1277,7 +1277,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2017-07-12 14:11:05"
+            "time": "2017-08-09 17:31:17"
         },
         {
             "name": "ik/device-bundle",
@@ -1285,7 +1285,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/DeviceBundle.git",
-                "reference": "e8ca2d03e566e7a7daa02cb9355a5f4f051ce024"
+                "reference": "f801d9002000c0804b5e8436dc1f4ac6a0143514"
             },
             "type": "library",
             "autoload": {
@@ -1300,7 +1300,7 @@
                 "bundle",
                 "validators"
             ],
-            "time": "2017-07-05 12:23:57"
+            "time": "2017-08-01 18:49:14"
         },
         {
             "name": "ik/extra-data-bundle",
@@ -1331,7 +1331,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
-                "reference": "0118134e5c0a4731b2f54328a960756bb83ac32e"
+                "reference": "b00d775523cf292ef5a8403f08a88584b36c8a28"
             },
             "require": {
                 "ext-curl": "*",
@@ -1350,14 +1350,14 @@
                 "bundle",
                 "oauth"
             ],
-            "time": "2017-04-06 15:40:13"
+            "time": "2017-08-02 14:10:32"
         },
         {
             "name": "ik/owner-voter-bundle",
             "version": "dev-master",
             "source": {
                 "type": "git",
-                "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/OwnerVoter.git",
+                "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/OwnerVoter.git",
                 "reference": "9ae7b65c59f9cb2216b422744a5e1ffbe429ef29"
             },
             "type": "library",
@@ -1375,13 +1375,79 @@
             ],
             "time": "2017-06-12 15:49:24"
         },
+        {
+            "name": "ik/redis-bundle",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/RedisBundle.git",
+                "reference": "ab9820ac7892ef9ea35f6bc37281be6c832fe919"
+            },
+            "require": {
+                "predis/predis": "^1.1"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "RedisBundle\\": ""
+                }
+            },
+            "description": "Flowdat 3 Redis Bundle",
+            "keywords": [
+                "php-redis-service",
+                "redis"
+            ],
+            "time": "2017-08-09 18:29:16"
+        },
+        {
+            "name": "ik/stats/fiberhome-bundle",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/FiberhomeBundle.git",
+                "reference": "45ae78218b6e8bb0548f373afafebbbcfed10a70"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "FiberhomeBundle\\": ""
+                }
+            },
+            "description": "Flowdat 3 Fiberhome Bundle",
+            "keywords": [
+                "Fiberhome",
+                "Flowdat 3"
+            ],
+            "time": "2017-08-09 13:22:08"
+        },
+        {
+            "name": "ik/statsd-bundle",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/StatsDBundle.git",
+                "reference": "6d988fa97216c6572c5f830c97ef42253d41a744"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "StatsDBundle\\": ""
+                }
+            },
+            "description": "The Flowdat3 StatsD Bundle",
+            "keywords": [
+                "stats",
+                "statsd"
+            ],
+            "time": "2017-07-25 18:45:31"
+        },
         {
             "name": "ik/webservice-bundle",
             "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/Webservice.git",
-                "reference": "1c50e96e43fdc76c8a0393d514799675c23f669f"
+                "reference": "dc5bad4b0b90885bd49b17472aa24267e3d4f15d"
             },
             "require": {
                 "ext-curl": "*",
@@ -1394,7 +1460,7 @@
                 }
             },
             "description": "The Flowdat3 Webservice Rest",
-            "time": "2017-06-05 15:48:18"
+            "time": "2017-08-09 12:58:39"
         },
         {
             "name": "incenteev/composer-parameter-handler",
@@ -2082,6 +2148,47 @@
             ],
             "time": "2017-04-24T09:12:42+00:00"
         },
+        {
+            "name": "opensolutions/oss-snmp",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/opensolutions/OSS_SNMP.git",
+                "reference": "2dab2b36288e11162388451002b15967ddf0528d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/opensolutions/OSS_SNMP/zipball/2dab2b36288e11162388451002b15967ddf0528d",
+                "reference": "2dab2b36288e11162388451002b15967ddf0528d",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.4.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "6.1.*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "OSS_SNMP": "src/",
+                    "Tests": "tests/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "description": "A PHP SNMP library for people who hate SNMP, MIBs and OIDs!",
+            "keywords": [
+                "opensolutions",
+                "oss",
+                "oss-snmp",
+                "oss_snmp",
+                "snmp"
+            ],
+            "time": "2017-06-10 07:30:59"
+        },
         {
             "name": "paragonie/random_compat",
             "version": "v2.0.10",
@@ -2963,6 +3070,56 @@
             ],
             "time": "2016-12-08T20:27:08+00:00"
         },
+        {
+            "name": "predis/predis",
+            "version": "v1.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/nrk/predis.git",
+                "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
+                "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.9"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.8"
+            },
+            "suggest": {
+                "ext-curl": "Allows access to Webdis when paired with phpiredis",
+                "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Predis\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Daniele Alessandri",
+                    "email": "suppakilla@gmail.com",
+                    "homepage": "http://clorophilla.net"
+                }
+            ],
+            "description": "Flexible and feature-complete Redis client for PHP and HHVM",
+            "homepage": "http://github.com/nrk/predis",
+            "keywords": [
+                "nosql",
+                "predis",
+                "redis"
+            ],
+            "time": "2016-06-16T16:22:20+00:00"
+        },
         {
             "name": "psr/cache",
             "version": "1.0.1",
@@ -5460,13 +5617,17 @@
     "aliases": [],
     "minimum-stability": "stable",
     "stability-flags": {
-        "voryx/restgeneratorbundle": 20,
         "ik/base-admin-bundle": 20,
-        "ik/oauthclient-bundle": 20,
-        "ik/webservice-bundle": 20,
         "ik/device-bundle": 20,
         "ik/extra-data-bundle": 20,
-        "ik/owner-voter-bundle": 20
+        "ik/oauthclient-bundle": 20,
+        "ik/owner-voter-bundle": 20,
+        "ik/redis-bundle": 20,
+        "ik/stats/fiberhome-bundle": 20,
+        "ik/statsd-bundle": 20,
+        "ik/webservice-bundle": 20,
+        "opensolutions/oss-snmp": 20,
+        "voryx/restgeneratorbundle": 20
     },
     "prefer-stable": false,
     "prefer-lowest": false,

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

@@ -0,0 +1,114 @@
+<?php
+
+namespace StatsBundle\Command;
+
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use StatsBundle\Services\DeviceManager;
+
+class GenerateCrontabCommand extends ContainerAwareCommand
+{
+
+    protected function configure()
+    {
+        $this
+            ->setName('generate:crontab')
+            ->setDescription('Stats Crontab File')
+            ->setHelp('El comando genera/actualiza el archivo crontab para realizar consultas a dispositivos')
+            ->setDefinition(array(
+                new InputOption('file-crontab', false, InputOption::VALUE_OPTIONAL, "File Crontab","/etc/cron.d/fd3_stats"),
+                new InputOption('path-app', false, InputOption::VALUE_OPTIONAL, "Path App")
+            ))
+        ;
+    }
+
+    /**
+     * @param InputInterface $input
+     * @param OutputInterface $output
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+
+        $fileCrontab = $input->getOption('file-crontab');
+        $pathApp = $input->getOption('path-app');
+
+        $file = $this->getContainer()->get('kernel')->getRootDir()."/Resources/stats_crontab";
+        $handle = fopen($file, "w");
+
+        $times = array();
+        $now = date("d-m-Y H:i:s");
+        fwrite($handle, PHP_EOL."# NO EDITAR este archivo, se autogenera con el comando generate:crontab. Generado {$now}.".PHP_EOL);
+
+        $doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
+        
+        if(is_null($pathApp)) {
+            $pathApp = $this->getContainer()->getParameter('app_path');
+        }
+        $pathConsole = "root $(wich php) {$pathApp}/bin/console"; 
+        
+        $serverDevices = $doctrine->getRepository('\StatsBundle\Entity\DeviceServer')->findAll();
+        
+        $oltMarks = array('FiberHome','FiberLink');
+        $oltLibraries = array('OIDSFiberHomeV1');
+
+        fwrite($handle, "*/5 * * * * {$pathConsole} generate:crontab".PHP_EOL);
+
+        foreach($serverDevices as $server) {
+
+            fwrite($handle, PHP_EOL."# SERVER {$server->getName()} / {$server->getUrl()}".PHP_EOL);
+        
+            // APARTADO OLT
+            $oltDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'FTTHBundle\Entity\OLT','deviceServer' => $server));
+
+            $serverId = $server->getId();
+
+            foreach($oltDevices as $device) {
+                $commands = array();
+                $data = $device->jsonExtraData();
+                
+                if($data['executeSnmp'] == 0) continue;
+
+                if(!in_array($data['mark'],$oltMarks)) continue;
+                
+                if(!in_array($data['library'],$oltLibraries)) continue;
+
+                $oltName = $data['name'];
+                $mark = strtolower($data['mark']);
+                $library = $data['library'];
+                $snmpCommunity = $data['snmpCommunity'];
+                $deviceIp = $device->getIp();
+                $deviceId = $device->getId();
+
+                $timeScan = $data['timeScan'];
+                $timeOnuStats = $data['timeOnuStats'];
+                $timePonStats = $data['timePonStats'];
+                $timeOltOctets = $data['timeOltOctets'];
+
+                $params = "--olt-ip={$deviceIp} --olt-community={$snmpCommunity} --olt-snmp-library={$library} --olt-device-id={$deviceId} --olt-server-id={$serverId}";
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$mark}:pon:scan {$params}";
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$mark}:onu:scan {$params}";
+                
+                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$mark}:onu:stats {$params}";
+                $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$mark}:pon:stats {$params}";
+                $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$mark}:pon:octets {$params}";
+                
+                fwrite($handle, PHP_EOL."# OLT {$oltName} ({$deviceIp})".PHP_EOL);
+                
+                fwrite($handle, implode(PHP_EOL,$commands));
+                fwrite($handle, PHP_EOL);
+            }
+        }
+
+        fclose($handle);
+        
+        @unlink($fileCrontab);
+        
+        if(symlink ($file , $fileCrontab)) print_r("Creado link al crontab".PHP_EOL);
+        
+        print_r(@shell_exec("/etc/init.d/cron reload"));
+
+    }
+
+}

+ 42 - 0
src/StatsBundle/Command/RedisCommand.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace StatsBundle\Command;
+
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use RedisBundle\Services\RedisService;
+
+class RedisCommand extends ContainerAwareCommand
+{
+
+    protected function configure()
+    {
+        $this
+                ->setName('redis:test')
+                ->setDescription('Test Redis')
+                ->setHelp('This command allows test redis')
+        ;
+    }
+
+    /**
+     * @param InputInterface $input
+     * @param OutputInterface $output
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        /* @var $statsDeviceManager DeviceManager */
+        $redis = $this->getContainer()->get('redis');
+        
+        //$parameters = ['tcp://127.0.0.1:6379'];
+
+        //$redis->setOptions($options);
+        //$redis->setConnection($parameters);
+
+        $value = $redis->getString('clave',true);
+
+        $output->writeln($value);
+        
+    }
+
+}