2 Copyright
2017-
2018 Jo-Philipp Wich
<jo@mein.io
>
3 Licensed to the public under the Apache License
2.0.
8 <link rel=
"stylesheet" href=
"<%=resource%>/view/nlbw.css" />
10 <script type=
"text/javascript" src=
"<%=resource%>/nlbw.chart.min.js"></script>
11 <script type=
"text/javascript" src=
"<%=resource%>/view/nlbw.js"></script>
13 <h2 name=
"content"><%:Netlink Bandwidth Monitor%
></h2>
16 <%:Select accounting period:%
>
17 <select id=
"nlbw.period" style=
"display:none"></select>
23 <div class=
"cbi-section" data-tab=
"traffic" data-tab-title=
"<%:Traffic Distribution%>">
26 <label><%:Traffic / Host%
></label>
27 <canvas id=
"traf-pie" width=
"200" height=
"200"></canvas>
31 <label><%:Connections / Host%
></label>
32 <canvas id=
"conn-pie" width=
"200" height=
"200"></canvas>
37 <li><%_
<big id=
"host-total">0</big> hosts%
></li>
38 <li><%_
<big id=
"rx-total">0</big> download%
></li>
39 <li><%_
<big id=
"tx-total">0</big> upload%
></li>
40 <li><%_
<big id=
"conn-total">0</big> connections%
></li>
44 <div class=
"table" id=
"host-data">
45 <div class=
"tr table-titles">
46 <div class=
"th left hostname"><%:Host%
></div>
47 <div class=
"th right"><%:MAC%
></div>
48 <div class=
"th right"><%:Connections%
></div>
49 <div class=
"th right"><%:Download (Bytes)%
></div>
50 <div class=
"th right"><%:Download (Packets)%
></div>
51 <div class=
"th right"><%:Upload (Bytes)%
></div>
52 <div class=
"th right"><%:Upload (Packets)%
></div>
54 <div class=
"tr placeholder">
56 <em class=
"spinning"><%:Collecting data...%
></em>
62 <div class=
"cbi-section" data-tab=
"layer7" data-tab-title=
"<%:Application Protocols%>">
65 <label><%:Download / Application%
></label>
66 <canvas id=
"layer7-rx-pie" width=
"200" height=
"200"></canvas>
70 <label><%:Upload / Application%
></label>
71 <canvas id=
"layer7-tx-pie" width=
"200" height=
"200"></canvas>
76 <li><%_
<big id=
"layer7-total">0</big> different application protocols%
></li>
77 <li><%_
<big id=
"layer7-most-rx">0</big> cause the most download%
></li>
78 <li><%_
<big id=
"layer7-most-tx">0</big> cause the most upload%
></li>
79 <li><%_
<big id=
"layer7-most-conn">0</big> cause the most connections%
></li>
83 <div class=
"table" id=
"layer7-data">
84 <div class=
"tr table-titles">
85 <div class=
"th left"><%:Application%
></div>
86 <div class=
"th right"><%:Connections%
></div>
87 <div class=
"th right"><%:Download (Bytes)%
></div>
88 <div class=
"th right"><%:Download (Packets)%
></div>
89 <div class=
"th right"><%:Upload (Bytes)%
></div>
90 <div class=
"th right"><%:Upload (Packets)%
></div>
92 <div class=
"tr placeholder">
94 <em class=
"spinning"><%:Collecting data...%
></em>
100 <div class=
"cbi-section" data-tab=
"ipv6" data-tab-title=
"<%:IPv6%>">
103 <label><%:IPv4 vs. IPv6%
></label>
104 <canvas id=
"ipv6-share-pie" width=
"200" height=
"200"></canvas>
108 <label><%:Dualstack enabled hosts%
></label>
109 <canvas id=
"ipv6-hosts-pie" width=
"200" height=
"200"></canvas>
114 <li><%_
<big id=
"ipv6-hosts">0%
</big> IPv6 support rate among hosts%
></li>
115 <li><%_
<big id=
"ipv6-share">0%
</big> of the total traffic is IPv6%
></li>
116 <li><%_
<big id=
"ipv6-rx">0B
</big> total IPv6 download%
></li>
117 <li><%_
<big id=
"ipv6-tx">0B
</big> total IPv6 upload%
></li>
121 <div class=
"table" id=
"ipv6-data">
122 <div class=
"tr table-titles">
123 <div class=
"th left"><%:Host%
></div>
124 <div class=
"th right"><%:MAC%
></div>
125 <div class=
"th double right hide-xs"><%:Family%
></div>
126 <div class=
"th double right"><%:Download (Bytes)%
></div>
127 <div class=
"th double right"><%:Download (Packets)%
></div>
128 <div class=
"th double right"><%:Upload (Bytes)%
></div>
129 <div class=
"th double right"><%:Upload (Packets)%
></div>
131 <div class=
"tr placeholder">
133 <em class=
"spinning"><%:Collecting data...%
></em>
139 <div class=
"cbi-section" data-tab=
"export" data-tab-title=
"<%:Export%>">
141 <li><a href=
"<%=url('admin/nlbw/data')%>?type=csv&group_by=mac&order_by=-rx,-tx"><%:CSV, grouped by MAC%
></a></li>
142 <li><a href=
"<%=url('admin/nlbw/data')%>?type=csv&group_by=ip&order_by=-rx,-tx"><%:CSV, grouped by IP%
></a></li>
143 <li><a href=
"<%=url('admin/nlbw/data')%>?type=csv&group_by=layer7&order_by=-rx,-tx"><%:CSV, grouped by protocol%
></a></li>
144 <li><a href=
"<%=url('admin/nlbw/data')%>?type=json"><%:JSON dump%
></a></li>
149 <script type=
"text/javascript">//<![CDATA[
150 var hostInfo = <%=luci.util.serialize_json(luci.sys.net.host_hints())%
>;
152 XHR.get(L.url('admin/nlbw/list'), null, function(xhr, res) {
154 if (res !== null && typeof(res) === 'object' && res.length
> 0) {
155 trafficPeriods = res;
159 xhr.open('GET', 'https://raw.githubusercontent.com/jow-/oui-database/master/oui.json', true);
160 xhr.onreadystatechange = function() {
161 if (xhr.readyState ===
4) {
162 try { res = JSON.parse(xhr.responseText); }
163 catch(e) { res = null; }
165 if (res !== null && typeof(res) === 'object' && (res.length %
3) ===
0)
174 document.addEventListener('tooltip-open', function(ev) {
175 renderHostDetail.call(ev.detail.target, ev.target);
178 if ('ontouchstart' in window) {
179 document.addEventListener('touchstart', function(ev) {
180 var tooltip = document.querySelector('.cbi-tooltip');
181 if (tooltip === ev.target || tooltip.contains(ev.target))