|
@@ -14,7 +14,7 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/statsdevice/update", name="stats_update_devices")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function updateDevicesAction()
|
|
@@ -29,21 +29,21 @@ class StatsController extends Controller
|
|
|
/**
|
|
|
* Check value of geoserver_service parameter in parameters.yml
|
|
|
*/
|
|
|
- private function checkGeoserverService()
|
|
|
+ private function checkGeoserverService()
|
|
|
{
|
|
|
if($this->getParameter('geoserver_service')) {
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$this->flashMsg('msg_no_enable_geoserver_service');
|
|
|
return false;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Create simple flash message
|
|
|
*/
|
|
|
- private function flashMsg($msg = 'msg', $type = 'error', $bundle = 'StatsBundle')
|
|
|
+ private function flashMsg($msg = 'msg', $type = 'error', $bundle = 'StatsBundle')
|
|
|
{
|
|
|
$translator = $this->get('translator');
|
|
|
$flashbag = $this->get('session')->getFlashBag();
|
|
@@ -51,9 +51,9 @@ class StatsController extends Controller
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Set default lat-lng-zoom
|
|
|
+ * Set default lat-lng-zoom
|
|
|
*/
|
|
|
- private function setDefaultMap()
|
|
|
+ private function setDefaultMap()
|
|
|
{
|
|
|
$zoom = $this->getParameter('geoserver_default_zoom') ?? null;
|
|
|
$lat = $this->getParameter('geoserver_default_lat') ?? null;
|
|
@@ -63,13 +63,13 @@ class StatsController extends Controller
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Set layer lat-lng-zoom
|
|
|
+ * Set layer lat-lng-zoom
|
|
|
*/
|
|
|
- private function setLatLngZoom($srs)
|
|
|
+ private function setLatLngZoom($srs)
|
|
|
{
|
|
|
$lng = $srs['minx'] + ($srs['maxx'] - $srs['minx']) / 2;
|
|
|
$lat = $srs['miny'] + ($srs['maxy'] - $srs['miny']) / 2;
|
|
|
-
|
|
|
+
|
|
|
$lngDiff = $srs['maxx'] - $srs['minx'];
|
|
|
$latDiff = $srs['maxy'] - $srs['miny'];
|
|
|
$maxDiff = ($lngDiff > $latDiff) ? $lngDiff : $latDiff;
|
|
@@ -85,15 +85,15 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/onu/stats/map", name="onu_stats_map")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function showMapAction(Request $request)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
if(!$this->checkGeoserverService())
|
|
|
return $this->redirect($this->generateUrl('admin_stats_onu_list'));
|
|
|
-
|
|
|
+
|
|
|
$map = $this->setDefaultMap();
|
|
|
|
|
|
$adminPool = $this->get('sonata.admin.pool');
|
|
@@ -102,10 +102,10 @@ class StatsController extends Controller
|
|
|
$gsPort = $this->getParameter('geoserver_port');
|
|
|
$deviceServerId = $this->getParameter('device_server_base');
|
|
|
$tenancyId = $this->get("base_tenancy.tenancy_service")->getTenancyIdCurrent();
|
|
|
-
|
|
|
+
|
|
|
$workspace = "deviceServer_{$deviceServerId}";
|
|
|
$layer = "onu_stats_tenancy_{$tenancyId}";
|
|
|
-
|
|
|
+
|
|
|
$data = $api->getLayerData($workspace, $layer);
|
|
|
$srs = false;
|
|
|
|
|
@@ -136,15 +136,15 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/ponport/stats/map", name="ponport_stats_map")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function showPonPortMapAction(Request $request)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
if(!$this->checkGeoserverService())
|
|
|
return $this->redirect($this->generateUrl('admin_stats_ponport_list'));
|
|
|
-
|
|
|
+
|
|
|
$map = $this->setDefaultMap();
|
|
|
|
|
|
$ponPortId = $request->get('id');
|
|
@@ -154,23 +154,23 @@ class StatsController extends Controller
|
|
|
$api = $this->get('geoserver.api');
|
|
|
$gsHost = $this->getParameter('geoserver_host');
|
|
|
$gsPort = $this->getParameter('geoserver_port');
|
|
|
-
|
|
|
+
|
|
|
$ponPort = $em->getRepository("StatsBundle:PonPort")->findOneById($ponPortId);
|
|
|
$oltDeviceId = $ponPort->getOltDeviceId();
|
|
|
$deviceServerId = $ponPort->getDeviceServer()->getId();
|
|
|
$tenancyId = $ponPort->getTenancyId();
|
|
|
-
|
|
|
+
|
|
|
$data = explode("/", $ponPort->getPonPort());
|
|
|
$card = $data[0];
|
|
|
$slot = $data[1];
|
|
|
-
|
|
|
+
|
|
|
$workspace = "deviceServer_{$deviceServerId}";
|
|
|
$layer = "ponport_stats_t_{$tenancyId}_o_{$oltDeviceId}_s_{$deviceServerId}_c_{$card}_s_{$slot}";
|
|
|
|
|
|
$data = $api->getLayerData($workspace, $layer);
|
|
|
|
|
|
$srs = false;
|
|
|
-
|
|
|
+
|
|
|
if(!empty($data) && is_array($data)) {
|
|
|
if(isset($data['featureType']['latLonBoundingBox'])) {
|
|
|
$srs = $data['featureType']['latLonBoundingBox'];
|
|
@@ -199,22 +199,22 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/onu/stats/api_feature_json", name="api_feature_json")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
- public function apiFeatureJsonAction(Request $request)
|
|
|
+ public function apiFeatureJsonAction(Request $request)
|
|
|
{
|
|
|
$params = $request->query->all();
|
|
|
$data = explode(":",$params['LAYERS']);
|
|
|
-
|
|
|
+
|
|
|
$workspace = $data[0];
|
|
|
|
|
|
$api = $this->get('geoserver.api');
|
|
|
$return = $api->getFeature($workspace, $params);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
$data = json_decode($return,true);
|
|
|
-
|
|
|
+
|
|
|
if(isset($data['features']) && isset($data['features'][0])) {
|
|
|
$return = json_encode($data['features'][0]['properties']);
|
|
|
} else {
|
|
@@ -233,16 +233,16 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/deviceserver/getroutes", name="deviceserver_get_routes")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function deviceServerGetRoutesAction()
|
|
|
{
|
|
|
$webservice = $this->get("webservice");
|
|
|
-
|
|
|
+
|
|
|
$test = $webservice->makeGetRequest("http://200.50.168.118/base/app_dev.php/api/routes");
|
|
|
|
|
|
-
|
|
|
+
|
|
|
$response = new Response(
|
|
|
$test,
|
|
|
Response::HTTP_OK,
|
|
@@ -250,17 +250,17 @@ class StatsController extends Controller
|
|
|
);
|
|
|
|
|
|
return $response;
|
|
|
-
|
|
|
+
|
|
|
print_r("<pre>");
|
|
|
var_dump($test);
|
|
|
|
|
|
die;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/olt/stats/graph", name="stats_graph")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function getStatsGraphAction(Request $request)
|
|
@@ -305,10 +305,10 @@ class StatsController extends Controller
|
|
|
'urls' => $urls,
|
|
|
));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @Route("/admin/stats/onu/stats/graph", name="onu_stats_graph")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function getONUStatsGraphAction(Request $request)
|
|
@@ -344,7 +344,7 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/onu/grafana", name="grafana_onu")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function grafanaOnuAction(Request $request)
|
|
@@ -352,7 +352,7 @@ class StatsController extends Controller
|
|
|
$grafana_url = $this->getParameter('grafana_url');
|
|
|
|
|
|
$ponSerialNumber = strtolower($request->get('ponSerialNumber'));
|
|
|
-
|
|
|
+
|
|
|
$panelIds = array(6, 1, 2, 3, 4, 5);
|
|
|
foreach ($panelIds as $panelId) {
|
|
|
$urls[] = "onu?orgId=1&var-serialnumber={$ponSerialNumber}&panelId={$panelId}&theme=light";
|
|
@@ -373,20 +373,20 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/ponport/grafana", name="grafana_ponport")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function grafanaPonPortAction(Request $request)
|
|
|
{
|
|
|
$grafana_url = $this->getParameter('grafana_url');
|
|
|
-
|
|
|
+
|
|
|
$em = $this->get("doctrine.orm.entity_manager");
|
|
|
$ponPortId = $request->get('id');
|
|
|
-
|
|
|
+
|
|
|
$ponPort = $em->getRepository("StatsBundle:PonPort")->findOneById($ponPortId);
|
|
|
$oltDeviceId = $ponPort->getOltDeviceId();
|
|
|
$deviceServerId = $ponPort->getDeviceServer()->getId();
|
|
|
-
|
|
|
+
|
|
|
$panelIds = array(1, 2, 3, 4);
|
|
|
$data = explode("/", $ponPort->getPonPort());
|
|
|
if(count($data) == 3) {
|
|
@@ -416,29 +416,29 @@ class StatsController extends Controller
|
|
|
));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/ponport/grafana", name="grafana_ponport")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function grafanaInterfaceAction(Request $request)
|
|
|
{
|
|
|
$grafana_url = $this->getParameter('grafana_url');
|
|
|
-
|
|
|
+
|
|
|
$em = $this->get("doctrine.orm.entity_manager");
|
|
|
$interfaceId = $request->get('id');
|
|
|
|
|
|
-
|
|
|
+
|
|
|
$interface = $em->getRepository("StatsBundle:CmtsInterface")->findOneById($interfaceId);
|
|
|
$cmtsDeviceId = $interface->getCmtsDeviceId();
|
|
|
$deviceServerId = $interface->getDeviceServer()->getId();
|
|
|
$index = $interface->getIndex();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
$panelIds = array(1, 2, 3);
|
|
|
-
|
|
|
+
|
|
|
foreach ($panelIds as $panelId) {
|
|
|
$urls[] = "cmts-interface?orgId=1&var-cmts={$cmtsDeviceId}&var-server={$deviceServerId}&var-interface={$index}&panelId={$panelId}&theme=light";
|
|
|
}
|
|
@@ -457,7 +457,7 @@ class StatsController extends Controller
|
|
|
|
|
|
/**
|
|
|
* @Route("/admin/stats/cablemodem/grafana", name="grafana_cablemodem")
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
public function grafanaCablemodemAction(Request $request)
|
|
@@ -465,7 +465,7 @@ class StatsController extends Controller
|
|
|
$grafana_url = $this->getParameter('grafana_url');
|
|
|
|
|
|
$mac = strtolower($request->get('mac'));
|
|
|
-
|
|
|
+
|
|
|
$panelIds = array(1, 2, 3, 4, 5);
|
|
|
foreach ($panelIds as $panelId) {
|
|
|
$urls[] = "cablemodem?orgId=1&var-mac={$mac}&var-tx_channel=2&var-channel=3&panelId={$panelId}&theme=light";
|