5 if [ ! -d "$base" -o ! -f "$base/netdata.c" ]
7 echo >&2 "Cannot find my home directory '${base}'."
12 # every how many seconds to show the graphs
13 NETDATA_CONFIG_UPDATE_EVERY=2
15 # the detail of the data that will be kept in netdata
16 NETDATA_CONFIG_INTERNAL_UPDATE_EVERY=1
18 # how many points should the graphs have
19 NETDATA_CONFIG_HISTORY_POINTS=120
21 # how many points should be kept in memory
22 NETDATA_CONFIG_HISTORY_DATA=3600
24 # every how many graph refreshes, the page should be reloaded
25 # this fixes a bug in the google graphs API which leaks memory
26 # when refreshes graphs
27 NETDATA_CONFIG_RELOAD_EVERY=500
29 if [ -f netdata.conf ]
34 # how many history lines to keep in netdata
35 NETDATA_HISTORY_LINES=$[NETDATA_CONFIG_UPDATE_EVERY * NETDATA_CONFIG_HISTORY_POINTS / NETDATA_CONFIG_INTERNAL_UPDATE_EVERY]
37 echo "Creating a directory for netdata..."
39 for x in /run/netdata /var/run/netdata /tmp/netdata
41 echo " Trying '${x}'..."
44 mkdir "${x}" 2>/dev/null
47 echo " OK. '${x}' works."
52 echo " OK. '${x}' works."
60 echo >&2 "Cannot find where to put netdata files."
66 echo "Removing existing $base/data link"
72 echo "Linking '${data}' to $base/data"
73 ln -s "${data}" data || exit 1
75 echo >&2 "Directory $base/data already exists. Not touching it, however it should be a link '${data}'."
78 cp "${base}/all.xsl" "${data}/"
79 cp "${base}/netdata.js" "${data}/"
80 cp "${base}/tc-all.sh" "${data}/"
81 chmod 700 "${data}/tc-all.sh"
83 echo "Finding proper parameters for dashboard..."
85 echo "Stopping a (possibly) running netdata..."
86 killall netdata 2>/dev/null
87 killall tc-all.sh 2>/dev/null
91 echo "Compiling netdata"
92 # gcc -Wall -O3 -o netdata netdata.c -lpthread || exit 1
93 gcc -Wall -ggdb -o netdata netdata.c -lpthread || exit 1
95 echo "Starting netdata"
99 $p/netdata -d -u $NETDATA_CONFIG_INTERNAL_UPDATE_EVERY -l $NETDATA_HISTORY_LINES || exit 1
105 all=`wget http://127.0.0.1:19999/list -O - 2>/dev/null`
109 y=`echo "$x" | tr ".-" "__"`
110 eval "t=\${NETDATA_PRIORITY_${y}}"
111 if [ ! "$t" = "IGNORE" ]
117 echo "We have $count graphs..."
119 echo "Generating ${data}/index.html"
121 cat >${data}/index.html <<EOF
122 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
123 <html xmlns="http://www.w3.org/1999/xhtml">
125 * {font-family:Arial}
126 div {float: left; margin: 0 0 0 0; }
128 <title>${host} netdata</title>
130 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
132 <!--Load the AJAX API-->
133 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
134 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
135 <script type="text/javascript" src="/file/netdata.js"></script>
136 <script type="text/javascript">
138 // Set a callback to run when the Google Visualization API is loaded.
139 google.setOnLoadCallback(drawCharts);
141 function drawCharts() {
142 // EDIT: add one line per interface you have
144 // EDIT: name div id json data graph vertical axis title
145 // EDIT: --------------------------------------------------------------------------------------------------
150 y=`echo "$x" | tr ".-" "__"`
156 title="Network Usage for "
157 vtitle="bandwidth in kilobits/s"
161 title="Disk I/O for "
162 vtitle="I/O in kilobytes/s"
166 title="Class utilization for "
167 vtitle="bandwidth in kilobits/s"
172 eval "NETDATA_TITLE_${y}=\${NETDATA_TITLE_${y}:-${x}}"
173 eval "t=\${NETDATA_TITLE_${y}}"
175 eval "p=\${NETDATA_PRIORITY_${y}}"
176 if [ ! "$p" = "IGNORE" ]
178 cat >>${data}/index.html <<EOF2
179 addChart('${x}', '${y}_div', 0, 0, "data/${x}/${NETDATA_CONFIG_HISTORY_POINTS}/${NETDATA_CONFIG_UPDATE_EVERY}/average/", "${title}${t} (${x})", "${vtitle}");
184 cat >>${data}/index.html <<EOF3
185 refreshCharts(999999);
188 var refreshCount = 0;
189 function myChartsRefresh() {
191 if(refreshCount > $NETDATA_CONFIG_RELOAD_EVERY) location.reload();
193 // refresh up to 2 charts per second
197 setInterval(myChartsRefresh, 1000);
199 //window.onresize = function(event) {
200 // refreshCharts(999999);
208 EDIT: add one div per interface you have
209 EDIT: use the same id above and bellow!
213 tmp="/tmp/$RANDOM.netdata.$$.$RANDOM"
216 y=`echo "$x" | tr ".-" "__"`
217 eval "NETDATA_PRIORITY_${y}=\${NETDATA_PRIORITY_${y}:-${x}}"
218 eval "t=\${NETDATA_PRIORITY_${y}}"
219 if [ ! "$t" = "IGNORE" ]
225 for x in `cat "${tmp}" | sort`
227 n="`echo "$x" | cut -d '|' -f 2-`"
228 cat >>${data}/index.html <<EOF4
229 <div id="${n}_div"></div>
234 cat >>${data}/index.html <<EOF5
239 set|grep ^NETDATA_ >netdata.conf
241 if [ ! -h "${data}/data" ]
248 echo "Just hit http://127.0.0.1:19999/ from your browser."