@cryptotaxi247 / netdata-1 / commits / 6a3b2e73c

adapted for new daemon

Costa Tsaousis (ktsaou) committed Mar 22, 2014 at 09:49 UTC 6a3b2e73cefdeaeb733c34fa368952171b19b3c6
1 file changed +30 -40
netdata.start
+30 -40
@@ -10,10 +10,13 @@ fi
10 cd "$base" || exit 1
11
12 # every how many seconds to update the JSON files
13 -NETDATA_CONFIG_UPDATE_EVERY=1
13 +NETDATA_CONFIG_UPDATE_EVERY=2
14
15 # how many points should the graphs have
16 -NETDATA_CONFIG_HISTORY_POINTS=60
16 +NETDATA_CONFIG_HISTORY_POINTS=120
17 +
18 +# how many points should be kept in memory
19 +NETDATA_CONFIG_HISTORY_DATA=3600
20
21 # every how many graph refreshes, the page should be reloaded
22 # this fixes a bug in the google graphs API which leaks memory
@@ -48,37 +51,10 @@ done
51
52 if [ -z "${data}" ]
53 then
51 - echo >&2 "Cannot find where to put JSON files."
54 + echo >&2 "Cannot find where to put netdata files."
55 exit 1
56 fi
57
55 -cat <<EOFHTACCESS >"${data}/.htaccess"
56 -
57 -ExpiresActive on
58 -ExpiresDefault A0
59 -ExpiresByType application/json A0
60 -
61 -Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
62 -Header set Pragma "no-cache"
63 -
64 -EOFHTACCESS
65 -
66 -echo "Stopping a (possibly) running netdata..."
67 -killall netdata 2>/dev/null
68 -
69 -sleep 1
70 -rm "${data}"/*.json
71 -
72 -echo "Compiling netdata"
73 -gcc -O3 -o netdata netdata.c || exit 1
74 -
75 -echo "Starting netdata"
76 -./netdata -d -u $NETDATA_CONFIG_UPDATE_EVERY -l $NETDATA_CONFIG_HISTORY_POINTS -o "${data}" || exit 1
77 -
78 -echo "Waiting 2 seconds for the JSON files"
79 -# wait 2 seconds for the JSON files to be generated
80 -sleep 2
81 -
58 if [ -h data ]
59 then
60 echo "Removing existing $base/data link"
@@ -95,12 +71,26 @@ fi
71
72 echo "Finding proper parameters for dashboard..."
73
74 +echo "Stopping a (possibly) running netdata..."
75 +killall netdata 2>/dev/null
76 +
77 +echo "Compiling netdata"
78 +gcc -Wall -O3 -o netdata netdata.c -lpthread || exit 1
79 +
80 +echo "Starting netdata"
81 +p=`pwd`
82 +cd data
83 +$p/netdata -d -u $NETDATA_CONFIG_UPDATE_EVERY -l $NETDATA_CONFIG_HISTORY_DATA || exit 1
84 +cd "$p"
85 +
86 +sleep 1
87 +
88 # count all JSON files
99 -all=`ls "${data}" | grep .json$ | sed "s/\.json$//g"`
89 +all=`wget http://127.0.0.1:19999/list -O - 2>/dev/null`
90 count=0
91 for x in $all
92 do
103 - y=`echo "$x" | tr "-" "_"`
93 + y=`echo "$x" | tr ".-" "__"`
94 eval "t=\${NETDATA_PRIORITY_${y}}"
95 if [ ! "$t" = "IGNORE" ]
96 then
@@ -177,7 +167,7 @@ EOF
167
168 for x in $all
169 do
180 - y=`echo "$x" | tr "-" "_"`
170 + y=`echo "$x" | tr ".-" "__"`
171 eval "NETDATA_TITLE_${y}=\${NETDATA_TITLE_${y}:-Live Network Usage for ${x}}"
172 eval "t=\${NETDATA_TITLE_${y}}"
173
@@ -185,7 +175,7 @@ do
175 if [ ! "$p" = "IGNORE" ]
176 then
177 cat >>${data}/index.html <<EOF2
188 - drawChart('${x}', '${x}_div', width, height, "data/${x}.json", "${t}");
178 + drawChart('${x}', '${y}_div', width, height, "data/${x}/${NETDATA_CONFIG_HISTORY_POINTS}", "${t}");
179 EOF2
180 fi
181 done
@@ -196,9 +186,9 @@ if [ $count -gt 4 ]
186 then
187 ref=1
188 tim=$[1000 * NETDATA_CONFIG_UPDATE_EVERY / count]
199 - if [ $tim -lt $[100 * NETDATA_CONFIG_UPDATE_EVERY] ]
189 + if [ $tim -lt $[333 * NETDATA_CONFIG_UPDATE_EVERY] ]
190 then
201 - tim=$[100 * NETDATA_CONFIG_UPDATE_EVERY]
191 + tim=$[333 * NETDATA_CONFIG_UPDATE_EVERY]
192 fi
193 fi
194
@@ -229,18 +219,18 @@ EOF3
219 tmp="/tmp/$RANDOM.netdata.$$.$RANDOM"
220 for x in $all
221 do
232 - y=`echo "$x" | tr "-" "_"`
222 + y=`echo "$x" | tr ".-" "__"`
223 eval "NETDATA_PRIORITY_${y}=\${NETDATA_PRIORITY_${y}:-${x}}"
224 eval "t=\${NETDATA_PRIORITY_${y}}"
225 if [ ! "$t" = "IGNORE" ]
226 then
237 - echo "${t}.${x}"
227 + echo "${t}|${y}"
228 fi
229 done >"${tmp}"
230
231 for x in `cat "${tmp}" | sort`
232 do
243 - n="`echo "$x" | cut -d '.' -f 2-`"
233 + n="`echo "$x" | cut -d '|' -f 2-`"
234 cat >>${data}/index.html <<EOF4
235 <div id="${n}_div"></div>
236 EOF4
@@ -261,5 +251,5 @@ then
251 fi
252
253 echo "All Done."
264 -echo "Just hit netdata/ from your browser."
254 +echo "Just hit http://127.0.0.1:19999/ from your browser."
255