Procházet zdrojové kódy

FD3-562 Se agregan vistas por highcharts para CM.

Maxi Schvindt před 7 roky
rodič
revize
18ac1897c1

+ 2 - 2
composer.lock

@@ -1688,7 +1688,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/GeoserverBundle.git",
-                "reference": "587d0a59cea00fb910b6db9e3037ff38f788f2f0"
+                "reference": "53061ce8e08150f39c3e3a40dc176affd6c630fe"
             },
             "type": "library",
             "autoload": {
@@ -1701,7 +1701,7 @@
                 "Flowdat 3",
                 "Geoserver"
             ],
-            "time": "2018-06-19T12:57:54+00:00"
+            "time": "2018-06-19T13:48:07+00:00"
         },
         {
             "name": "ik/stats/huawei-bundle",

+ 50 - 0
src/StatsBundle/Controller/StatsController.php

@@ -689,4 +689,54 @@ class StatsController extends Controller
         return new JsonResponse(array('series' => $series,));
     }
 
+    public function cablemodemHistoricAction(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);
+
+        $mac = strtolower($request->get('mac'));
+
+        $series = $targets = array();
+        $targets["in_bandwidth"] = array("target" => "inbandwidth_cm_{$mac}");
+        $targets["out_bandwidth"] = array("target" => "outbandwidth_cm_{$mac}");
+        $targets["tx"] = array("target" => "cm_tx_{$mac}.2");
+        $targets["rx"] = array("target" => "cm_rx_{$mac}.3");
+        $targets["signal"] = array("target" => "cm_signal_{$mac}.3");
+        $targets["microreflection"] = array("target" => "cm_microreflection_{$mac}.3");
+        
+        $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 ($request->isMethod('GET')) {
+            return $this->render('StatsBundle:Stats:cmts_cablemodem.html.twig', array(
+                        'series' => $series
+            ));
+        }
+
+        return new JsonResponse(array('series' => $series,));
+    }
+
 }

+ 4 - 1
src/StatsBundle/Resources/views/Cablemodem/base_show.html.twig

@@ -2,9 +2,12 @@
 
 {% block show %}
     {{ parent() }}
+
+    <script src="{{ asset('bundles/stats/highcharts/code/highcharts.js') }}" type="text/javascript" charset="utf-8"></script>
+    <script src="{{ asset('bundles/stats/highcharts/highchartsConfig.js') }}" type="text/javascript" charset="utf-8"></script>
     
     {% if object.getDeviceServer().getSaveHistoric() == 1 %}
-    {{ render(controller('StatsBundle:Stats:grafanaCablemodem', { 'mac':object.mac })) }}
+    {{ render(controller('StatsBundle:Stats:cablemodemHistoric', { 'mac':object.mac })) }}
     {% endif %}
     
 {% endblock %}

+ 106 - 0
src/StatsBundle/Resources/views/Stats/cmts_cablemodem.html.twig

@@ -0,0 +1,106 @@
+<div class="row">
+    <div class="col-md-12">
+        <div id="cmts_cablemodem_bandwidth" style="height: 400px;"></div>
+
+        <div id="cmts_cablemodem_rf" style="height: 400px;"></div>
+        
+        <div class="clearfix" style="width: 100%; background-color:white; padding:0 5px">
+            <div id="cmts_cablemodem_snr" style="height: 400px; float: left; width:49%"></div>
+            <div id="cmts_cablemodem_microreflection" style="height: 400px; float: right; width:49%"></div>
+        </div>
+
+        {# <div id="olt_onu_status" style="height: 400px;"></div> #}
+    </div>
+</div>
+
+<script type="text/javascript">
+
+Highcharts.chart('cmts_cablemodem_bandwidth', {
+    chart: {type: 'spline'},
+    title: {text: 'Bandwidth Cablemodem'},
+    subtitle: {text: 'IN Bandwidth / OUT Bandwidth'},
+    xAxis: {type: 'datetime',dateTimeLabelFormats: {month: '%e. %b',year: '%b'},title: {text: 'Date'}},
+    yAxis: {labels: {formatter: bandwidthAxisLabel,align: 'left'},min: 0},
+    tooltip: {formatter: bandwidthTooltip},
+    plotOptions: {spline: {marker: {enabled: true}}},
+    series: [{
+        name: "OUT Bandwidth",
+        data: {{series['out_bandwidth']['data']|json_encode}},
+        color: '#e24d42'
+        },{
+        name: "IN Bandwidth",
+        data: {{series['in_bandwidth']['data']|json_encode}},
+        color: '#3f6833'
+    }]
+});
+
+Highcharts.chart('cmts_cablemodem_rf', {
+    chart: {type: 'area'},
+    title: {text: 'Radio Frequency'},
+    subtitle: {text: 'TX /RX Power'},
+    xAxis: {type: 'datetime',dateTimeLabelFormats: {month: '%e. %b',year: '%b'},title: {text: 'Date'}},
+    yAxis: {labels: {format: '{value} dB'},min: null},
+    tooltip: {valueSuffix: ' dB',valueDecimals: 2},
+    plotOptions: {spline: {marker: {enabled: true}}},
+    series: [{
+        name: "TX Power",
+        data: {{series['tx']['data']|json_encode}},
+        color: '#6ed0e0',
+        fillOpacity: 0.2
+    },{
+        name: "RX Power",
+        data: {{series['rx']['data']|json_encode}},
+        color: '#4841AD',
+        fillOpacity: 0.2
+    }]
+});
+
+Highcharts.chart('cmts_cablemodem_snr', {
+    chart: {type: 'area'},
+    title: {text: 'SNR'},
+    subtitle: {text: 'SNR'},
+    xAxis: {type: 'datetime',dateTimeLabelFormats: {month: '%e. %b',year: '%b'},title: {text: 'Date'}},
+    yAxis: {labels: {format: '{value} V'},min: 0},
+    tooltip: {valueSuffix: ' V',valueDecimals: 2},
+    plotOptions: {spline: {marker: {enabled: true}}},
+    series: [{
+        name: "Snr",
+        data: {{series['signal']['data']|json_encode}},
+        color: '#4841AD',
+        fillOpacity: 0.2
+    }]
+});
+
+Highcharts.chart('cmts_cablemodem_microreflection', {
+    chart: {type: 'area'},
+    title: {text: 'Microreflection'},
+    subtitle: {text: 'Microreflection'},
+    xAxis: {type: 'datetime',dateTimeLabelFormats: {month: '%e. %b',year: '%b'},title: {text: 'Date'}},
+    yAxis: {labels: {format: '{value} ºC'},min: 0},
+    tooltip: {valueSuffix: ' ºC',valueDecimals: 2},
+    plotOptions: {spline: {marker: {enabled: true}}},
+    series: [{
+        name: "Microreflection",
+        data: {{series['microreflection']['data']|json_encode}},
+        color: '#B75426',
+        fillOpacity: 0.2
+    }]
+});
+
+
+{# Highcharts.chart('olt_onu_status', {
+    chart: {type: 'area'},
+    title: {text: 'Estatus'},
+    subtitle: {text: 'Online / Offline'},
+    xAxis: {type: 'datetime',dateTimeLabelFormats: {month: '%e. %b',year: '%b'},title: {text: 'Date'}},
+    yAxis: { categories: ['Offline', 'Online'], min: 0,stackLabels: {enabled: true,style: {fontWeight: 'bold',color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'}}},
+    tooltip: {formatter: onuStatusTooltip},
+    plotOptions: {column: {stacking: 'normal',dataLabels: {enabled: true,color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'}}},
+    series: [{
+        name: 'Status',
+        data: {{series['status']['data']|json_encode}},
+        color: '#3f6833'
+    }]
+}); #}
+
+</script>