Просмотр исходного кода

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

Maximiliano Schvindt 7 лет назад
Родитель
Сommit
f3e65e228a
1 измененных файлов с 14 добавлено и 5 удалено
  1. 14 5
      Command/FiberhomePonOctetsCommand.php

+ 14 - 5
Command/FiberhomePonOctetsCommand.php

@@ -65,13 +65,10 @@ class FiberhomePonOctetsCommand extends BaseCommand
         $subId = $this->d_s;
         
         $t1 = time();
-        $totalIn = $totalOut = 0;
+        $totalConsOut = $totalConsIn = $totalIn = $totalOut = 0;
         foreach($dataCached as $index => $pon) {
             $ponPort = "{$pon['slot']}.{$pon['port']}";
             
-            //foreach($metrics as $data => $metric) {
-            //if(isset($$data[$index]) && !empty($$data[$index])) {
-            
             (isset($inOctets[$index]))? $in1 = $inOctets[$index] : $in1 = 0;
             (isset($outOctets[$index]))? $out1 = $outOctets[$index] : $out1 = 0;
 
@@ -101,10 +98,17 @@ class FiberhomePonOctetsCommand 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);
             }
         }
 
@@ -113,9 +117,14 @@ class FiberhomePonOctetsCommand extends BaseCommand
         $oltBandwidth = array();
         $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);