1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace FiberlinkBundle\Command;
- use BaseStatsBundle\Command\BaseCommand;
- 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 FiberlinkBundle\SNMP\SNMP as SNMP;
- //use RedisBundle\Services\RedisService;
- class FiberlinkOnuScanCommand extends BaseCommand
- {
- protected function configure()
- {
- $this
- ->setName('fiberlink: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-server-id', null, InputOption::VALUE_OPTIONAL, "ServerDevice 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);
-
- $key_olt_scan = "olt_scan_{$this->d_s}";
- $inicio = microtime(true);
-
- $SNMP = new SNMP($this->oltIp, $this->oltCommunity);
- $library = "use".$this->oltSnmpLibrary;
- $this->apiSNMP = $SNMP->$library();
- $dataCached = array();
- $serialNumbers = $this->getSNMP("onuSerialNumber","onuScan");
-
- $countOnus = 0;
- foreach($serialNumbers as $index => $serialNumber) {
- $ponPort = explode(".",$index);
- if(count($ponPort) != 3) continue;
- $s = $ponPort[0];
- $p = $ponPort[1];
- $o = $ponPort[2];
- //$index = $s.$p.$o;
- $sn = strtolower($serialNumber);
-
- $countOnus++;
- $data = array();
- $data['slot'] = $s;
- $data['port'] = $p;
- $data['onuId'] = $o;
- $data['serialNumber'] = $sn;
- $data['ponport'] = "{$s}/{$p}/{$o}";
- $dataCached[$index] = $data;
- }
- $this->setData($key_olt_scan, $dataCached, true);
- /* Fin de bloqueo */
- $this->removeLock($this->flag);
- $fin = microtime(true);
- $time = $fin - $inicio;
- $this->output->writeln("Tiempo: $time segundos / Cantidad ONUs: {$countOnus}");
-
- }
- }
|