Pārlūkot izejas kodu

Bug al guardar ',' en números de 1000.

Maxi Schvindt 6 gadi atpakaļ
vecāks
revīzija
d8c44c1b55
2 mainītis faili ar 8 papildinājumiem un 104 dzēšanām
  1. 4 3
      Command/CmtsInterfaceStatsCommand.php
  2. 4 101
      Command/CmtsOctetsCommand.php

+ 4 - 3
Command/CmtsInterfaceStatsCommand.php

@@ -223,7 +223,7 @@ class CmtsInterfaceStatsCommand extends BaseCmtsCommand
 
                 $totalConsOut += $outAcc;
                 $totalConsIn += $inAcc;
-                
+
                 $bandwidthCached[$index] = array('t' => $t1, 'inOct' => $in1, 'outOct' => $out1, 'inAcc' => $inAcc, 'outAcc' => $outAcc, 'inBand' => $inBandwidth, 'outBand' => $outBandwidth);
 
                 if(isset($ifStatsCached[$index])) {
@@ -242,8 +242,9 @@ class CmtsInterfaceStatsCommand extends BaseCmtsCommand
         $cmtsBandwidth["{$subId}_outbandwidth_cmts"] = "{$totalOut}|g";
         
         $div = 1073741824; //bytes => giga
-        $consIn = number_format(($totalConsIn / $div),3);
-        $consOut = number_format(($totalConsOut / $div),3);
+        $consIn = number_format(($totalConsIn / $div),3,'.','');
+        $consOut = number_format(($totalConsOut / $div),3,'.','');
+        
         $cmtsConsumption = array();
         $cmtsConsumption["{$subId}_inconsumption_cmts"] = "{$consIn}|g";
         $cmtsConsumption["{$subId}_outconsumption_cmts"] = "{$consOut}|g";

+ 4 - 101
Command/CmtsOctetsCommand.php

@@ -134,8 +134,8 @@ class CmtsOctetsCommand extends BaseCmtsCommand
             $sendData["outbandwidth_cm_{$mac}"] = "{$outBand}|g";
             
             $div = 1073741824; //bytes => giga
-            $consIn = number_format(($inAcc / $div),3);
-            $consOut = number_format(($outAcc / $div),3);
+            $consIn = number_format(($inAcc / $div),3,'.','');
+            $consOut = number_format(($outAcc / $div),3,'.','');
             
             $sendData["inconsumption_cm_{$mac}"] = "{$consIn}|g";
             $sendData["outconsumption_cm_{$mac}"] = "{$consOut}|g";
@@ -165,8 +165,8 @@ class CmtsOctetsCommand extends BaseCmtsCommand
         $sendData["{$this->d_s}_outbandwidth_cmts_x_cm"] = "{$outBandTotal}|g";
 
         $div = 1073741824; //bytes => giga
-        $consIn = number_format(($inAccTotal / $div),3);
-        $consOut = number_format(($outAccTotal / $div),3);
+        $consIn = number_format(($inAccTotal / $div),3,'.','');
+        $consOut = number_format(($outAccTotal / $div),3,'.','');
 
         $sendData["{$this->d_s}_inconsumption_cmts_x_cm"] = "{$consIn}|g";
         $sendData["{$this->d_s}_outconsumption_cmts_x_cm"] = "{$consOut}|g";
@@ -189,101 +189,4 @@ class CmtsOctetsCommand extends BaseCmtsCommand
         $this->output->writeln("Tiempo: $time segundos");
     }
 
-    /*
-    private function octets(&$ifStatsCached, $dataCached, $saveHistoric) {
-
-        $inOctets = $this->getSNMP("inOctets","cmtsIfInOctets");
-        $outOctets = $this->getSNMP("outOctets","cmtsIfOutOctets");
-
-        $key_cmts_ifs_bandwidth = "cmts_bandwidth_ifs_{$this->d_s}";
-        $bandwidthCached = $this->getData($key_cmts_ifs_bandwidth, true);
-        if(empty($bandwidthCached)) $bandwidthCached = array();
-
-        $t1 = time();
-        $totalConsOut = $totalConsIn = $totalIn = $totalOut = 0;
-        $sendData = array(); $subId = $this->d_s;
-
-        foreach($dataCached as $index => $data) {
-            
-            (isset($inOctets[$index]))? $in1 = $inOctets[$index] : $in1 = 0;
-            (isset($outOctets[$index]))? $out1 = $outOctets[$index] : $out1 = 0;
-
-            if(isset($ifStatsCached[$index])) {
-                $ifStatsCached[$index]['inOctets'] = 0;
-                $ifStatsCached[$index]['outOctets'] = 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'];
-
-                $inBandwidth = $outBandwidth = 0; 
-                 
-                if(($in1 >= $in0) && ($t1 > $t0)) {
-                    $diff = $in1 - $in0;
-                    $inAcc += $diff;
-                    $inBandwidth = ($diff / ($t1 - $t0)) * 8;
-                }
-
-                if(($out1 >= $out0) && ($t1 > $t0)) {
-                    $diff = $out1 - $out0;
-                    $outAcc += $diff;
-                    $outBandwidth = ($diff / ($t1 - $t0)) * 8;
-                }
-
-                $totalIn += $inBandwidth;
-                $totalOut += $outBandwidth;
-
-                $sendData["{$subId}_inbandwidth_if_{$index}"] = "{$inBandwidth}|g";
-                $sendData["{$subId}_outbandwidth_if_{$index}"] = "{$outBandwidth}|g";
-
-                if(date("n",$t0) != date("n",$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);
-
-                if(isset($ifStatsCached[$index])) {
-                    $ifStatsCached[$index]['inOctets'] = $inBandwidth;
-                    $ifStatsCached[$index]['outOctets'] = $outBandwidth;
-                }
-            } else {
-                $bandwidthCached[$index] = array('t' => $t1, 'inOct' => $in1, 'outOct' => $out1, 'inAcc' => 0, 'outAcc' => 0, 'inBand' => 0, 'outBand' => 0);
-            }
-        }
-
-        $this->setData($key_cmts_ifs_bandwidth, $bandwidthCached, true);
-        
-        $cmtsBandwidth = array();
-        $cmtsBandwidth["{$subId}_inbandwidth_cmts"] = "{$totalIn}|g";
-        $cmtsBandwidth["{$subId}_outbandwidth_cmts"] = "{$totalOut}|g";
-        
-        $div = 1073741824; //bytes => giga
-        $consIn = number_format(($totalConsIn / $div),3);
-        $consOut = number_format(($totalConsOut / $div),3);
-        $cmtsConsumption = array();
-        $cmtsConsumption["{$subId}_inconsumption_cmts"] = "{$consIn}|g";
-        $cmtsConsumption["{$subId}_outconsumption_cmts"] = "{$consOut}|g";
-
-        $statsdService = $this->getContainer()->get('statsd');
-        $statsdService->send($cmtsBandwidth);
-        $statsdService->send($cmtsConsumption);
-        
-        if($sendData && $saveHistoric) {
-            $t_start_script = microtime(true); 
-            $statsdService->send($sendData);
-            $t_end_script = microtime(true); 
-            $time = $t_end_script - $t_start_script;
-            print_r("Tiempo de envío de Octets al StatsD: {$time} ms / Cantidad: ".count($sendData).PHP_EOL);
-        }
-        
-    }
-    */
-
 }