]> arthur.barton.de Git - netdata.git/commitdiff
calculates refresh time for pages with more than 4 charts
authorbox@home root <costa@tsaousis.gr>
Tue, 18 Jun 2013 23:23:08 +0000 (02:23 +0300)
committerbox@home root <costa@tsaousis.gr>
Tue, 18 Jun 2013 23:23:08 +0000 (02:23 +0300)
netdata.start

index 1f4a5c732243dbfe332f28eb9fecb1c1b3b101a7..556f4e446b662935e6d177224ba9d273839eec79 100755 (executable)
@@ -95,23 +95,37 @@ cat >all.html <<EOF
 EOF
 
 all=`ls "${data}" | grep .json$ | sed "s/\.json$//g"`
+count=0
 for x in $all
 do
+       count=$[count + 1]
        cat >>all.html <<EOF2
                drawChart('${x}', '${x}_div', width, height, "data/${x}.json", "Live Network Usage for ${x}");
 EOF2
 done
 
+ref=4
+tim=1000
+if [ $count -gt 4 ]
+then
+       ref=1
+       tim=$[1000 / count]
+       if [ $tim -lt 100 ]
+       then
+               tim=100
+       fi
+fi
+
 cat >>all.html <<EOF3
        }
        
         function myChartsRefresh() {
                // refresh up to 4 charts per second
-                refreshCharts(4);
+                refreshCharts($ref);
         }
 
         // EDIT: how often the charts are updated, in milliseconds
-        setInterval(myChartsRefresh, 1000);
+        setInterval(myChartsRefresh, $tim);
        </script>
 </head>