浏览代码

Se envía el consumo de la OLT al StatsD.

Maximiliano Schvindt 7 年之前
父节点
当前提交
6edfc5886b
共有 1 个文件被更改,包括 14 次插入2 次删除
  1. 14 2
      Command/HuaweiPonOctetsCommand.php

+ 14 - 2
Command/HuaweiPonOctetsCommand.php

@@ -65,7 +65,7 @@ class HuaweiPonOctetsCommand extends BaseCommand
         $subId = $this->d_s;
         
         $t1 = time();
-        $totalIn = $totalOut = 0;
+        $totalConsOut = $totalConsIn = $totalIn = $totalOut = 0;
         foreach($dataCached as $index => $pon) {
             $ponPort = str_replace("/",".",$pon['ponPort']);
             
@@ -101,10 +101,17 @@ class HuaweiPonOctetsCommand extends BaseCommand
 
                 $sendData["{$subId}_inbandwidth_pon_{$ponPort}"] = "{$inBandwidth}|g";
                 $sendData["{$subId}_outbandwidth_pon_{$ponPort}"] = "{$outBandwidth}|g";
+
+                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' => $in1, 'outAcc' => $out1, 'inBand' => 0, 'outBand' => 0);
+                $bandwidthCached[$index] = array('t' => $t1, 'inOct' => $in1, 'outOct' => $out1, 'inAcc' => 0, 'outAcc' => 0, 'inBand' => 0, 'outBand' => 0);
             }
         }
 
@@ -114,8 +121,13 @@ class HuaweiPonOctetsCommand extends BaseCommand
         $oltBandwidth["{$subId}_inbandwidth_olt"] = "{$totalIn}|g";
         $oltBandwidth["{$subId}_outbandwidth_olt"] = "{$totalOut}|g";
 
+        $oltConsumption = array();
+        $oltConsumption["{$subId}_inconsumption_olt"] = "{$totalConsIn}|g";
+        $oltConsumption["{$subId}_outconsumption_olt"] = "{$totalConsOut}|g";
+
         $statsdService = $this->getContainer()->get('statsd');
         $statsdService->send($oltBandwidth);
+        $statsdService->send($oltConsumption);
 
         if($sendData && $saveHistoric) {
             $t_start_script = microtime(true);