1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace FiberhomeBundle\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 FiberhomeBundle\SNMP\SNMP as SNMP;
- //use RedisBundle\Services\RedisService;
- class FiberhomeOnuScanCommand extends BaseCommand
- {
- protected function configure()
- {
- $this
- ->setName('fiberhome:onu:scan')
- ->setDescription('Escanear OLT para obtener ONUs')
- ->setHelp('Se requieren parámetros para poder realizar la correcta consulta. El comando requiere Redis.')
- ->setDefinition(array(
- new InputOption('olt-device-id', null, InputOption::VALUE_OPTIONAL, "DeviceId de la OLT",1),
- new InputOption('olt-device-tenancy-id', null, InputOption::VALUE_OPTIONAL, "TenancyId de la OLT",1),
- new InputOption('olt-ip', false, InputOption::VALUE_OPTIONAL, "IP de la OLT"),
- new InputOption('olt-community', false, InputOption::VALUE_OPTIONAL, "COMMUNITY de la OLT"),
- new InputOption('olt-snmp-library', false, InputOption::VALUE_OPTIONAL, "Versión de librería SNMP")
- ))
- ;
- }
- /**
- * @param InputInterface $input
- * @param OutputInterface $output
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- parent::execute($input, $output);
-
- $this->output->writeln("INICIO");
-
- $inicio = microtime(true);
- $time = time();
- $oltDeviceId = (int) $input->getOption('olt-device-id');
- $oltDeviceTenancyId = (int) $input->getOption('olt-device-tenancy-id');
- $oltIp = $input->getOption('olt-ip');
- $oltCommunity = $input->getOption('olt-community');
- $oltSnmpLibrary = $input->getOption('olt-snmp-library');
-
- /* Control de bloqueo */
- $flag = "olt_{$oltDeviceId}_{$oltDeviceTenancyId}.lock";
- if($this->lock($flag)) {return;}
- //$aux = snmp2_real_walk("190.110.248.2", "LoLtawah", "1.3.6.1.4.1.5875.800.3.10.1.1.10", 100000000, 5);
- //print_r($aux);
-
- $SNMP = new SNMP($oltIp, $oltCommunity);
- $library = "use".$oltSnmpLibrary;
-
- $interfaces = $SNMP->$library()->ifDescr();
-
- //$parameters = ['tcp://127.0.0.1:6379'];
- //$redis->setOptions($options);
- //$redis->setConnection($parameters);
- $value = $this->collector->getString('clave',true);
- $output->writeln($value);
- $this->removeLock($flag);
-
- }
- }
|