@cryptotaxi247 / netdata-1 / commits / d054d68ac

advertise the os type at the charts API call, to allow the dashboard provide OS specific information about charts.

Costa Tsaousis (ktsaou) committed Feb 8, 2017 at 21:35 UTC d054d68acfd1d6a24b6f4904cb3c97a656836dee
8 files changed +51 -33
src/common.c
+1
@@ -12,6 +12,7 @@ char *global_host_prefix = "";
12 int enable_ksm = 1;
13
14 volatile sig_atomic_t netdata_exit = 0;
15 +const char *os_type = NETDATA_OS_TYPE;
16
17 // ----------------------------------------------------------------------------
18 // memory allocation functions that handle failures
src/common.h
+5
@@ -189,11 +189,14 @@
189
190 #if defined(__FreeBSD__)
191 #include "plugin_freebsd.h"
192 +#define NETDATA_OS_TYPE "freebsd"
193 #elif defined(__APPLE__)
194 #include "plugin_macos.h"
195 +#define NETDATA_OS_TYPE "macos"
196 #else
197 #include "plugin_proc.h"
198 #include "plugin_proc_diskspace.h"
199 +#define NETDATA_OS_TYPE "linux"
200 #endif /* __FreeBSD__, __APPLE__*/
201
202 #include "plugin_tc.h"
@@ -271,6 +274,8 @@ extern pid_t get_system_pid_max(void);
274 extern unsigned int hz;
275 extern void get_system_HZ(void);
276
277 +extern volatile sig_atomic_t netdata_exit;
278 +extern const char *os_type;
279
280 /* fix for alpine linux */
281 #ifndef RUSAGE_THREAD
src/main.h
-2
@@ -1,8 +1,6 @@
1 #ifndef NETDATA_MAIN_H
2 #define NETDATA_MAIN_H 1
3
4 -extern volatile sig_atomic_t netdata_exit;
5 -
4 /**
5 * This struct contains information about command line options.
6 */
src/rrd2json.c
+2
@@ -85,10 +85,12 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
85
86 buffer_sprintf(wb, "{\n"
87 "\t\"hostname\": \"%s\""
88 + ",\n\t\"os\": \"%s\""
89 ",\n\t\"update_every\": %d"
90 ",\n\t\"history\": %d"
91 ",\n\t\"charts\": {"
92 , localhost.hostname
93 + , os_type
94 , rrd_update_every
95 , rrd_default_history_entries
96 );
src/web_buffer_svg.c
+1 -1
@@ -391,7 +391,7 @@ static inline char *format_value_with_precision_and_unit(char *value_string, siz
391 }
392 else if(isgreaterequal(abs, 10)) len = snprintfz(value_string, value_string_len, "%0.1Lf", (long double) value);
393 else if(isgreaterequal(abs, 1)) len = snprintfz(value_string, value_string_len, "%0.2Lf", (long double) value);
394 - else if(isgreaterequal(abs, 0.1)) len = snprintfz(value_string, value_string_len, "%0.3Lf", (long double) value);
394 + else if(isgreaterequal(abs, 0.1)) len = snprintfz(value_string, value_string_len, "%0.2Lf", (long double) value);
395 else len = snprintfz(value_string, value_string_len, "%0.4Lf", (long double) value);
396
397 if(unlikely(trim_zeros)) {
web/dashboard.js
+7 -16
@@ -2255,9 +2255,12 @@ var NETDATA = window.NETDATA || {};
2255 __legendFormatValueChartDecimalsLastMin = min;
2256 __legendFormatValueChartDecimalsLastMax = max;
2257
2258 - if(this.value_decimal_detail !== -1) {
2258 + if(this.data !== null && this.data.min === this.data.max)
2259 + __legendFormatValueChartDecimals = -1;
2260 +
2261 + else if(this.value_decimal_detail !== -1)
2262 __legendFormatValueChartDecimals = this.value_decimal_detail;
2260 - }
2263 +
2264 else {
2265 var delta;
2266
@@ -2269,7 +2272,7 @@ var NETDATA = window.NETDATA || {};
2272 if (delta > 1000) __legendFormatValueChartDecimals = 0;
2273 else if (delta > 10) __legendFormatValueChartDecimals = 1;
2274 else if (delta > 1) __legendFormatValueChartDecimals = 2;
2272 - else if (delta > 0.1) __legendFormatValueChartDecimals = 3;
2275 + else if (delta > 0.1) __legendFormatValueChartDecimals = 2;
2276 else __legendFormatValueChartDecimals = 4;
2277 }
2278 };
@@ -2285,7 +2288,7 @@ var NETDATA = window.NETDATA || {};
2288 if(abs > 1000) dmax = 0;
2289 else if(abs > 10 ) dmax = 1;
2290 else if(abs > 1) dmax = 2;
2288 - else if(abs > 0.1) dmax = 3;
2291 + else if(abs > 0.1) dmax = 2;
2292 else dmax = 4;
2293 }
2294 else {
@@ -4257,12 +4260,6 @@ var NETDATA = window.NETDATA || {};
4260 dygraph.updateOptions(options);
4261 }
4262
4260 - // decide the decimal points on the legend of the chart
4261 - state.legendFormatValueDecimalsFromMinMax(
4262 - state.dygraph_instance.axes_[0].extremeRange[0],
4263 - state.dygraph_instance.axes_[0].extremeRange[1]
4264 - );
4265 -
4263 state.dygraph_last_rendered = Date.now();
4264 return true;
4265 };
@@ -4865,12 +4862,6 @@ var NETDATA = window.NETDATA || {};
4862 state.__commonMax = null;
4863 }
4864
4868 - // decide the decimal points on the legend of the chart
4869 - state.legendFormatValueDecimalsFromMinMax(
4870 - state.dygraph_instance.axes_[0].extremeRange[0],
4871 - state.dygraph_instance.axes_[0].extremeRange[1]
4872 - );
4873 -
4865 return true;
4866 };
4867
web/dashboard_info.js
+23 -7
@@ -287,12 +287,22 @@ netdataDashboard.submenu = {
287
288 'system.softnet_stat': {
289 title: 'softnet',
290 - info: 'Statistics for CPUs SoftIRQs related to network receive work. Break down per CPU core can be found at <a href="#menu_cpu_submenu_softnet_stat">CPU / softnet statistics</a>. <b>processed</b> states the number of packets processed, <b>dropped</b> is the number packets dropped because the network device backlog was full (to fix them use <code>sysctl</code> to increase <code>net.core.netdev_max_backlog</code>), <b>squeezed</b> is the number of packets dropped because the network device budget ran out (to fix them use <code>sysctl</code> to increase <code>net.core.netdev_budget</code>). More information about identifying and troubleshooting network driver related issues can be found at <a href="https://access.redhat.com/sites/default/files/attachments/20150325_network_performance_tuning.pdf" target="_blank">Red Hat Enterprise Linux Network Performance Tuning Guide</a>.'
290 + info: function(os) {
291 + if(os === 'linux')
292 + return 'Statistics for CPUs SoftIRQs related to network receive work. Break down per CPU core can be found at <a href="#menu_cpu_submenu_softnet_stat">CPU / softnet statistics</a>. <b>processed</b> states the number of packets processed, <b>dropped</b> is the number packets dropped because the network device backlog was full (to fix them on Linux use <code>sysctl</code> to increase <code>net.core.netdev_max_backlog</code>), <b>squeezed</b> is the number of packets dropped because the network device budget ran out (to fix them on Linux use <code>sysctl</code> to increase <code>net.core.netdev_budget</code>). More information about identifying and troubleshooting network driver related issues can be found at <a href="https://access.redhat.com/sites/default/files/attachments/20150325_network_performance_tuning.pdf" target="_blank">Red Hat Enterprise Linux Network Performance Tuning Guide</a>.';
293 + else
294 + return 'Statistics for CPUs SoftIRQs related to network receive work.';
295 + }
296 },
297
298 'cpu.softnet_stat': {
299 title: 'softnet',
295 - info: 'Statistics for per CPUs core SoftIRQs related to network receive work. Total for all CPU cores can be found at <a href="#menu_system_submenu_softnet_stat">System / softnet statistics</a>. <b>processed</b> states the number of packets processed, <b>dropped</b> is the number packets dropped because the network device backlog was full (to fix them use <code>sysctl</code> to increase <code>net.core.netdev_max_backlog</code>), <b>squeezed</b> is the number of packets dropped because the network device budget ran out (to fix them use <code>sysctl</code> to increase <code>net.core.netdev_budget</code>). More information about identifying and troubleshooting network driver related issues can be found at <a href="https://access.redhat.com/sites/default/files/attachments/20150325_network_performance_tuning.pdf" target="_blank">Red Hat Enterprise Linux Network Performance Tuning Guide</a>.'
300 + info: function(os) {
301 + if(os === 'linux')
302 + return 'Statistics for per CPUs core SoftIRQs related to network receive work. Total for all CPU cores can be found at <a href="#menu_system_submenu_softnet_stat">System / softnet statistics</a>. <b>processed</b> states the number of packets processed, <b>dropped</b> is the number packets dropped because the network device backlog was full (to fix them on Linux use <code>sysctl</code> to increase <code>net.core.netdev_max_backlog</code>), <b>squeezed</b> is the number of packets dropped because the network device budget ran out (to fix them on Linux use <code>sysctl</code> to increase <code>net.core.netdev_budget</code>). More information about identifying and troubleshooting network driver related issues can be found at <a href="https://access.redhat.com/sites/default/files/attachments/20150325_network_performance_tuning.pdf" target="_blank">Red Hat Enterprise Linux Network Performance Tuning Guide</a>.';
303 + else
304 + return 'Statistics for per CPUs core SoftIRQs related to network receive work. Total for all CPU cores can be found at <a href="#menu_system_submenu_softnet_stat">System / softnet statistics</a>.';
305 + }
306 }
307 };
308
@@ -308,7 +318,8 @@ netdataDashboard.submenu = {
318 //
319 netdataDashboard.context = {
320 'system.cpu': {
311 - info: function() {
321 + info: function(os) {
322 + void(os);
323 return 'Total CPU utilization (all cores). 100% here means there is no CPU idle time at all. You can get per core usage at the <a href="#menu_cpu">CPUs</a> section and per application usage at the <a href="#menu_apps">Applications Monitoring</a> section.'
324 + netdataDashboard.sparkline('<br/>Keep an eye on <b>iowait</b> ', 'system.cpu', 'iowait', '%', '. If it is constantly high, your disks are a bottleneck and they slow your system down.')
325 + netdataDashboard.sparkline('<br/>An important metric worth monitoring, is <b>softirq</b> ', 'system.cpu', 'softirq', '%', '. A constantly high percentage of softirq may indicate network driver issues.');
@@ -400,7 +411,8 @@ netdataDashboard.context = {
411
412 'mem.ksm_ratios': {
413 heads: [
403 - function(id) {
414 + function(os, id) {
415 + void(os);
416 return '<div data-netdata="' + id + '"'
417 + ' data-gauge-max-value="100"'
418 + ' data-chart-library="gauge"'
@@ -529,7 +541,9 @@ netdataDashboard.context = {
541
542 'tc.qos': {
543 heads: [
532 - function(id) {
544 + function(os, id) {
545 + void(os);
546 +
547 if(id.match(/.*-ifb$/))
548 return netdataDashboard.gaugeChart('Inbound', '12%', '', '#5555AA');
549 else
@@ -693,7 +707,8 @@ netdataDashboard.context = {
707
708 'apache.workers': {
709 mainheads: [
696 - function(id) {
710 + function(os, id) {
711 + void(os);
712 return '<div data-netdata="' + id + '"'
713 + ' data-dimensions="busy"'
714 + ' data-append-options="percentage"'
@@ -765,7 +780,8 @@ netdataDashboard.context = {
780 'retroshare.peers': {
781 info: 'Number of (connected) RetroShare friends.',
782 mainheads: [
768 - function(id) {
783 + function(os, id) {
784 + void(os);
785 return '<div data-netdata="' + id + '"'
786 + ' data-dimensions="peers_connected"'
787 + ' data-append-options="friends"'
web/index.html
+12 -7
@@ -941,6 +941,7 @@
941
942 var netdataDashboard = {
943 sparklines_registry: {},
944 + os: 'unknown',
945
946 menu: {},
947 submenu: {},
@@ -1003,8 +1004,9 @@
1004 if(typeof(x) === 'undefined')
1005 return def;
1006
1006 - if(typeof(x) === 'function')
1007 - return x();
1007 + if(typeof(x) === 'function') {
1008 + return x(netdataDashboard.os);
1009 + }
1010
1011 return x;
1012 }
@@ -1168,7 +1170,9 @@
1170
1171 // ----------------------------------------------------------------------------
1172
1171 - function headMain(charts, duration) {
1173 + function headMain(os, charts, duration) {
1174 + void(os);
1175 +
1176 var head = '';
1177
1178 if(typeof charts['system.swap'] !== 'undefined')
@@ -1289,7 +1293,7 @@
1293 var hi = 0, hlen = hcharts.length;
1294 while(hi < hlen) {
1295 if(typeof hcharts[hi] === 'function')
1292 - head += hcharts[hi](chart.id).replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
1296 + head += hcharts[hi](netdataDashboard.os, chart.id).replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
1297 else
1298 head += hcharts[hi].replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
1299 hi++;
@@ -1306,7 +1310,7 @@
1310 var duration = Math.round(($(div).width() * pcent_width / 100 * data.update_every / 3) / 60) * 60;
1311 var html = '';
1312 var sidebar = '<ul class="nav dashboard-sidenav" data-spy="affix" id="sidebar_ul">';
1309 - var mainhead = headMain(data.charts, duration);
1313 + var mainhead = headMain(netdataDashboard.os, data.charts, duration);
1314
1315 // sort the menus
1316 var main = sortObjectByPriority(menus);
@@ -2203,6 +2207,7 @@
2207 if(data !== null) {
2208 options.hostname = data.hostname;
2209 options.data = data;
2210 + netdataDashboard.os = data.os;
2211
2212 // update the dashboard hostname
2213 document.getElementById('hostname').innerHTML = options.hostname;
@@ -2750,7 +2755,7 @@
2755 });
2756
2757 NETDATA.requiredJs.push({
2753 - url: NETDATA.serverDefault + 'dashboard_info.js?v20170207-12',
2758 + url: NETDATA.serverDefault + 'dashboard_info.js?v20170208-6',
2759 async: false,
2760 isAlreadyLoaded: function() { return false; }
2761 });
@@ -3377,4 +3382,4 @@
3382 </div>
3383 </body>
3384 </html>
3380 -<script type="text/javascript" src="dashboard.js?v20170205-39"></script>
3385 +<script type="text/javascript" src="dashboard.js?v20170208-6"></script>