]> arthur.barton.de Git - netdata.git/commitdiff
allow dashboards to retry fetching chart data on failures; fixes #1402
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 19 Dec 2016 22:20:17 +0000 (00:20 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 19 Dec 2016 22:20:17 +0000 (00:20 +0200)
web/dashboard.js
web/demosites.html
web/index.html

index a62b31d4aefd144e6c1e0ea8bf0ed418bfd637b6..0db567107ae01e9b2c239948fa6f68c5fa2c360d 100644 (file)
             async_on_scroll: false,                 // sync/async onscroll handler
             onscroll_worker_duration_threshold: 30, // time in ms, to consider slow the onscroll handler
 
+            retries_on_data_failures: 3, // how many retries to make if we can't fetch chart data from the server
+
             setOptionCallback: function() { ; }
         },
 
         // the chart library requested by the user
         this.library_name = self.data('chart-library') || NETDATA.chartDefaults.library;
 
+        // how many retries we have made to load chart data from the server
+        this.retries_on_data_failures = 0;
+
         // object - the chart library used
         this.library = null;
 
             })
             .done(function(data) {
                 that.xhr = undefined;
+                that.retries_on_data_failures = 0;
 
                 if(that.debug === true)
                     that.log('data received. updating chart.');
             .fail(function(msg) {
                 that.xhr = undefined;
 
-                if(msg.statusText !== 'abort')
-                    error('data download failed for url: ' + that.data_url);
+                if(msg.statusText !== 'abort') {
+                    that.retries_on_data_failures++;
+                    if(that.retries_on_data_failures > NETDATA.options.current.retries_on_data_failures) {
+                        // that.log('failed ' + that.retries_on_data_failures.toString() + ' times - giving up');
+                        that.retries_on_data_failures = 0;
+                        error('data download failed for url: ' + that.data_url);
+                    }
+                    else {
+                        that.tm.last_autorefreshed = Date.now();
+                        // that.log('failed ' + that.retries_on_data_failures.toString() + ' times, but I will retry');
+                    }
+                }
             })
             .always(function() {
                 that.xhr = undefined;
index 63a62d6966ef7b329d04857f32dd5cbb7ba5c457..e212e4cd0a4b62dd7947b843f7a22a749b784e51 100644 (file)
@@ -505,7 +505,7 @@ p {
     and that you have chown it to be owned by netdata:netdata
 -->
 <!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
-<script type="text/javascript" src="dashboard.js?v20161218-1"></script>
+<script type="text/javascript" src="dashboard.js?v20161219-1"></script>
 
 <script>
     // --- OPTIONS FOR THE CHARTS --
@@ -529,6 +529,9 @@ p {
     // since we have many servers and limited sockets,
     // abort ajax calls when we scroll
     NETDATA.options.current.abort_ajax_on_scroll = true;
+
+    // do not to give errors on netdata demo servers for 60 seconds
+    NETDATA.options.current.retries_on_data_failures = 60;
 </script>
 
 <style>
index 491b772ba48bd40c6bf20b783b68e97b00308988..64ca0aef8b1c105bfc113a7a5a9d1f44511777ca 100644 (file)
         });
 
         if(isdemo()) {
+            // do not to give errors on netdata demo servers for 60 seconds
+            NETDATA.options.current.retries_on_data_failures = 60;
+
             if(urlOptions.nowelcome !== true) {
                 setTimeout(function() {
                     $('#welcomeModal').modal();
     </div>
 </body>
 </html>
-<script type="text/javascript" src="dashboard.js?v20161218-5"></script>
+<script type="text/javascript" src="dashboard.js?v20161219-1"></script>