|
@@ -46,41 +46,21 @@ class StatsGeoPonPortCommand extends BaseCommand
|
|
|
|
|
|
$devicesOlt = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceServer' => $oltServerId, 'deviceType' => 'FTTHBundle\Entity\OLT'));
|
|
|
|
|
|
- $metrics = array("tx" => "onu_tx_", "rx" => "onu_rx_", "temp" => "onu_temperature_", "volt" => "onu_voltage_", "status" => "onu_status_");
|
|
|
-
|
|
|
- $data = array();
|
|
|
-
|
|
|
- $devices = $this->getOnusFromDevices($oltServerId);
|
|
|
+ $metrics = array("tx" => "getTxPower", "rx" => "getRxPower", "temp" => "getTemperature", "volt" => "getVoltage", "status" => "getStatus");
|
|
|
|
|
|
foreach($devicesOlt as $k => $deviceOlt) {
|
|
|
|
|
|
$oltDeviceId = $deviceOlt->getDeviceId();
|
|
|
$tenancyId = $deviceOlt->getTenancyId();
|
|
|
|
|
|
- $onuStats = array();
|
|
|
- foreach($metrics as $m => $metric) {
|
|
|
- $key_onu_stats = "{$metric}d_{$oltDeviceId}_s_{$oltServerId}";
|
|
|
- $onuStats[$metric] = $this->getData($key_onu_stats, true);
|
|
|
- }
|
|
|
-
|
|
|
- $key_pon_stats = "olt_stats_pons_d_{$oltDeviceId}_s_{$oltServerId}";
|
|
|
-
|
|
|
- $ponsCached = $this->getData($key_pon_stats, true);
|
|
|
-
|
|
|
- if(empty($ponsCached)) {
|
|
|
- $this->output->writeln("Se requiere {$key_pon_stats}.");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- $ponStats = array();
|
|
|
- foreach($ponsCached as $p) {$ponStats[$p['ponPort']] = $p;}
|
|
|
-
|
|
|
$ponPorts = $doctrine->getRepository('\StatsBundle\Entity\PonPort')->findBy(array('deviceServer' => $oltServerId, 'oltDeviceId' => $oltDeviceId));
|
|
|
|
|
|
foreach($ponPorts as $ponPort) {
|
|
|
|
|
|
//$ponIndex = str_replace("/","_",$ponPort->getPonPort());
|
|
|
$ponIndex = $ponPort->getPonPort();
|
|
|
+ $rxPon = $ponPort->getArrayRxPower();
|
|
|
+ $txPon = $ponPort->getTxPower();
|
|
|
|
|
|
$geo = array();
|
|
|
$geo['type'] = "FeatureCollection";
|
|
@@ -105,29 +85,22 @@ class StatsGeoPonPortCommand extends BaseCommand
|
|
|
$lowSn = strtolower($sn);
|
|
|
$pon = explode("/", $onu->getPonPort());
|
|
|
|
|
|
- if(!isset($devices[$lowSn])) {
|
|
|
- continue;
|
|
|
- } elseif(is_null($devices[$lowSn]['lat']) || is_null($devices[$lowSn]['lng'])) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ $lat = $onu->getLat();
|
|
|
+ $lng = $onu->getLng();
|
|
|
+
|
|
|
+ if(is_null($lat) || is_null($lng)) continue;
|
|
|
|
|
|
$row = array();
|
|
|
$row['type'] = "Feature";
|
|
|
$row['id'] = "onu.{$lowSn}";
|
|
|
|
|
|
- $lat = $devices[$lowSn]['lat'];
|
|
|
- $lng = $devices[$lowSn]['lng'];
|
|
|
-
|
|
|
$row['geometry'] = array('type' => "Point", 'coordinates' => array(0 => $lng, 1 => $lat));
|
|
|
$row['geometry_name'] = "the_geom";
|
|
|
$row['properties'] = array();
|
|
|
|
|
|
- foreach($metrics as $m => $metric) {
|
|
|
- if(isset($onuStats[$metric][$lowSn])) {
|
|
|
- $row['properties'][$m] = $onuStats[$metric][$lowSn];
|
|
|
- } else {
|
|
|
- $row['properties'][$m] = "null";
|
|
|
- }
|
|
|
+ foreach($metrics as $m => $method) {
|
|
|
+ $value = $onu->$method();
|
|
|
+ (is_null($value))? $row['properties'][$m] = "null" : $row['properties'][$m] = $value;
|
|
|
}
|
|
|
|
|
|
$row['properties']["muestreo"] = date("d-m H:i");
|
|
@@ -137,15 +110,8 @@ class StatsGeoPonPortCommand extends BaseCommand
|
|
|
$_ponPort = "{$pon[0]}/{$pon[1]}";
|
|
|
$_onuId = $pon[2];
|
|
|
|
|
|
- $row['properties']['txPon'] = "null";
|
|
|
- $row['properties']['rxPon'] = "null";
|
|
|
- if(isset($ponStats[$_ponPort]) && isset($ponStats[$_ponPort]['txPower'])) {
|
|
|
- $row['properties']['txPon'] = $ponStats[$_ponPort]['txPower'];
|
|
|
- }
|
|
|
-
|
|
|
- if(isset($ponStats[$_ponPort]) && isset($ponStats[$_ponPort]['rxPower'][$_onuId])) {
|
|
|
- $row['properties']['rxPon'] = $ponStats[$_ponPort]['rxPower'][$_onuId];
|
|
|
- }
|
|
|
+ (is_null($txPon))? $row['properties']['txPon'] = "null" : $row['properties']['txPon'] = $txPon;
|
|
|
+ (isset($rxPon[$_onuId]))? $row['properties']['rxPon'] = $rxPon[$_onuId] : $row['properties']['rxPon'] = "null";
|
|
|
|
|
|
$geo['features'][] = $row;
|
|
|
}
|