HuaweiOltScanCommand.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Flowdat\Stats\Command\Huawei;
  3. use Flowdat\Stats\App\Service\Huawei\HuaweiService;
  4. use Flowdat\Stats\Command\Base\BaseCommand;
  5. use Flowdat\Stats\SNMP\Huawei\SNMP as SNMP;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. use Symfony\Component\Console\Input\InputOption;
  8. use Symfony\Component\Console\Output\OutputInterface;
  9. class HuaweiOltScanCommand extends BaseCommand
  10. {
  11. protected function configure()
  12. {
  13. $this
  14. ->setName('huawei:olt:scan')
  15. ->setDescription('Escanear OLT para obtener ONUs')
  16. ->setHelp('Se requieren parámetros para poder realizar la correcta consulta. El comando requiere Redis.')
  17. ->setDefinition(array(
  18. new InputOption('olt-device-id', null, InputOption::VALUE_OPTIONAL, "DeviceId de la OLT",1),
  19. new InputOption('olt-server-id', null, InputOption::VALUE_OPTIONAL, "ServerDevice de la OLT",1),
  20. new InputOption('olt-ip', false, InputOption::VALUE_OPTIONAL, "IP de la OLT"),
  21. new InputOption('olt-community', false, InputOption::VALUE_OPTIONAL, "COMMUNITY de la OLT"),
  22. new InputOption('olt-snmp-library', false, InputOption::VALUE_OPTIONAL, "Versión de librería SNMP"),
  23. new InputOption('save-historic', null, InputOption::VALUE_OPTIONAL, "Send data to StatsD", 1)
  24. ));
  25. }
  26. public function execute(InputInterface $input, OutputInterface $output){
  27. parent::execute($input, $output);
  28. $saveHistoric = (int)$input->getOption('save-historic');
  29. /*Definir o SNMP*/
  30. $SNMP = new SNMP($this->oltIp, $this->oltCommunity);
  31. $library = "use".$this->oltSnmpLibrary;
  32. /*Definindo as Keys*/
  33. $keyOltScanCard = "olt_scan_card_{$this->d_s}";
  34. $keyOltScanPons = "olt_scan_pons_{$this->d_s}";
  35. $keyPonStats = "olt_stats_pons_{$this->d_s}";
  36. $huaweiService = new HuaweiService($SNMP->$library(), $output, $this->flag);
  37. $huaweiService
  38. ->searchOltMemoryAndCpu($keyOltScanCard)
  39. ->searchPonAndSaveCache($keyOltScanPons)
  40. ->searchInformationsAboutOltAndSave($keyOltScanPons, $keyPonStats, $this->d_s, $saveHistoric);
  41. }
  42. }