setName('fiberlink:pon:scan') ->setDescription('Escanear OLT para obtener PON PORTs') ->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_pons_{$this->d_s}"; $inicio = microtime(true); $SNMP = new SNMP($this->oltIp, $this->oltCommunity); $library = "use".$this->oltSnmpLibrary; $this->apiSNMP = $SNMP->$library(); $dataCached = $this->getData($key_olt_scan, true); $dataCached = array(); $ports = $this->getSNMP("oltPonDesc","ponScan"); $countPons = 0; foreach($ports as $index => $d) { $s_p = explode(".",$index); if(count($s_p) == 2) { $countPons++; $s = $s_p[0]; $p = $s_p[1]; //$index = $s.$p; $dataCached[$index] = array("ponPort"=>"{$s}/{$p}",'slot'=>$s,'port'=>$p); } } $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 Puertos: {$countPons}"); } }