Explorar el Código

Fixed OIDS FurukawaGS8V1

Jean Sumara hace 5 años
padre
commit
a8220f6d21
Se han modificado 2 ficheros con 79 adiciones y 1 borrados
  1. 78 0
      Command/FurukawaOltScanCommand.php
  2. 1 1
      SNMP/MIBS/FurukawaG8SV1.php

+ 78 - 0
Command/FurukawaOltScanCommand.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace FurukawaBundle\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 FurukawaBundle\SNMP\SNMP as SNMP;
+//use RedisBundle\Services\RedisService;
+
+class FurukawaOltScanCommand extends BaseCommand
+{
+
+    protected function configure()
+    {
+        $this
+            ->setName('furukawa:olt: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_card_{$this->d_s}";
+        $inicio = microtime(true);
+        
+        $SNMP = new SNMP($this->oltIp, $this->oltCommunity);
+        $library = "use".$this->oltSnmpLibrary;
+        $this->apiSNMP = $SNMP->$library();
+
+        $dataCached = array();
+
+        $cpu = $this->getSNMP("oltCardCpu","cardCpu");
+        $memory = $this->getSNMP("oltCardMemory","cardMemory");
+
+        $_memory = $_cpu = array();
+        foreach($cpu as $index => $value) {
+            if($value == -1) continue;
+            $_cpu[$index] = $value;
+        }
+        
+        foreach($memory as $index => $value) {
+            if($value == -1) continue;
+            $_memory[$index] = $value;
+        }
+
+        if($_cpu) {$dataCached['cpu'] = $_cpu;}
+        
+        if($_memory) {$dataCached['memory'] = $_memory;}
+
+        $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");
+        
+    }
+
+}

+ 1 - 1
SNMP/MIBS/FurukawaG8SV1.php

@@ -2,7 +2,7 @@
 
 namespace FurukawaBundle\SNMP\MIBS;
 
-class FurukawaG8SV1 extends \FurukawaBundle\SNMP\MIB {
+class OIDSFurukawaG8SV1 extends \FurukawaBundle\SNMP\MIB {
     
     const OID_authOnuListSlot               = "1.3.6.1.4.1.5875.800.3.10.1.1.2";
     const OID_authOnuListPon                = "1.3.6.1.4.1.5875.800.3.10.1.1.3";