123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace Flowdat\Stats\Command\Huawei;
- use Flowdat\Stats\App\Service\Huawei\HuaweiService;
- use Flowdat\Stats\App\Service\Stats\StatsService;
- use Flowdat\Stats\Command\Base\BaseCommand;
- use Flowdat\Stats\SNMP\Huawei\SNMP as SNMP;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Output\OutputInterface;
- class HuaweiOnuScanCommand extends BaseCommand
- {
- protected function configure()
- {
- $this
- ->setName('huawei:onu:scan')
- ->setDescription('Scan de ONUs de OLT')
- ->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"),
- new InputOption('save-historic', null, InputOption::VALUE_OPTIONAL, "Send data to StatsD", 1)
- ));
- }
- /**
- * @param InputInterface $input
- * @param OutputInterface $output
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- parent::execute($input, $output);
- $saveHistoric = (int)$input->getOption('save-historic');
- /*Definir o SNMP*/
- $SNMP = new SNMP($this->oltIp, $this->oltCommunity);
- $library = "use".$this->oltSnmpLibrary;
- /*Definição das KEYS*/
- $keyOltScan = "olt_scan_{$this->d_s}";
- $keyOltScanPon = "olt_scan_pons_{$this->d_s}";
- $keyOltBandwidthOnu = "olt_bandwidth_onu_{$this->d_s}";
- $huaweiService = new HuaweiService($SNMP->$library(), $output, $this->flag);
- $huaweiService
- ->searchPonAndSaveCache($keyOltScanPon)
- ->searchNumberSerialAndSaveCache($keyOltScan, $keyOltScanPon)
- ->searchInformationsAboutOnuAndSave($keyOltScan, $keyOltBandwidthOnu, $this->oltServerId, $this->oltDeviceId, $this->d_s, $saveHistoric);
- $statsService = new StatsService();
- $statsService->updateStatsOnu($this->oltDeviceId, $this->oltServerId);
- }
- }
|