|
@@ -485,131 +485,184 @@ class StatsController extends Controller
|
|
|
|
|
|
public function cmtsInterfaceHistoricAction(Request $request)
|
|
|
{
|
|
|
- $em = $this->get("doctrine.orm.entity_manager");
|
|
|
- $endpoint = $this->get('endpoint.mongo');
|
|
|
-
|
|
|
- ($request->get('from'))? $from = $request->get('from') : $from = date("Y-m-d H:i:s",strtotime("-3 hour"));
|
|
|
- ($request->get('to'))? $to = $request->get('to') : $to = date("Y-m-d H:i:s",strtotime("now"));
|
|
|
- $range = array('from' => $from, 'to' => $to);
|
|
|
-
|
|
|
- $interface = $em->getRepository("StatsBundle:CmtsInterface")->findOneById($request->get('id'));
|
|
|
- $cmtsDeviceId = $interface->getCmtsDeviceId();
|
|
|
- $deviceServerId = $interface->getDeviceServer()->getId();
|
|
|
- $index = $interface->getIndex();
|
|
|
-
|
|
|
- $prefix = "d_{$cmtsDeviceId}_s_{$deviceServerId}";
|
|
|
-
|
|
|
- $series = $targets = array();
|
|
|
- $targets["in_bandwidth"] = array("target" => "{$prefix}_inbandwidth_if_{$index}");
|
|
|
- $targets["out_bandwidth"] = array("target" => "{$prefix}_outbandwidth_if_{$index}");
|
|
|
- $targets["signal"] = array("target" => "{$prefix}_if_signal_{$index}");
|
|
|
- $targets["on"] = array("target" => "{$prefix}_if_state_on_{$index}");
|
|
|
- $targets["off"] = array("target" => "{$prefix}_if_state_off_{$index}");
|
|
|
-
|
|
|
- $errors = array();
|
|
|
-
|
|
|
- foreach($targets as $index => $t) {
|
|
|
+ $em = $this->get("doctrine.orm.entity_manager");
|
|
|
+ $endpoint = $this->get('endpoint.mongo');
|
|
|
|
|
|
- if(!isset($series[$index])) $series[$index] = array('name' => $index, 'data' => array());
|
|
|
-
|
|
|
- $search = array('targets' => array(0 => $t), 'maxDataPoints' => 5000, 'range' => $range);
|
|
|
- try {
|
|
|
- $data = $endpoint->get(json_encode($search),'query', true);
|
|
|
- } catch(\Exception $e) {
|
|
|
- $errors[] = array("msg" => "Falla mongo_json_endpoint({$index}): {$e->getMessage()}");
|
|
|
- $data = array();
|
|
|
- }
|
|
|
+ ($request->get('from'))? $from = $request->get('from') : $from = date("Y-m-d H:i:s",strtotime("-3 hour"));
|
|
|
+ ($request->get('to'))? $to = $request->get('to') : $to = date("Y-m-d H:i:s",strtotime("now"));
|
|
|
+ $range = array('from' => $from, 'to' => $to);
|
|
|
+
|
|
|
+ $interface = $em->getRepository("StatsBundle:CmtsInterface")->findOneById($request->get('id'));
|
|
|
+ $cmtsDeviceId = $interface->getCmtsDeviceId();
|
|
|
+ $deviceServerId = $interface->getDeviceServer()->getId();
|
|
|
+ $index = $interface->getIndex();
|
|
|
+
|
|
|
+ $prefix = "d_{$cmtsDeviceId}_s_{$deviceServerId}";
|
|
|
+
|
|
|
+ $series = $targets = array();
|
|
|
+ $targets["in_bandwidth"] = array("target" => "{$prefix}_inbandwidth_if_{$index}");
|
|
|
+ $targets["out_bandwidth"] = array("target" => "{$prefix}_outbandwidth_if_{$index}");
|
|
|
+ $targets["signal"] = array("target" => "{$prefix}_if_signal_{$index}");
|
|
|
+ $targets["on"] = array("target" => "{$prefix}_if_state_on_{$index}");
|
|
|
+ $targets["off"] = array("target" => "{$prefix}_if_state_off_{$index}");
|
|
|
+
|
|
|
+ $errors = array();
|
|
|
+
|
|
|
+ foreach($targets as $index => $t) {
|
|
|
+
|
|
|
+ if(!isset($series[$index])) $series[$index] = array('name' => $index, 'data' => array());
|
|
|
+
|
|
|
+ $search = array('targets' => array(0 => $t), 'maxDataPoints' => 5000, 'range' => $range);
|
|
|
+ try {
|
|
|
+ $data = $endpoint->get(json_encode($search),'query', true);
|
|
|
+ } catch(\Exception $e) {
|
|
|
+ $errors[] = array("msg" => "Falla mongo_json_endpoint({$index}): {$e->getMessage()}");
|
|
|
+ $data = array();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- if(isset($data[0]) && isset($data[0]['datapoints'])) {
|
|
|
- $points = array();
|
|
|
- foreach($data[0]['datapoints'] as $d) {
|
|
|
- $points[] = array($d[1],$d[0]);
|
|
|
+ if(isset($data[0]) && isset($data[0]['datapoints'])) {
|
|
|
+ $points = array();
|
|
|
+ foreach($data[0]['datapoints'] as $d) {
|
|
|
+ $points[] = array($d[1],$d[0]);
|
|
|
+ }
|
|
|
+ $series[$index]['data'] = $points;
|
|
|
}
|
|
|
- $series[$index]['data'] = $points;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if ($request->isMethod('GET')) {
|
|
|
- return $this->render('StatsBundle:Stats:cmts_interface.html.twig', array(
|
|
|
- 'series' => $series
|
|
|
- ));
|
|
|
- }
|
|
|
+ if ($request->isMethod('GET')) {
|
|
|
+ return $this->render('StatsBundle:Stats:cmts_interface.html.twig', array(
|
|
|
+ 'series' => $series
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
- return new JsonResponse(array(
|
|
|
- 'series' => $series,
|
|
|
- ));
|
|
|
+ return new JsonResponse(array(
|
|
|
+ 'series' => $series,
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
public function oltPonPortHistoricAction(Request $request)
|
|
|
{
|
|
|
- $em = $this->get("doctrine.orm.entity_manager");
|
|
|
- $endpoint = $this->get('endpoint.mongo');
|
|
|
-
|
|
|
- ($request->get('from'))? $from = $request->get('from') : $from = date("Y-m-d H:i:s",strtotime("-3 hour"));
|
|
|
- ($request->get('to'))? $to = $request->get('to') : $to = date("Y-m-d H:i:s",strtotime("now"));
|
|
|
- $range = array('from' => $from, 'to' => $to);
|
|
|
-
|
|
|
- $pon = $em->getRepository("StatsBundle:PonPort")->findOneById($request->get('id'));
|
|
|
- $oltDeviceId = $pon->getOltDeviceId();
|
|
|
- $deviceServerId = $pon->getDeviceServer()->getId();
|
|
|
- $ponPort = str_replace("/",".",$pon->getPonPort());
|
|
|
-
|
|
|
- $prefix = "d_{$oltDeviceId}_s_{$deviceServerId}";
|
|
|
-
|
|
|
- $series = $targets = array();
|
|
|
- $targets["in_bandwidth"] = array("target" => "{$prefix}_inbandwidth_pon_{$ponPort}");
|
|
|
- $targets["out_bandwidth"] = array("target" => "{$prefix}_outbandwidth_pon_{$ponPort}");
|
|
|
- $targets["tx"] = array("target" => "{$prefix}_pon_tx_{$ponPort}");
|
|
|
- $targets["voltage"] = array("target" => "{$prefix}_pon_voltage_{$ponPort}");
|
|
|
- $targets["temperature"] = array("target" => "{$prefix}_pon_temperature_{$ponPort}");
|
|
|
- $targets["on"] = array("target" => "{$prefix}_pon_state_on_{$ponPort}");
|
|
|
- $targets["off"] = array("target" => "{$prefix}_pon_state_off_{$ponPort}");
|
|
|
-
|
|
|
- $errors = array();
|
|
|
-
|
|
|
- foreach($targets as $index => $t) {
|
|
|
+ $em = $this->get("doctrine.orm.entity_manager");
|
|
|
+ $endpoint = $this->get('endpoint.mongo');
|
|
|
|
|
|
- if(!isset($series[$index])) $series[$index] = array('name' => $index, 'data' => array());
|
|
|
-
|
|
|
- $search = array('targets' => array(0 => $t), 'maxDataPoints' => 5000, 'range' => $range);
|
|
|
- try {
|
|
|
- $data = $endpoint->get(json_encode($search),'query', true);
|
|
|
- } catch(\Exception $e) {
|
|
|
- $errors[] = array("msg" => "Falla mongo_json_endpoint({$index}): {$e->getMessage()}");
|
|
|
- $data = array();
|
|
|
+ ($request->get('from'))? $from = $request->get('from') : $from = date("Y-m-d H:i:s",strtotime("-3 hour"));
|
|
|
+ ($request->get('to'))? $to = $request->get('to') : $to = date("Y-m-d H:i:s",strtotime("now"));
|
|
|
+ $range = array('from' => $from, 'to' => $to);
|
|
|
+
|
|
|
+ $pon = $em->getRepository("StatsBundle:PonPort")->findOneById($request->get('id'));
|
|
|
+ $oltDeviceId = $pon->getOltDeviceId();
|
|
|
+ $deviceServerId = $pon->getDeviceServer()->getId();
|
|
|
+ $ponPort = str_replace("/",".",$pon->getPonPort());
|
|
|
+
|
|
|
+ $prefix = "d_{$oltDeviceId}_s_{$deviceServerId}";
|
|
|
+
|
|
|
+ $series = $targets = array();
|
|
|
+ $targets["in_bandwidth"] = array("target" => "{$prefix}_inbandwidth_pon_{$ponPort}");
|
|
|
+ $targets["out_bandwidth"] = array("target" => "{$prefix}_outbandwidth_pon_{$ponPort}");
|
|
|
+ $targets["tx"] = array("target" => "{$prefix}_pon_tx_{$ponPort}");
|
|
|
+ $targets["voltage"] = array("target" => "{$prefix}_pon_voltage_{$ponPort}");
|
|
|
+ $targets["temperature"] = array("target" => "{$prefix}_pon_temperature_{$ponPort}");
|
|
|
+ $targets["on"] = array("target" => "{$prefix}_pon_state_on_{$ponPort}");
|
|
|
+ $targets["off"] = array("target" => "{$prefix}_pon_state_off_{$ponPort}");
|
|
|
+
|
|
|
+ $errors = array();
|
|
|
+
|
|
|
+ foreach($targets as $index => $t) {
|
|
|
+
|
|
|
+ if(!isset($series[$index])) $series[$index] = array('name' => $index, 'data' => array());
|
|
|
+
|
|
|
+ $search = array('targets' => array(0 => $t), 'maxDataPoints' => 5000, 'range' => $range);
|
|
|
+ try {
|
|
|
+ $data = $endpoint->get(json_encode($search),'query', true);
|
|
|
+ } catch(\Exception $e) {
|
|
|
+ $errors[] = array("msg" => "Falla mongo_json_endpoint({$index}): {$e->getMessage()}");
|
|
|
+ $data = array();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($data[0]) && isset($data[0]['datapoints'])) {
|
|
|
+ $points = array();
|
|
|
+ foreach($data[0]['datapoints'] as $d) {
|
|
|
+ $points[] = array($d[1],$d[0]);
|
|
|
+ }
|
|
|
+ $series[$index]['data'] = $points;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if(isset($data[0]) && isset($data[0]['datapoints'])) {
|
|
|
- $points = array();
|
|
|
- foreach($data[0]['datapoints'] as $d) {
|
|
|
- $points[] = array($d[1],$d[0]);
|
|
|
+ $q = $em->getRepository("StatsBundle:Onu")->createQueryBuilder('o');
|
|
|
+ $onus = $q->where($q->expr()->like('o.ponPort', ':ponPort'))
|
|
|
+ ->andWhere('o.oltDeviceId = :oltDeviceId')
|
|
|
+ ->andWhere('o.deviceServer = :deviceServer')
|
|
|
+ ->setParameter('ponPort', "{$pon->getPonPort()}%")
|
|
|
+ ->setParameter('oltDeviceId', $oltDeviceId)
|
|
|
+ ->setParameter('deviceServer', $deviceServerId)
|
|
|
+ ->getQuery()
|
|
|
+ ->getResult();
|
|
|
+
|
|
|
+ $seriesOnus = $targets = array();
|
|
|
+ if($onus) {
|
|
|
+ foreach($onus as $index => $onu) {
|
|
|
+ $ponPort = str_replace("/",".",$onu->getPonPort());
|
|
|
+ $targets[$onu->getPonSerialNumber()] = array("target" => "{$prefix}_pon_rx_{$ponPort}");
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($targets as $index => $t) {
|
|
|
+
|
|
|
+ if(!isset($seriesOnus[$index])) $seriesOnus[$index] = array('name' => $index, 'data' => array());
|
|
|
+
|
|
|
+ $search = array('targets' => array(0 => $t), 'maxDataPoints' => 5000, 'range' => $range);
|
|
|
+ try {
|
|
|
+ $data = $endpoint->get(json_encode($search),'query', true);
|
|
|
+ } catch(\Exception $e) {
|
|
|
+ $errors[] = array("msg" => "Falla mongo_json_endpoint({$index}): {$e->getMessage()}");
|
|
|
+ $data = array();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($data[0]) && isset($data[0]['datapoints'])) {
|
|
|
+ $points = array();
|
|
|
+ foreach($data[0]['datapoints'] as $d) {
|
|
|
+ $points[] = array($d[1],$d[0]);
|
|
|
+ }
|
|
|
+ $seriesOnus[$index]['data'] = $points;
|
|
|
+ }
|
|
|
}
|
|
|
- $series[$index]['data'] = $points;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- $q = $em->getRepository("StatsBundle:Onu")->createQueryBuilder('o');
|
|
|
- $onus = $q->where($q->expr()->like('o.ponPort', ':ponPort'))
|
|
|
- ->andWhere('o.oltDeviceId = :oltDeviceId')
|
|
|
- ->andWhere('o.deviceServer = :deviceServer')
|
|
|
- ->setParameter('ponPort', "{$pon->getPonPort()}%")
|
|
|
- ->setParameter('oltDeviceId', $oltDeviceId)
|
|
|
- ->setParameter('deviceServer', $deviceServerId)
|
|
|
- ->getQuery()
|
|
|
- ->getResult();
|
|
|
-
|
|
|
- $seriesOnus = $targets = array();
|
|
|
- if($onus) {
|
|
|
- foreach($onus as $index => $onu) {
|
|
|
- $ponPort = str_replace("/",".",$onu->getPonPort());
|
|
|
- $targets[$onu->getPonSerialNumber()] = array("target" => "{$prefix}_pon_rx_{$ponPort}");
|
|
|
+ if ($request->isMethod('GET')) {
|
|
|
+ return $this->render('StatsBundle:Stats:olt_ponport.html.twig', array(
|
|
|
+ 'series' => $series,
|
|
|
+ 'seriesOnus' => $seriesOnus
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
- foreach($targets as $index => $t) {
|
|
|
+ return new JsonResponse(array('series' => $series,'seriesOnus' => $seriesOnus));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function onuHistoricAction(Request $request)
|
|
|
+ {
|
|
|
+ $endpoint = $this->get('endpoint.mongo');
|
|
|
+
|
|
|
+ ($request->get('from'))? $from = $request->get('from') : $from = date("Y-m-d H:i:s",strtotime("-3 hour"));
|
|
|
+ ($request->get('to'))? $to = $request->get('to') : $to = date("Y-m-d H:i:s",strtotime("now"));
|
|
|
+ $range = array('from' => $from, 'to' => $to);
|
|
|
+
|
|
|
+ $psn = strtolower($request->get('ponSerialNumber'));
|
|
|
+
|
|
|
+ $series = $targets = array();
|
|
|
+ $targets["in_bandwidth"] = array("target" => "inbandwidth_onu_{$psn}");
|
|
|
+ $targets["out_bandwidth"] = array("target" => "outbandwidth_onu_{$psn}");
|
|
|
+ $targets["tx"] = array("target" => "onu_tx_{$psn}");
|
|
|
+ $targets["rx"] = array("target" => "onu_rx_{$psn}");
|
|
|
+ $targets["voltage"] = array("target" => "onu_voltage_{$psn}");
|
|
|
+ $targets["temperature"] = array("target" => "onu_temperature_{$psn}");
|
|
|
+ $targets["status"] = array("target" => "onu_status_{$psn}");
|
|
|
|
|
|
- if(!isset($seriesOnus[$index])) $seriesOnus[$index] = array('name' => $index, 'data' => array());
|
|
|
-
|
|
|
+ $errors = array();
|
|
|
+
|
|
|
+ foreach($targets as $index => $t) {
|
|
|
+
|
|
|
+ if(!isset($series[$index])) $series[$index] = array('name' => $index, 'data' => array());
|
|
|
+
|
|
|
$search = array('targets' => array(0 => $t), 'maxDataPoints' => 5000, 'range' => $range);
|
|
|
try {
|
|
|
$data = $endpoint->get(json_encode($search),'query', true);
|
|
@@ -617,27 +670,23 @@ class StatsController extends Controller
|
|
|
$errors[] = array("msg" => "Falla mongo_json_endpoint({$index}): {$e->getMessage()}");
|
|
|
$data = array();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(isset($data[0]) && isset($data[0]['datapoints'])) {
|
|
|
$points = array();
|
|
|
foreach($data[0]['datapoints'] as $d) {
|
|
|
$points[] = array($d[1],$d[0]);
|
|
|
}
|
|
|
- $seriesOnus[$index]['data'] = $points;
|
|
|
+ $series[$index]['data'] = $points;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if ($request->isMethod('GET')) {
|
|
|
- return $this->render('StatsBundle:Stats:olt_ponport.html.twig', array(
|
|
|
- 'series' => $series,
|
|
|
- 'seriesOnus' => $seriesOnus
|
|
|
- ));
|
|
|
- }
|
|
|
+ if ($request->isMethod('GET')) {
|
|
|
+ return $this->render('StatsBundle:Stats:olt_onu.html.twig', array(
|
|
|
+ 'series' => $series
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
- return new JsonResponse(array(
|
|
|
- 'series' => $series,
|
|
|
- ));
|
|
|
+ return new JsonResponse(array('series' => $series,));
|
|
|
}
|
|
|
|
|
|
}
|