123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace CmtsBundle\Command;
- use BaseStatsBundle\Command\BaseCmtsCommand;
- 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 CmtsBundle\SNMP\SNMP as SNMP;
- class CmtsCmScanCommand extends BaseCmtsCommand
- {
- protected function configure()
- {
- $this
- ->setName('cmts:cm:scan')
- ->setDescription('Escanear CMTS para obtener CMs')
- ->setHelp('Se requieren parámetros para poder realizar la correcta consulta. El comando requiere Redis.')
- ->setDefinition(array(
- new InputOption('cmts-device-id', null, InputOption::VALUE_OPTIONAL, "DeviceId del CMTS",1),
- new InputOption('cmts-server-id', null, InputOption::VALUE_OPTIONAL, "ServerDevice del CMTS",1),
- new InputOption('cmts-ip', false, InputOption::VALUE_OPTIONAL, "IP del CMTS"),
- new InputOption('cmts-community', false, InputOption::VALUE_OPTIONAL, "Community del CMTS"),
- new InputOption('cmts-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_cmts_scan = "cmts_scan_{$this->d_s}";
- $inicio = microtime(true);
-
- $SNMP = new SNMP($this->cmtsIp, $this->cmtsCommunity);
- $library = "use".$this->cmtsSnmpLibrary;
- $this->apiSNMP = $SNMP->$library();
- $dataCached = array();
- $countCms = 0;
- /*
- $slots = $this->getSNMP("onuSlot","onuSlot");
- $pons = $this->getSNMP("onuPon","onuPon");
- $onus = $this->getSNMP("onuOnuid","onuOnuid");
- $serialNumbers = $this->getSNMP("onuSerialNumber","onuScan");
- foreach($onus as $index => $onuId) {
- $countOnus++;
- if(isset($slots[$index]) && isset($pons[$index]) && isset($serialNumbers[$index])) {
- $slot = $slots[$index]; $pon = $pons[$index]; $sn = strtolower($serialNumbers[$index]);
- $data = array();
- $data['slot'] = $slot;
- $data['port'] = $pon;
- $data['onuId'] = $onuId;
- $data['serialNumber'] = $sn;
- $data['ponport'] = "{$slot}/{$pon}/{$onuId}";
- $dataCached[$index] = $data;
- }
- }
- */
- $this->setData($key_cmts_scan, $dataCached, true);
- /* Fin de bloqueo */
- $this->removeLock($this->flag);
- $fin = microtime(true);
- $time = $fin - $inicio;
- $this->output->writeln("Tiempo: $time segundos / Cantidad CMs: {$countCms}");
-
- }
- }
|