calculates refresh time for pages with more than 4 charts
box@home root committed
Jun 19, 2013 at 02:23 UTC
de2ed0cda1ba05b7b08df1f8023319b26fa9a9bf
1 file changed
+16
-2
netdata.start
+16
-2
@@ -95,23 +95,37 @@ cat >all.html <<EOF
95
EOF
96
97
all=`ls "${data}" | grep .json$ | sed "s/\.json$//g"`
98
+count=0
99
for x in $all
100
do
101
+ count=$[count + 1]
102
cat >>all.html <<EOF2
103
drawChart('${x}', '${x}_div', width, height, "data/${x}.json", "Live Network Usage for ${x}");
104
EOF2
105
done
106
107
+ref=4
108
+tim=1000
109
+if [ $count -gt 4 ]
110
+then
111
+ ref=1
112
+ tim=$[1000 / count]
113
+ if [ $tim -lt 100 ]
114
+ then
115
+ tim=100
116
+ fi
117
+fi
118
+
119
cat >>all.html <<EOF3
120
}
121
122
function myChartsRefresh() {
123
// refresh up to 4 charts per second
110
- refreshCharts(4);
124
+ refreshCharts($ref);
125
}
126
127
// EDIT: how often the charts are updated, in milliseconds
114
- setInterval(myChartsRefresh, 1000);
128
+ setInterval(myChartsRefresh, $tim);
129
</script>
130
</head>
131