|
@@ -38,6 +38,7 @@ class StatsOnuCommand extends BaseCommand
|
|
$now = date("d-m-Y H:i:s");
|
|
$now = date("d-m-Y H:i:s");
|
|
|
|
|
|
$doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
$doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
|
+ $conn = $doctrine->getConnection();
|
|
|
|
|
|
$deviceOlt = $doctrine->getRepository('\StatsBundle\Entity\Device')->findOneBy(array('deviceId' => $oltDeviceId, 'deviceServer' => $oltServerId, 'deviceType' => 'FTTHBundle\Entity\OLT'));
|
|
$deviceOlt = $doctrine->getRepository('\StatsBundle\Entity\Device')->findOneBy(array('deviceId' => $oltDeviceId, 'deviceServer' => $oltServerId, 'deviceType' => 'FTTHBundle\Entity\OLT'));
|
|
|
|
|
|
@@ -122,17 +123,17 @@ class StatsOnuCommand extends BaseCommand
|
|
$clientId = $devices[$serialNumber]['clientId'];
|
|
$clientId = $devices[$serialNumber]['clientId'];
|
|
if(isset($clients[$clientId])) {
|
|
if(isset($clients[$clientId])) {
|
|
$row['clientId'] = $clientId;
|
|
$row['clientId'] = $clientId;
|
|
- $row['clientExternalId'] = "'".$clients[$clientId]['externalId']."'";
|
|
|
|
- $row['clientName'] = "'".$clients[$clientId]['name']."'";
|
|
|
|
- $row['clientAddress'] = "'".$clients[$clientId]['address']."'";
|
|
|
|
|
|
+ $row['clientExternalId'] = $conn->quote($clients[$clientId]['externalId']);
|
|
|
|
+ $row['clientName'] = $conn->quote($clients[$clientId]['name']);
|
|
|
|
+ $row['clientAddress'] = $conn->quote($clients[$clientId]['address']);
|
|
}
|
|
}
|
|
} elseif(isset($devices[$ponSerialNumber]) && isset($devices[$ponSerialNumber]['clientId'])) {
|
|
} elseif(isset($devices[$ponSerialNumber]) && isset($devices[$ponSerialNumber]['clientId'])) {
|
|
$clientId = $devices[$ponSerialNumber]['clientId'];
|
|
$clientId = $devices[$ponSerialNumber]['clientId'];
|
|
if(isset($clients[$clientId])) {
|
|
if(isset($clients[$clientId])) {
|
|
$row['clientId'] = $clientId;
|
|
$row['clientId'] = $clientId;
|
|
- $row['clientExternalId'] = "'".$clients[$clientId]['externalId']."'";
|
|
|
|
- $row['clientName'] = "'".$clients[$clientId]['name']."'";
|
|
|
|
- $row['clientAddress'] = "'".$clients[$clientId]['address']."'";
|
|
|
|
|
|
+ $row['clientExternalId'] = $conn->quote($clients[$clientId]['externalId']);
|
|
|
|
+ $row['clientName'] = $conn->quote($clients[$clientId]['name']);
|
|
|
|
+ $row['clientAddress'] = $conn->quote($clients[$clientId]['address']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -140,19 +141,16 @@ class StatsOnuCommand extends BaseCommand
|
|
}
|
|
}
|
|
|
|
|
|
if($data) {
|
|
if($data) {
|
|
- $conn = $doctrine->getConnection();
|
|
|
|
$sql = "DELETE FROM `onu` WHERE device_server_id = {$deviceServerId} AND olt_device_id = {$oltDeviceId};";
|
|
$sql = "DELETE FROM `onu` WHERE device_server_id = {$deviceServerId} AND olt_device_id = {$oltDeviceId};";
|
|
$conn->query($sql);
|
|
$conn->query($sql);
|
|
- $conn->close();
|
|
|
|
|
|
|
|
- $conn = $doctrine->getConnection();
|
|
|
|
$sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`,`lat`,`lng`,`index`,`in_octets`,`out_octets`,`rx_power_olt`,`client_id`,`client_external_id`,`client_name`,`client_address`) VALUES ". implode(",", $data).";";
|
|
$sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`,`lat`,`lng`,`index`,`in_octets`,`out_octets`,`rx_power_olt`,`client_id`,`client_external_id`,`client_name`,`client_address`) VALUES ". implode(",", $data).";";
|
|
$conn->query($sql);
|
|
$conn->query($sql);
|
|
- $conn->close();
|
|
|
|
} else {
|
|
} else {
|
|
print_r("No se encuentran ONUs cargadas en Redis, comprobar onu:scan y onu:stats".PHP_EOL);
|
|
print_r("No se encuentran ONUs cargadas en Redis, comprobar onu:scan y onu:stats".PHP_EOL);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ $conn->close();
|
|
}
|
|
}
|
|
|
|
|
|
private function getBandwidth($server, $olt) {
|
|
private function getBandwidth($server, $olt) {
|