@cryptotaxi247 / netdata-1 / commits / 900632ce8

automatic installation

box@home root committed Jun 18, 2013 at 22:54 UTC 900632ce88a40fdfbfe9a513d8f8ae5cc466e82d
3 files changed +132
README.md
+17
@@ -25,6 +25,23 @@ Your browser will hit the web server to fetch the JSON data and refresh the grap
25
26 # Installation
27
28 +## Automatic installation
29 +
30 +1. Download everything in a directory inside your web server.
31 +2. cd to that directory
32 +3. run:
33 +
34 +```sh
35 +./netdata.start
36 +```
37 +
38 +For this to work, you need to have persmission to create a directory in /run.
39 +If you run into problems, try to become root to verify it works.
40 +
41 +---
42 +
43 +## Installation by hand
44 +
45 ### download everything in a directory inside your web docs.
46 You don't need apache. Any web server able to provide static files will do the job fine.
47
example.html renamed
netdata.start new
+115
@@ -0,0 +1,115 @@
1 +#!/bin/bash
2 +
3 +base="`dirname "$0"`"
4 +
5 +if [ ! -d "$base" -o ! -f "$base/netdata.c" ]
6 +then
7 + echo >&2 "Cannot find my home directory '${base}'."
8 + exit 1
9 +fi
10 +cd "$base" || exit 1
11 +
12 +echo "Creating a directory for netdata in /run"
13 +if [ ! -d /run/netdata ]
14 +then
15 + mkdir /run/netdata || exit 1
16 +fi
17 +
18 +echo "Stopping a (possibly) running netdata..."
19 +killall netdata 2>/dev/null
20 +
21 +echo "Compiling netdata"
22 +gcc -O3 -o netdata netdata.c || exit 1
23 +
24 +echo "Starting netdata"
25 +./netdata -d -u 1 -l 60 -o /run/netdata || exit 1
26 +
27 +echo "Waiting 2 seconds for the JSON files"
28 +# wait 2 seconds for the JSON files to be generated
29 +sleep 2
30 +
31 +if [ -h data ]
32 +then
33 + echo "Removing existing $base/data link"
34 + rm data || exit 1
35 +fi
36 +
37 +if [ ! -d data ]
38 +then
39 + echo "Linking /run/netdata to $base/data"
40 + ln -s /run/netdata data || exit 1
41 +else
42 + echo >&2 "Directory $base/data already exists. Not touching it, however it should be a link /run/netdata."
43 +fi
44 +
45 +echo "Generating all.html"
46 +cat >all.html <<EOF
47 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
48 +<html xmlns="http://www.w3.org/1999/xhtml">
49 +<style>
50 + * {font-family:Arial}
51 + div {float: left; margin: 0 0 0 0; }
52 +</style>
53 +<title>netdata</title>
54 +<head>
55 + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
56 +
57 + <!--Load the AJAX API-->
58 + <script type="text/javascript" src="https://www.google.com/jsapi"></script>
59 + <script type="text/javascript" src="jquery-1.10.1.min.js"></script>
60 + <script type="text/javascript" src="netdata.js"></script>
61 + <script type="text/javascript">
62 +
63 + // Set a callback to run when the Google Visualization API is loaded.
64 + google.setOnLoadCallback(drawCharts);
65 +
66 + function drawCharts() {
67 + var width = (window.innerWidth - 50) / 2;
68 + var height = 260;
69 +
70 + if(width < height) width = height; //>
71 +
72 + // EDIT: add one line per interface you have
73 + // EDIT:
74 + // EDIT: name div id json data graph title
75 + // EDIT: --------------------------------------------------------------------------------
76 +EOF
77 +
78 +all=`ls /tmp/interfaces/ | grep .json$ | sed "s/\.json$//g"`
79 +for x in $all
80 +do
81 + cat >>all.html <<EOF2
82 + drawChart('${x}', '${x}_div', width, height, "data/${x}.json", "Live Network Usage for ${x}");
83 +EOF2
84 +done
85 +
86 +cat >>all.html <<EOF3
87 + }
88 +
89 + // EDIT: how often the charts are updated, in milliseconds
90 + setInterval(drawCharts, 1000);
91 + </script>
92 +</head>
93 +
94 +<body>
95 + <!--
96 + EDIT: add one div per interface you have
97 + EDIT: use the same id above and bellow!
98 + -->
99 +EOF3
100 +
101 +for x in $all
102 +do
103 + cat >>all.html <<EOF4
104 + <div id="${x}_div"></div>
105 +EOF4
106 +done
107 +
108 +cat >>all.html <<EOF5
109 + </body>
110 +</html>
111 +EOF5
112 +
113 +echo "All Done."
114 +echo "Just hit all.html from your browser."
115 +