show netif on multiple links to same neighbour

fixes #1
This commit is contained in:
Dominik Heidler 2015-11-27 15:49:02 +01:00
parent 1762f095a7
commit 0716ed945a
2 changed files with 22 additions and 16 deletions

View File

@ -1,6 +1,7 @@
var points_per_px = 0.3;
var controls_container = "<div style='right:60px;top:13px;position:absolute;display:none;' id='controls'></div>";
var reset_button = "<div class='btn btn-default btn-xs'>Reset</div>";
timezoneJS.timezone.zoneFileBasePath = '/static/tz';
function labelFormatter(label, series) {
@ -13,8 +14,8 @@ function labelFormatter(label, series) {
}
function legendFormatter(label, series) {
var append_dots = (label.length > 18);
label = label.substr(0, 17);
var append_dots = (label.length > 28);
label = label.substr(0, 27);
if (append_dots) {
label += "&hellip;";
}
@ -104,6 +105,15 @@ function neighbour_graph(neighbours) {
var pdata = [];
for (j=0; j<neighbours.length; j++) {
var label = neighbours[j].name;
// add network interface when there are multiple links to same node
var k;
for(k=0; k<neighbours.length; k++) {
if(label == neighbours[k].name && k != j) {
label += "@" + neighbours[j].net_if;
}
}
var mac = neighbours[j].mac;
var data = [];
var len, i;
@ -253,7 +263,7 @@ function global_client_graph() {
var plot = $.plot(clientstat, pdata, {
xaxis: {mode: "time", timezone: "browser"},
selection: {mode: "x"},
yaxis: {min: 0},
yaxis: {min: 0, autoscaleMargin: 0.1},
legend: {hideable: true},
//points: {show: true}
series: {downsample: {threshold: Math.floor(clientstat.width() * points_per_px)}}
@ -336,7 +346,7 @@ function global_router_models_graph() {
});
placeholder.bind("plotclick", function(event, pos, obj) {
if (obj) {
window.location.href = routers_page_url + "?q=hardware.name:" + obj.series.label;
window.location.href = routers_page_url + "?q=hardware.name:" + obj.series.label.replace(/ /g, '_');
}
});
}

View File

@ -101,7 +101,7 @@
</td></tr>
<tr><th class="text-nowrap">Last contact</th><td>
{{ router.last_contact|utc2local|format_dt }}
({{ router.last_contact|format_dt_ago }})
({{ router.last_contact|format_dt_ago }}){{- "" -}}
</td></tr>
{%- if router.description %}
<tr><th>Description</th><td>{{ router.description }}</td></tr>
@ -190,16 +190,6 @@
{%- endfor %}
{%- endif %}
<div id="meshstat" class="graph" style="height: 300px;"></div>
<script type="text/javascript">
var neighbours = [
{%- for neighbour in router.neighbours %}
{"name": "{{ neighbour.hostname or neighbour.mac }}", "mac": "{{ neighbour.mac }}"},
{%- endfor %}
];
$(function() {
neighbour_graph(neighbours);
});
</script>
</div>
</div>
</div>
@ -241,7 +231,7 @@
<li class="list-group-item" data-name="{{ netif.name|replace('.', '')|replace('$', '') }}">
<h4 class="list-group-item-heading"><div class="row">
<div class="col-xs-6 col-sm-6">{{ netif.name }}</div>
<div class="col-xs-6 col-sm-6 text-right">{{ netif.mac|upper }}</div>
<div class="col-xs-6 col-sm-6 text-right" style="text-transform: uppercase;">{{ netif.mac }}</div>
</div></h4>
<p class="list-group-item-text"><div class="row">
<div class="col-xs-5 col-sm-5">
@ -286,7 +276,13 @@
</div>
<script type="text/javascript">
var router_stats = {{ router.stats|statbson2json|safe }};
var neighbours = [
{%- for neighbour in router.neighbours %}
{"name": "{{ neighbour.hostname or neighbour.mac }}", "mac": "{{ neighbour.mac }}", "net_if": "{{ neighbour.net_if }}"},
{%- endfor %}
];
$(document).ready(function() {
neighbour_graph(neighbours);
memory_graph();
process_graph();
client_graph();