|
@@ -49,6 +49,8 @@ class StatsOnuCommand extends BaseCommand
|
|
|
$metrics = array("txPower" => "onu_tx_", "rxPower" => "onu_rx_", "temperature" => "onu_temperature_", "voltage" => "onu_voltage_", "status" => "onu_status_");
|
|
|
$data = $stats = array();
|
|
|
|
|
|
+ $bandwidth = $this->getBandwidth($oltServerId, $oltDeviceId);
|
|
|
+
|
|
|
foreach($metrics as $m => $metric) {
|
|
|
$key_onu_stats = "{$metric}d_{$oltDeviceId}_s_{$oltServerId}";
|
|
|
$stats[$metric] = $this->getData($key_onu_stats, true);
|
|
@@ -93,6 +95,16 @@ class StatsOnuCommand extends BaseCommand
|
|
|
|
|
|
$row['lat'] = ($lat)?$lat:"NULL";
|
|
|
$row['lng'] = ($lng)?$lng:"NULL";
|
|
|
+
|
|
|
+ $row['index'] = $index;
|
|
|
+
|
|
|
+ if(isset($bandwidth[$lowSn])) {
|
|
|
+ $row['inOctets'] = $bandwidth[$lowSn]['inBand'];
|
|
|
+ $row['outOctets'] = $bandwidth[$lowSn]['outBand'];
|
|
|
+ } else {
|
|
|
+ $row['inOctets'] = "NULL";
|
|
|
+ $row['outOctets'] = "NULL";
|
|
|
+ }
|
|
|
|
|
|
$data[] = "(".implode(",",$row).")".PHP_EOL;
|
|
|
}
|
|
@@ -104,7 +116,7 @@ class StatsOnuCommand extends BaseCommand
|
|
|
$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`) 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`) VALUES ". implode(",", $data).";";
|
|
|
$conn->query($sql);
|
|
|
$conn->close();
|
|
|
} else {
|
|
@@ -112,4 +124,43 @@ class StatsOnuCommand extends BaseCommand
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ private function getBandwidth($server, $olt) {
|
|
|
+
|
|
|
+ $bandwidth = array();
|
|
|
+
|
|
|
+ $doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
+ $nass = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceServer' => $server, 'deviceType' => 'RadiusBundle\Entity\NAS'));
|
|
|
+
|
|
|
+ foreach($nass as $index => $nas) {
|
|
|
+ $nasId = $nas->getDeviceId();
|
|
|
+
|
|
|
+ $d_s = "d_{$nasId}_s_{$server}";
|
|
|
+ $key_nas_onu_bandwidth = "nas_bandwidth_onu_{$d_s}";
|
|
|
+
|
|
|
+ $bandwidthCached = $this->getData($key_nas_onu_bandwidth, true);
|
|
|
+
|
|
|
+ if(empty($bandwidthCached)) continue;
|
|
|
+
|
|
|
+ foreach($bandwidthCached as $index => $data) {
|
|
|
+ if(!isset($data['sn'])) continue;
|
|
|
+ $bandwidth[$data['sn']] = $data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $d_s = "d_{$olt}_s_{$server}";
|
|
|
+ $key_olt_onu_bandwidth = "olt_bandwidth_onu_{$d_s}";
|
|
|
+
|
|
|
+ $bandwidthCached = $this->getData($key_olt_onu_bandwidth, true);
|
|
|
+
|
|
|
+ if($bandwidthCached) {
|
|
|
+ foreach($bandwidthCached as $index => $data) {
|
|
|
+ if(!isset($data['sn'])) continue;
|
|
|
+ $bandwidth[$data['sn']] = $data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $bandwidth;
|
|
|
+
|
|
|
+ }
|
|
|
}
|