-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·145 lines (113 loc) · 5.71 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·145 lines (113 loc) · 5.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#! /bin/sh -e
#set -x
apk update
apk add curl
wupiaowt() {
# [w]ait [u]ntil [p]ort [i]s [a]ctually [o]pen [w]ith [t]imeout <who> <timeout> <target>
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo 'Invalid parameters'
exit 1
fi
if ! timeout -t $2 -s KILL /bin/sh -c "until curl -XGET -o /dev/null -sf 'http://$3'; do sleep 1s && echo '$1 waiting for $3 ...'; done"; then
echo "$0 timeout: $3 was unreachable"
exit 137
fi
}
wupiaowt "$0" 70 "grafana:3000"
#wupiaowt "$0" 70 "influxdb:8086"
STATUSCODE=$(curl -i -XPOST 'http://influxdb:8086/query?q=CREATE+DATABASE+%22telegraf%22&db=_internal' \
--write-out "%{http_code}" --output /dev/stderr)
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to create telegraf db in influxdb"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://influxdb:8086/query?q=CREATE+DATABASE+%22perfana_trends%22&db=_internal' \
--write-out "%{http_code}" --output /dev/stderr)
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to create perfana_trends db in influxdb"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/datasources' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary "{\"name\":\"Graphite\",\"type\":\"graphite\",\"url\":\"http://graphite\",\"access\":\"proxy\",\"jsonData\":{\"graphiteVersion\":\"1.0\"},\"secureJsonFields\":{}}")
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to initialise the graphite data source"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/datasources' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary "{\"name\":\"influxdb telegraf\",\"type\":\"influxdb\",\"access\":\"proxy\",\"url\":\"http://influxdb:8086\",\"password\":\"foobar\",\"user\":\"foobar\",\"database\":\"telegraf\",\"basicAuth\":false,\"isDefault\":true}")
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to initialise the influxdb telegraf data source"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/datasources' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary "{\"name\":\"influxdb perfana trends\",\"type\":\"influxdb\",\"access\":\"proxy\",\"url\":\"http://influxdb:8086\",\"password\":\"foobar\",\"user\":\"foobar\",\"database\":\"perfana_trends\",\"basicAuth\":false,\"isDefault\":true}")
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to initialise the influxdb perfana_trends data source"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/datasources' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary "{\"name\":\"influxdb gatling\",\"type\":\"influxdb\",\"access\":\"proxy\",\"url\":\"http://influxdb:8086\",\"password\":\"foobar\",\"user\":\"foobar\",\"database\":\"gatling\",\"basicAuth\":false,\"isDefault\":true}")
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to initialise the influxdb Gatling data source"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/datasources' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary "{\"name\":\"Prometheus\",\"type\":\"prometheus\",\"access\":\"proxy\",\"url\":\"http://prometheus:9090\",\"password\":\"foobar\",\"user\":\"foobar\",\"basicAuth\":false}")
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to initialise the prometheus data source"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/dashboards/import' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary @/gatling.json)
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to create the gatling dashboard"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/dashboards/import' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary @/system.json)
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to create the system dashboard"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/dashboards/import' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary @/prometheus-docker-dashboard.json)
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to create the prometheus dashboard"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/dashboards/import' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary @/graphite.json)
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to create the graphite dashboard"
exit 1
fi
STATUSCODE=$(curl -i -XPOST 'http://foobar:foobar@grafana:3000/api/dashboards/import' \
--write-out "%{http_code}" --output /dev/stderr \
--header 'Content-Type: application/json' \
--data-binary @/perfana_trends.json)
if [ $STATUSCODE -ne 200 ]; then
echo "Unable to create the Perfana trends dashboard"
exit 1
fi
while true; do
exec tail -s 6000000 -f /dev/null
sleep 1s
done