|
@@ -190,10 +190,10 @@ class ZteService
|
|
|
if(count($ponPortOnuId) != 2) continue;
|
|
|
$indexPon = $ponPortOnuId[0];
|
|
|
|
|
|
- if(isset($dataCached[$indexPon])) {
|
|
|
+ if(isset($oltScanPonsCached[$indexPon])) {
|
|
|
|
|
|
$onuId = $ponPortOnuId[1];
|
|
|
- $ponPort = str_replace ('/','.',$dataCached[$indexPon]['ponPort']);
|
|
|
+ $ponPort = str_replace ('/','.',$oltScanPonsCached[$indexPon]['ponPort']);
|
|
|
|
|
|
$m = "{$subId}_pon_rx_{$ponPort}.{$onuId}";
|
|
|
|
|
@@ -203,8 +203,8 @@ class ZteService
|
|
|
$ponStatsCached[$indexPon]['rxPower'][$onuId] = $v;
|
|
|
}
|
|
|
|
|
|
- if(isset($dataCached[$indexPon]['nexo'])) {
|
|
|
- $index = $dataCached[$indexPon]['nexo'];
|
|
|
+ if(isset($oltScanPonsCached[$indexPon]['nexo'])) {
|
|
|
+ $index = $oltScanPonsCached[$indexPon]['nexo'];
|
|
|
if(isset($ponStatsCached[$index]['rxPower'])) {
|
|
|
$ponStatsCached[$index]['rxPower'][$onuId] = $v;
|
|
|
}
|
|
@@ -309,9 +309,6 @@ class ZteService
|
|
|
$stats[$metric] = array();
|
|
|
}
|
|
|
|
|
|
- $bandwidthCached = $this->redisHelper->getData($keyOltPonBandwith, true);
|
|
|
-
|
|
|
- $totalConsOut = $totalConsIn = $totalIn = $totalOut = 0;
|
|
|
foreach($serialNumberCache as $index => $onu) {
|
|
|
$statusIndex = $index;
|
|
|
$index = $index.".1";
|
|
@@ -346,25 +343,9 @@ class ZteService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $this->setOltBandwith($sendData, $onu, $index, $bandwidthCached, $subId, $inOctets, $outOctets, $totalIn, $totalOut, $totalConsIn, $totalConsOut);
|
|
|
}
|
|
|
|
|
|
- $this->redisHelper->setData($keyOltPonBandwith, $bandwidthCached, true);
|
|
|
-
|
|
|
- $oltBandwidth = array();
|
|
|
- $oltBandwidth["{$subId}_inbandwidth_olt"] = "{$totalIn}|g";
|
|
|
- $oltBandwidth["{$subId}_outbandwidth_olt"] = "{$totalOut}|g";
|
|
|
-
|
|
|
- $div = 1073741824; //bytes => giga
|
|
|
- $consIn = number_format(($totalConsIn / $div),3,'.','');
|
|
|
- $consOut = number_format(($totalConsOut / $div),3,'.','');
|
|
|
- $oltConsumption = array();
|
|
|
- $oltConsumption["{$subId}_inconsumption_olt"] = "{$consIn}|g";
|
|
|
- $oltConsumption["{$subId}_outconsumption_olt"] = "{$consOut}|g";
|
|
|
-
|
|
|
- $statsdService = new StatsDService();
|
|
|
- $statsdService->send($oltBandwidth);
|
|
|
- $statsdService->send($oltConsumption);
|
|
|
+ $this->setBandwidth($serialNumberCache, $sendData, $inOctets, $outOctets, $keyOltPonBandwith, $subId);
|
|
|
|
|
|
foreach($stats as $metric => $data) {
|
|
|
$keyOnuStats = "{$metric}{$subId}";
|
|
@@ -389,60 +370,83 @@ class ZteService
|
|
|
$this->output->writeln("Tiempo: $time segundos");
|
|
|
}
|
|
|
|
|
|
- private function setOltBandwith(&$sendData, $pon, $index, &$bandwidthCached, $subId, $inOctets, $outOctets, &$totalIn, &$totalOut, &$totalConsIn, &$totalConsOut){
|
|
|
+ private function setBandwidth($dataCached, &$sendData, $inOctets, $outOctets, $keyOltPonBandwidth, $subId){
|
|
|
$t1 = time();
|
|
|
+ $totalConsOut = $totalConsIn = $totalIn = $totalOut = 0;
|
|
|
+ $bandwidthCached = $this->redisHelper->getData($keyOltPonBandwidth, true);
|
|
|
+ foreach($dataCached as $index => $pon) {
|
|
|
|
|
|
- (isset($inOctets[$index]))? $in1 = $inOctets[$index] : $in1 = 0;
|
|
|
- (isset($outOctets[$index]))? $out1 = $outOctets[$index] : $out1 = 0;
|
|
|
+ if(isset($pon['nexo'])){
|
|
|
+ $realIndex = $pon['nexo'];
|
|
|
+ }
|
|
|
|
|
|
- $ponPort = str_replace("/",".",$pon['ponPort']);
|
|
|
+ $ponPort = str_replace("/",".",$pon['ponPort']);
|
|
|
|
|
|
- if(isset($bandwidthCached[$index]) && !isset($pon['nexo'])) {
|
|
|
- $t0 = $bandwidthCached[$index]['t'];
|
|
|
- $in0 = $bandwidthCached[$index]['inOct'];
|
|
|
- $out0 = $bandwidthCached[$index]['outOct'];
|
|
|
- $inAcc = $bandwidthCached[$index]['inAcc'];
|
|
|
- $outAcc = $bandwidthCached[$index]['outAcc'];
|
|
|
+ (isset($inOctets[$realIndex]))? $in1 = $inOctets[$realIndex] : $in1 = 0;
|
|
|
+ (isset($outOctets[$realIndex]))? $out1 = $outOctets[$realIndex] : $out1 = 0;
|
|
|
|
|
|
- $inBandwidth = $outBandwidth = 0;
|
|
|
+ if(isset($bandwidthCached[$index])) {
|
|
|
+ $t0 = $bandwidthCached[$index]['t'];
|
|
|
+ $in0 = $bandwidthCached[$index]['inOct'];
|
|
|
+ $out0 = $bandwidthCached[$index]['outOct'];
|
|
|
+ $inAcc = $bandwidthCached[$index]['inAcc'];
|
|
|
+ $outAcc = $bandwidthCached[$index]['outAcc'];
|
|
|
|
|
|
- if(($in1 >= $in0) && ($t1 > $t0)) {
|
|
|
- $diff = $in1 - $in0;
|
|
|
- $inAcc += $diff;
|
|
|
- $inBandwidth = ($diff / ($t1 - $t0)) * 8;
|
|
|
- }
|
|
|
+ $inBandwidth = $outBandwidth = 0;
|
|
|
|
|
|
- if(($out1 >= $out0) && ($t1 > $t0)) {
|
|
|
- $diff = $out1 - $out0;
|
|
|
- $outAcc += $diff;
|
|
|
- $outBandwidth = ($diff / ($t1 - $t0)) * 8;
|
|
|
- }
|
|
|
+ if(($in1 >= $in0) && ($t1 > $t0)) {
|
|
|
+ $diff = $in1 - $in0;
|
|
|
+ $inAcc += $diff;
|
|
|
+ $inBandwidth = ($diff / ($t1 - $t0)) * 8;
|
|
|
+ }
|
|
|
|
|
|
- $totalIn += $inBandwidth;
|
|
|
- $totalOut += $outBandwidth;
|
|
|
+ if(($out1 >= $out0) && ($t1 > $t0)) {
|
|
|
+ $diff = $out1 - $out0;
|
|
|
+ $outAcc += $diff;
|
|
|
+ $outBandwidth = ($diff / ($t1 - $t0)) * 8;
|
|
|
+ }
|
|
|
|
|
|
- $sendData["{$subId}_inbandwidth_pon_{$ponPort}"] = "{$inBandwidth}|g";
|
|
|
- $sendData["{$subId}_outbandwidth_pon_{$ponPort}"] = "{$outBandwidth}|g";
|
|
|
+ $totalIn += $inBandwidth;
|
|
|
+ $totalOut += $outBandwidth;
|
|
|
|
|
|
- $div = 1073741824; //bytes => giga
|
|
|
- $_in = number_format(($inAcc / $div),3,'.','');
|
|
|
- $_out = number_format(($outAcc / $div),3,'.','');
|
|
|
- $sendData["{$subId}_inconsumption_pon_{$ponPort}"] = "{$_in}|g";
|
|
|
- $sendData["{$subId}_outconsumption_pon_{$ponPort}"] = "{$_out}|g";
|
|
|
+ $sendData["{$subId}_inbandwidth_pon_{$ponPort}"] = "{$inBandwidth}|g";
|
|
|
+ $sendData["{$subId}_outbandwidth_pon_{$ponPort}"] = "{$outBandwidth}|g";
|
|
|
|
|
|
+ $div = 1073741824; //bytes => giga
|
|
|
+ $_in = number_format(($inAcc / $div),3,'.','');
|
|
|
+ $_out = number_format(($outAcc / $div),3,'.','');
|
|
|
+ $sendData["{$subId}_inconsumption_pon_{$ponPort}"] = "{$_in}|g";
|
|
|
+ $sendData["{$subId}_outconsumption_pon_{$ponPort}"] = "{$_out}|g";
|
|
|
|
|
|
- if(date("d",$t0) != date("d",$t1)) {
|
|
|
- $inAcc = $outAcc = 0;
|
|
|
- }
|
|
|
|
|
|
- $totalConsOut += $outAcc;
|
|
|
- $totalConsIn += $inAcc;
|
|
|
+ if(date("d",$t0) != date("d",$t1)) {
|
|
|
+ $inAcc = $outAcc = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $totalConsOut += $outAcc;
|
|
|
+ $totalConsIn += $inAcc;
|
|
|
|
|
|
- $bandwidthCached[$index] = array('t' => $t1, 'inOct' => $in1, 'outOct' => $out1, 'inAcc' => $inAcc, 'outAcc' => $outAcc, 'inBand' => $inBandwidth, 'outBand' => $outBandwidth);
|
|
|
- } else {
|
|
|
- $bandwidthCached[$index] = array('t' => $t1, 'inOct' => $in1, 'outOct' => $out1, 'inAcc' => 0, 'outAcc' => 0, 'inBand' => 0, 'outBand' => 0);
|
|
|
+ $bandwidthCached[$index] = array('t' => $t1, 'inOct' => $in1, 'outOct' => $out1, 'inAcc' => $inAcc, 'outAcc' => $outAcc, 'inBand' => $inBandwidth, 'outBand' => $outBandwidth);
|
|
|
+ } else {
|
|
|
+ $bandwidthCached[$index] = array('t' => $t1, 'inOct' => $in1, 'outOct' => $out1, 'inAcc' => 0, 'outAcc' => 0, 'inBand' => 0, 'outBand' => 0);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ $this->redisHelper->setData($keyOltPonBandwidth, $bandwidthCached, true);
|
|
|
+
|
|
|
+ $oltBandwidth = array();
|
|
|
+ $oltBandwidth["{$subId}_inbandwidth_olt"] = "{$totalIn}|g";
|
|
|
+ $oltBandwidth["{$subId}_outbandwidth_olt"] = "{$totalOut}|g";
|
|
|
+
|
|
|
+ $div = 1073741824; //bytes => giga
|
|
|
+ $consIn = number_format(($totalConsIn / $div),3,'.','');
|
|
|
+ $consOut = number_format(($totalConsOut / $div),3,'.','');
|
|
|
+ $oltConsumption = array();
|
|
|
+ $oltConsumption["{$subId}_inconsumption_olt"] = "{$consIn}|g";
|
|
|
+ $oltConsumption["{$subId}_outconsumption_olt"] = "{$consOut}|g";
|
|
|
|
|
|
+ $statsdService = new StatsDService();
|
|
|
+ $statsdService->send($oltBandwidth);
|
|
|
+ $statsdService->send($oltConsumption);
|
|
|
}
|
|
|
}
|