|
@@ -47,12 +47,16 @@ class StatsPonPortCommand extends BaseCommand
|
|
|
$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}.");
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ $key_olt_pon_bandwidth = "olt_bandwidth_pons_d_{$oltDeviceId}_s_{$oltServerId}";
|
|
|
+ $status = $this->getCountOnus($deviceServerId, $oltDeviceId);
|
|
|
+ $bandwidth = $this->getData($key_olt_pon_bandwidth, true);
|
|
|
+
|
|
|
$ponPorts = $doctrine->getRepository('\StatsBundle\Entity\PonPort')->findBy(array('oltDeviceId' => $oltDeviceId, 'deviceServer' => $oltServerId));
|
|
|
$_ponPorts = array();
|
|
|
foreach($ponPorts as $k => $pp) {
|
|
@@ -83,6 +87,22 @@ class StatsPonPortCommand extends BaseCommand
|
|
|
(isset($stats['temperature']))? $row['temperature'] = $stats['temperature'] : $row['temperature'] = "NULL";
|
|
|
(isset($stats['biasCurrent']))? $row['biasCurrent'] = $stats['biasCurrent'] : $row['biasCurrent'] = "NULL";
|
|
|
|
|
|
+ if(isset($bandwidth[$index])) {
|
|
|
+ $row['inOctets'] = $bandwidth[$index]['inBand'];
|
|
|
+ $row['outOctets'] = $bandwidth[$index]['outBand'];
|
|
|
+ } else {
|
|
|
+ $row['inOctets'] = $row['outOctets'] = "NULL";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($status[$ponPort])) {
|
|
|
+ $row['online'] = $status[$ponPort][1];
|
|
|
+ $row['offline'] = $status[$ponPort][0];
|
|
|
+ } else {
|
|
|
+ $row['online'] = $row['offline'] = "NULL";
|
|
|
+ }
|
|
|
+
|
|
|
+ $row['index'] = $index;
|
|
|
+
|
|
|
$data[] = "(".implode(",",$row).")".PHP_EOL;
|
|
|
}
|
|
|
|
|
@@ -92,14 +112,44 @@ class StatsPonPortCommand extends BaseCommand
|
|
|
$conn->close();
|
|
|
|
|
|
$conn = $doctrine->getConnection();
|
|
|
- $sql = "INSERT LOW_PRIORITY IGNORE INTO `pon_port` (`id`,`device_server_id`,`pon_port`,`olt_device_id`,`tenancy_id`,`updated`,`tx_power`,`rx_power`,`voltage`,`temperature`,`bias_current`) VALUES ". implode(",", $data).";";
|
|
|
+ $sql = "INSERT LOW_PRIORITY IGNORE INTO `pon_port` (`id`,`device_server_id`,`pon_port`,`olt_device_id`,`tenancy_id`,`updated`,`tx_power`,`rx_power`,`voltage`,`temperature`,`bias_current`,`in_octets`,`out_octets`,`online`,`offline`,`index`) VALUES ". implode(",", $data).";";
|
|
|
|
|
|
- //print_r($sql);
|
|
|
$conn->query($sql);
|
|
|
$conn->close();
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private function getCountOnus($server, $olt) {
|
|
|
+ $key_onu_stats = "onu_status_d_{$olt}_s_{$server}";
|
|
|
+ $key_olt_scan = "olt_scan_d_{$olt}_s_{$server}";
|
|
|
+
|
|
|
+ $status = $this->getData($key_onu_stats, true);
|
|
|
+ $onus = $this->getData($key_olt_scan, true);
|
|
|
+
|
|
|
+ $return = array();
|
|
|
+ foreach($onus as $index => $info) {
|
|
|
+ $pp = explode("/",$info['ponport']);
|
|
|
+ if(count($pp) == 3) {
|
|
|
+ $port = "{$pp[0]}/{$pp[1]}";
|
|
|
+ } elseif(count($pp) == 4) {
|
|
|
+ $port = "{$pp[0]}/{$pp[1]}/{$pp[2]}";
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!isset($return[$port])) $return[$port] = array(0,0);
|
|
|
+ $sn = $info['serialNumber'];
|
|
|
+ if(isset($status[$sn])) {
|
|
|
+ $state = $status[$sn];
|
|
|
+ $return[$port][$state]++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|