|
@@ -198,6 +198,103 @@ class HuaweiService
|
|
|
$this->output->writeln("Tiempo: $time segundos");
|
|
|
}
|
|
|
|
|
|
+ public function searchOltMemoryAndCpu($keyOltScanCard){
|
|
|
+ $startCmd = microtime(true);
|
|
|
+ $oltScanCardCache = $this->redisHelper->getData($keyOltScanCard, true);
|
|
|
+
|
|
|
+ if(empty($oltScanCardCache)){
|
|
|
+ $oltScanCardCache = [];
|
|
|
+
|
|
|
+ $cpu = $this->snmpService->getSNMP($this->snmpLibrary, "oltCardCpu","cardCpu", $this->output);
|
|
|
+ $memory = $this->snmpService->getSNMP($this->snmpLibrary,"oltCardMemory","cardMemory", $this->output);
|
|
|
+
|
|
|
+ $_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) {$oltScanCardCache['cpu'] = $_cpu;}
|
|
|
+
|
|
|
+ if($_memory) {$oltScanCardCache['memory'] = $_memory;}
|
|
|
+
|
|
|
+ $this->redisHelper->setData($keyOltScanCard, $oltScanCardCache, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ $endCmd = microtime(true);
|
|
|
+ $time = $endCmd - $startCmd;
|
|
|
+ $this->output->writeln("Tiempo: $time segundos");
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function searchInformationsAboutOltAndSave($keyOltScanPons, $keyPonStats, $subId, $saveHistoric){
|
|
|
+ $startCmd = microtime(true);
|
|
|
+
|
|
|
+ $oltScanPonsCached = $this->redisHelper->getData($keyOltScanPons, true);
|
|
|
+ if(!empty($oltScanPonsCached)){
|
|
|
+ //return [PONINDEX.ONUID] => value
|
|
|
+ $rxPower = $this->snmpService->getSNMP($this->snmpLibrary, "oltPonRxOpticalPower","ponRxPower", $this->output);
|
|
|
+ //return [PONINDEX] => value
|
|
|
+ $txPower = $this->snmpService->getSNMP($this->snmpLibrary, "oltPonTxOpticalPower","ponTxPower", $this->output);
|
|
|
+ $temperature = $this->snmpService->getSNMP($this->snmpLibrary, "oltPonOpticalTemperature","ponTemperature", $this->output);
|
|
|
+ $voltage = $this->snmpService->getSNMP($this->snmpLibrary, "oltPonOpticalVltage","ponVoltage", $this->output);
|
|
|
+ $biasCurrent = $this->snmpService->getSNMP($this->snmpLibrary, "oltPonOpticalCurrent","ponBiasCurrent", $this->output);
|
|
|
+
|
|
|
+ $ponStatsCached = [];
|
|
|
+ $sendData = [];
|
|
|
+
|
|
|
+ $huaweiOltService = new HuaweiOltService($sendData);
|
|
|
+
|
|
|
+ foreach ($oltScanPonsCached as $index => $pon){
|
|
|
+ $ponPort = str_replace ('/','.',$pon['ponPort']);
|
|
|
+
|
|
|
+ $stats = [];
|
|
|
+ $stats['ponPort'] = $pon['ponPort'];
|
|
|
+ $stats['rxPower'] = [];
|
|
|
+
|
|
|
+ $huaweiOltService
|
|
|
+ ->configure(new Huawei($index, null, $ponPort, $stats))
|
|
|
+ ->setVoltageOrTxPower($txPower, $subId, "txPower", "_pon_tx_")
|
|
|
+ ->setVoltageOrTxPower($voltage, $subId, "voltage", "_pon_voltage_")
|
|
|
+ ->setTemperatureOrBiasCurrent($temperature, $subId, "temperature", "_pon_temperature_")
|
|
|
+ ->setTemperatureOrBiasCurrent($biasCurrent, $subId, "biasCurrent", "_pon_biascurrent_");
|
|
|
+
|
|
|
+ $ponStatsCached[$index] = $stats;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($rxPower as $index => $rx) {
|
|
|
+ $ponPortOnuId = explode(".",$index);
|
|
|
+ if($rx != 2147483647 && count($ponPortOnuId) == 2){
|
|
|
+ $huaweiOltService->setRxPower($ponPortOnuId, $oltScanPonsCached, $subId, $rx, $ponStatsCached);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($ponStatsCached) {
|
|
|
+ $this->redisHelper->setData($keyPonStats, $ponStatsCached, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($sendData && $saveHistoric) {
|
|
|
+ $timeStartScript = microtime(true);
|
|
|
+ (new StatsDService())->send($sendData);
|
|
|
+ $timeEndScript = microtime(true);
|
|
|
+ $time = $timeEndScript - $timeStartScript;
|
|
|
+ print_r("Tiempo de envío al StatsD: {$time} ms / Cantidad: ".count($sendData).PHP_EOL);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Fin de bloqueo */
|
|
|
+ RedisHelper::removeLock($this->flagCmd);
|
|
|
+
|
|
|
+ $endCmd = microtime(true);
|
|
|
+ $time = $endCmd - $startCmd;
|
|
|
+ $this->output->writeln("Tiempo: $time segundos");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private function saveConsumption($data)
|
|
|
{
|
|
|
if ($data) {
|