]> arthur.barton.de Git - netdata.git/commitdiff
advertise the os type at the charts API call, to allow the dashboard provide OS speci...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Wed, 8 Feb 2017 19:35:56 +0000 (21:35 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Wed, 8 Feb 2017 19:35:56 +0000 (21:35 +0200)
src/common.c
src/common.h
src/main.h
src/rrd2json.c
src/web_buffer_svg.c
web/dashboard.js
web/dashboard_info.js
web/index.html

index 57bcaaab5d73f28c30552e08c237cc0ed8677996..92a7899471705933e4f61e0fe9a6fdc35740e52f 100644 (file)
@@ -12,6 +12,7 @@ char *global_host_prefix = "";
 int enable_ksm = 1;
 
 volatile sig_atomic_t netdata_exit = 0;
+const char *os_type = NETDATA_OS_TYPE;
 
 // ----------------------------------------------------------------------------
 // memory allocation functions that handle failures
index ea129550fa3c95afc96a18e2688722b237503f5e..a82ed3758290ccd9e244a3b98020f24884fd5aa3 100644 (file)
 
 #if defined(__FreeBSD__)
 #include "plugin_freebsd.h"
+#define NETDATA_OS_TYPE "freebsd"
 #elif defined(__APPLE__)
 #include "plugin_macos.h"
+#define NETDATA_OS_TYPE "macos"
 #else
 #include "plugin_proc.h"
 #include "plugin_proc_diskspace.h"
+#define NETDATA_OS_TYPE "linux"
 #endif /* __FreeBSD__, __APPLE__*/
 
 #include "plugin_tc.h"
@@ -271,6 +274,8 @@ extern pid_t get_system_pid_max(void);
 extern unsigned int hz;
 extern void get_system_HZ(void);
 
+extern volatile sig_atomic_t netdata_exit;
+extern const char *os_type;
 
 /* fix for alpine linux */
 #ifndef RUSAGE_THREAD
index 49afaef123e7ce6a6546bc763c78ab4f722f14d6..38df0fea44773d213915d7b1a91c83439ad2a9c6 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef NETDATA_MAIN_H
 #define NETDATA_MAIN_H 1
 
-extern volatile sig_atomic_t netdata_exit;
-
 /**
  * This struct contains information about command line options.
  */
index e079cdd79c5876784617f50b5b4f4699d653fdb0..904b606498efa556a85b1eaf1d7755f08621cf75 100644 (file)
@@ -85,10 +85,12 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
 
     buffer_sprintf(wb, "{\n"
            "\t\"hostname\": \"%s\""
+        ",\n\t\"os\": \"%s\""
         ",\n\t\"update_every\": %d"
         ",\n\t\"history\": %d"
         ",\n\t\"charts\": {"
         , localhost.hostname
+        , os_type
         , rrd_update_every
         , rrd_default_history_entries
         );
index 9537780d7a803cc9bd615dc0ac02ac11c093091c..2591799d4c6849a047a68525700b23d3156ea637 100644 (file)
@@ -391,7 +391,7 @@ static inline char *format_value_with_precision_and_unit(char *value_string, siz
         }
         else if(isgreaterequal(abs, 10))  len = snprintfz(value_string, value_string_len, "%0.1Lf", (long double) value);
         else if(isgreaterequal(abs, 1))   len = snprintfz(value_string, value_string_len, "%0.2Lf", (long double) value);
-        else if(isgreaterequal(abs, 0.1)) len = snprintfz(value_string, value_string_len, "%0.3Lf", (long double) value);
+        else if(isgreaterequal(abs, 0.1)) len = snprintfz(value_string, value_string_len, "%0.2Lf", (long double) value);
         else                              len = snprintfz(value_string, value_string_len, "%0.4Lf", (long double) value);
 
         if(unlikely(trim_zeros)) {
index 230f24486c0f767f9c1fbe625c243f259101caac..c134581959dc94cc762509d6444d0c2b15c2de0f 100644 (file)
@@ -2255,9 +2255,12 @@ var NETDATA = window.NETDATA || {};
             __legendFormatValueChartDecimalsLastMin = min;
             __legendFormatValueChartDecimalsLastMax = max;
 
-            if(this.value_decimal_detail !== -1) {
+            if(this.data !== null && this.data.min === this.data.max)
+                __legendFormatValueChartDecimals = -1;
+
+            else if(this.value_decimal_detail !== -1)
                 __legendFormatValueChartDecimals = this.value_decimal_detail;
-            }
+
             else {
                 var delta;
 
@@ -2269,7 +2272,7 @@ var NETDATA = window.NETDATA || {};
                 if (delta > 1000)     __legendFormatValueChartDecimals = 0;
                 else if (delta > 10)  __legendFormatValueChartDecimals = 1;
                 else if (delta > 1)   __legendFormatValueChartDecimals = 2;
-                else if (delta > 0.1) __legendFormatValueChartDecimals = 3;
+                else if (delta > 0.1) __legendFormatValueChartDecimals = 2;
                 else                  __legendFormatValueChartDecimals = 4;
             }
         };
@@ -2285,7 +2288,7 @@ var NETDATA = window.NETDATA || {};
                 if(abs > 1000)      dmax = 0;
                 else if(abs > 10 )  dmax = 1;
                 else if(abs > 1)    dmax = 2;
-                else if(abs > 0.1)  dmax = 3;
+                else if(abs > 0.1)  dmax = 2;
                 else                dmax = 4;
             }
             else {
@@ -4257,12 +4260,6 @@ var NETDATA = window.NETDATA || {};
             dygraph.updateOptions(options);
         }
 
-        // decide the decimal points on the legend of the chart
-        state.legendFormatValueDecimalsFromMinMax(
-            state.dygraph_instance.axes_[0].extremeRange[0],
-            state.dygraph_instance.axes_[0].extremeRange[1]
-        );
-
         state.dygraph_last_rendered = Date.now();
         return true;
     };
@@ -4865,12 +4862,6 @@ var NETDATA = window.NETDATA || {};
             state.__commonMax = null;
         }
 
-        // decide the decimal points on the legend of the chart
-        state.legendFormatValueDecimalsFromMinMax(
-            state.dygraph_instance.axes_[0].extremeRange[0],
-            state.dygraph_instance.axes_[0].extremeRange[1]
-        );
-
         return true;
     };
 
index 6885b6d443bbc8dc3f0a9f009189d4bf7085d9f8..24c260e8add6f8f028c6a1376d2d05196b37ced5 100644 (file)
@@ -287,12 +287,22 @@ netdataDashboard.submenu = {
 
     'system.softnet_stat': {
         title: 'softnet',
-        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>.'
+        info: function(os) {
+            if(os === 'linux')
+                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>.';
+            else
+                return 'Statistics for CPUs SoftIRQs related to network receive work.';
+        }
     },
 
     'cpu.softnet_stat': {
         title: 'softnet',
-        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>.'
+        info: function(os) {
+            if(os === 'linux')
+                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>.';
+            else
+                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>.';
+        }
     }
 };
 
@@ -308,7 +318,8 @@ netdataDashboard.submenu = {
 //
 netdataDashboard.context = {
     'system.cpu': {
-        info: function() {
+        info: function(os) {
+            void(os);
             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.'
                 + 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.')
                 + 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 = {
 
     'mem.ksm_ratios': {
         heads: [
-            function(id) {
+            function(os, id) {
+                void(os);
                 return  '<div data-netdata="' + id + '"'
                     + ' data-gauge-max-value="100"'
                     + ' data-chart-library="gauge"'
@@ -529,7 +541,9 @@ netdataDashboard.context = {
 
     'tc.qos': {
         heads: [
-            function(id) {
+            function(os, id) {
+                void(os);
+
                 if(id.match(/.*-ifb$/))
                     return netdataDashboard.gaugeChart('Inbound', '12%', '', '#5555AA');
                 else
@@ -693,7 +707,8 @@ netdataDashboard.context = {
 
     'apache.workers': {
         mainheads: [
-            function(id) {
+            function(os, id) {
+                void(os);
                 return  '<div data-netdata="' + id + '"'
                     + ' data-dimensions="busy"'
                     + ' data-append-options="percentage"'
@@ -765,7 +780,8 @@ netdataDashboard.context = {
     'retroshare.peers': {
         info: 'Number of (connected) RetroShare friends.',
         mainheads: [
-            function(id) {
+            function(os, id) {
+                void(os);
                 return  '<div data-netdata="' + id + '"'
                     + ' data-dimensions="peers_connected"'
                     + ' data-append-options="friends"'
index 6daed50666b11537759a748150dc14690317680e..c5e5ce92dd1c9d416247ab6c55179b8be70abaf9 100644 (file)
 
         var netdataDashboard = {
             sparklines_registry: {},
+            os: 'unknown',
 
             menu: {},
             submenu: {},
                     if(typeof(x) === 'undefined')
                         return def;
 
-                    if(typeof(x) === 'function')
-                        return x();
+                    if(typeof(x) === 'function') {
+                        return x(netdataDashboard.os);
+                    }
 
                     return x;
                 }
 
         // ----------------------------------------------------------------------------
 
-        function headMain(charts, duration) {
+        function headMain(os, charts, duration) {
+            void(os);
+
             var head = '';
 
             if(typeof charts['system.swap'] !== 'undefined')
                 var hi = 0, hlen = hcharts.length;
                 while(hi < hlen) {
                     if(typeof hcharts[hi] === 'function')
-                        head += hcharts[hi](chart.id).replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
+                        head += hcharts[hi](netdataDashboard.os, chart.id).replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
                     else
                         head += hcharts[hi].replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
                     hi++;
             var duration = Math.round(($(div).width() * pcent_width / 100 * data.update_every / 3) / 60) * 60;
             var html = '';
             var sidebar = '<ul class="nav dashboard-sidenav" data-spy="affix" id="sidebar_ul">';
-            var mainhead = headMain(data.charts, duration);
+            var mainhead = headMain(netdataDashboard.os, data.charts, duration);
 
             // sort the menus
             var main = sortObjectByPriority(menus);
                     if(data !== null) {
                         options.hostname = data.hostname;
                         options.data = data;
+                        netdataDashboard.os = data.os;
 
                         // update the dashboard hostname
                         document.getElementById('hostname').innerHTML = options.hostname;
             });
 
             NETDATA.requiredJs.push({
-                url: NETDATA.serverDefault + 'dashboard_info.js?v20170207-12',
+                url: NETDATA.serverDefault + 'dashboard_info.js?v20170208-6',
                 async: false,
                 isAlreadyLoaded: function() { return false; }
             });
     </div>
 </body>
 </html>
-<script type="text/javascript" src="dashboard.js?v20170205-39"></script>
+<script type="text/javascript" src="dashboard.js?v20170208-6"></script>