get interface names from fireqos interfaces
Costa Tsaousis (ktsaou) committed
Dec 23, 2015 at 22:26 UTC
969fd497fc381e6419099872bc6c6c58b218f86c
1 file changed
+38
-20
web/index.html
+38
-20
@@ -509,6 +509,7 @@ if(document.location.hostname === demo_hostname) {
509
510
var options = {
511
sparklines_registry: {},
512
+ interfaces_registry: {},
513
data: null,
514
hostname: 'netdata_server', // will be overwritten by the netdata server
515
categories: new Array(),
@@ -639,6 +640,14 @@ function prepareScreen(data) {
640
document.title = options.hostname + ' dashboard';
641
var charts = data.charts;
642
643
+ function name2id(s) {
644
+ return s
645
+ .replace(' ', '_')
646
+ .replace('(', '_')
647
+ .replace(')', '_')
648
+ .replace('/', '_');
649
+ }
650
+
651
$.each(charts, function(i, c) {
652
if(c.enabled === true) {
653
@@ -649,18 +658,6 @@ function prepareScreen(data) {
658
if(tmp === 'net' || tmp === 'disk')
659
c.category = tmp;
660
652
- if(c.category === 'cpu') {
653
- if(c.id.match(/^cpu\.cpu[0-9]+$/)) {
654
- c.family = 'Utilization';
655
- }
656
- else if(c.id.match(/^cpu\.cpu[0-9]+_interrupts$/)) {
657
- c.family = 'Interrupts';
658
- }
659
- else if(c.id.match(/^cpu\.cpu[0-9]+_softirqs$/)) {
660
- c.family = 'SoftIRQs';
661
- }
662
- }
663
-
661
switch(c.category) {
662
case 'system':
663
c.category_priority = 10;
@@ -672,6 +669,11 @@ function prepareScreen(data) {
669
c.category_priority = 20;
670
c.category_title = 'Quality Of Service';
671
c.glyphicon = "glyphicon-random";
672
+
673
+ // find the name of the interface from the tc family
674
+ if(typeof options.interfaces_registry[c.family] === 'undefined' || options.interfaces_registry[c.family] === c.family)
675
+ options.interfaces_registry[c.family] = c.name.split('.')[1].split('_')[0];
676
+
677
break;
678
679
case 'net':
@@ -714,6 +716,17 @@ function prepareScreen(data) {
716
c.category_priority = 90;
717
c.category_title = 'CPU Cores';
718
c.glyphicon = "glyphicon-dashboard";
719
+
720
+ if(c.id.match(/^cpu\.cpu[0-9]+$/)) {
721
+ c.family = 'Utilization';
722
+ }
723
+ else if(c.id.match(/^cpu\.cpu[0-9]+_interrupts$/)) {
724
+ c.family = 'Interrupts';
725
+ }
726
+ else if(c.id.match(/^cpu\.cpu[0-9]+_softirqs$/)) {
727
+ c.family = 'SoftIRQs';
728
+ }
729
+
730
break;
731
732
case 'disk':
@@ -828,16 +841,16 @@ function prepareScreen(data) {
841
$.each(options.categories, function(i, t) {
842
t.charts.sort(prioritySort);
843
831
- sidebar += '<li class="' + ((i === 0)?'active':'').toString() + '"><a href="#' + t.name + '">' + t.title + '</a>';
832
- html += '<div role="section"><div role="sectionhead"><h1 id="' + t.name + '" role="heading">' + t.title + '</h1>' + getMessage(t.name) + '</div><div id="' + t.name + '" role="document">';
844
+ sidebar += '<li class="' + ((i === 0)?'active':'').toString() + '"><a href="#' + name2id(t.name) + '">' + t.title + '</a>';
845
+ html += '<div role="section"><div role="sectionhead"><h1 id="' + name2id(t.name) + '" role="heading">' + t.title + '</h1>' + getMessage(t.name) + '</div><div id="' + name2id(t.name) + '" role="document">';
846
847
if(t.name === 'cpu') {
848
var families = uniq_with_list(t.charts, function(c) { return c.family; });
849
850
sidebar += '<ul class="nav">';
851
$.each(families, function(j, c) {
839
- sidebar += '<li class><a href="#' + t.name + '_' + c.name + '">' + c.name + '</a></li>';
840
- html += '<div class="netdata-group-container" id="family_' + t.name + '_' + c.name + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + t.name + '_' + c.name + '" class="netdata-chart-alignment" role="heading">' + c.name + '</h2>';
852
+ sidebar += '<li class><a href="#' + name2id(t.name) + '_' + name2id(c.name) + '">' + c.name + '</a></li>';
853
+ html += '<div class="netdata-group-container" id="family_' + name2id(t.name) + '_' + name2id(c.name) + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + name2id(t.name) + '_' + name2id(c.name) + '" class="netdata-chart-alignment" role="heading">' + c.name + '</h2>';
854
$.each(c.values, function(x, f) {
855
var c = null;
856
var h = options.chartsHeight;
@@ -859,8 +872,13 @@ function prepareScreen(data) {
872
873
sidebar += '<ul class="nav">';
874
$.each(interfaces, function(j, c) {
862
- sidebar += '<li class><a href="#' + t.name + '_' + c.name + '">' + c.name + '</a></li>';
863
- html += '<div class="netdata-group-container" id="interface_' + t.name + '_' + c.name + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + t.name + '_' + c.name + '" class="netdata-chart-alignment" role="heading">' + c.name + '</h2>';
875
+ var menuitem = c.name;
876
+ var name = options.interfaces_registry[menuitem];
877
+ if(typeof name !== 'undefined' && name !== menuitem)
878
+ menuitem = menuitem + ' (' + name + ')';
879
+
880
+ sidebar += '<li class><a href="#' + name2id(t.name) + '_' + name2id(c.name) + '">' + menuitem + '</a></li>';
881
+ html += '<div class="netdata-group-container" id="interface_' + name2id(t.name) + '_' + name2id(c.name) + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + name2id(t.name) + '_' + name2id(c.name) + '" class="netdata-chart-alignment" role="heading">' + menuitem + '</h2>';
882
$.each(c.values, function(x, f) {
883
var c = null;
884
var h = options.chartsHeight / 2;
@@ -886,8 +904,8 @@ function prepareScreen(data) {
904
905
sidebar += '<ul class="nav">';
906
$.each(disks, function(j, c) {
889
- sidebar += '<li class><a href="#' + c.name + '">' + c.name + '</a></li>';
890
- html += '<div class="netdata-group-container" id="disk_' + c.name + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + c.name + '" class="netdata-chart-alignment" role="heading">' + c.name + '</h2>';
907
+ sidebar += '<li class><a href="#' + name2id(c.name) + '">' + c.name + '</a></li>';
908
+ html += '<div class="netdata-group-container" id="disk_' + name2id(c.name) + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + name2id(c.name) + '" class="netdata-chart-alignment" role="heading">' + c.name + '</h2>';
909
$.each(c.values, function(x, f) {
910
var c = null;
911
var h = options.chartsHeight / 2;