forked from prahaladramji/synology-prometheus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup
79 lines (68 loc) · 3.43 KB
/
setup
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
#!/usr/bin/env sh
# Global Variables
VERSION=$(curl -fsSL https://raw.githubusercontent.com/billykwooten/synology-prometheus/master/version | cat)
DOCKER_VOLUME="/volume1/docker"
PROMETHEUS_ROOT="${DOCKER_VOLUME}/prometheus"
GRAFANA_ROOT="${DOCKER_VOLUME}/grafana"
ALERTMANAGER_ROOT="${DOCKER_VOLUME}/alertmanager"
HOSTNAME=$(hostname -s)
# Throw Banner
echo "############################################################"
echo "# Synology Install Prometheus Stack Tool v${VERSION}"
echo "############################################################"
# Setup Prometheus File Structure
echo; echo ">>>>>> Setting up system File Structure"
prometheus_folders=( "configs" "data" )
for i in "${prometheus_folders[@]}"; do
[ ! -d ${PROMETHEUS_ROOT}/${i} ] && mkdir -p ${PROMETHEUS_ROOT}/${i} \
&& echo "folder created ${PROMETHEUS_ROOT}/${i}"
done
# Setup Grafana File Structure
grafana_folders=( "configs" "data" )
for i in "${grafana_folders[@]}"; do
[ ! -d ${GRAFANA_ROOT}/${i} ] && mkdir -p ${GRAFANA_ROOT}/${i} \
&& echo "folder created ${GRAFANA_ROOT}/${i}"
done
# Setup Alertmanager File Structure
alertmanager_folders=( "configs" "data" )
for i in "${alertmanager_folders[@]}"; do
[ ! -d ${ALERTMANAGER_ROOT}/${i} ] && mkdir -p ${ALERTMANAGER_ROOT}/${i} \
&& echo "folder created ${ALERTMANAGER_ROOT}/${i}"
done
# Set permissions on the data file structures
chown -R 65534:65534 ${PROMETHEUS_ROOT}/data #nobody userid
chown -R 65534:65534 ${ALERTMANAGER_ROOT}/data #nobody userid
chown -R 472:472 ${GRAFANA_ROOT}/data #grafana userid
# Download the default configs
curl -fsSL https://raw.githubusercontent.com/billykwooten/synology-prometheus/master/configs/prometheus.yml -o ${PROMETHEUS_ROOT}/configs/prometheus.yml
sed -i "s/\${HOSTNAME}/${HOSTNAME//\//\\/}/g" ${PROMETHEUS_ROOT}/configs/prometheus.yml
curl -fsSL https://raw.githubusercontent.com/billykwooten/synology-prometheus/master/configs/prometheus.rules -o ${PROMETHEUS_ROOT}/configs/prometheus.rules
curl -fsSL https://raw.githubusercontent.com/billykwooten/synology-prometheus/master/configs/alertmanager.yml -o ${ALERTMANAGER_ROOT}/configs/alertmanager.yml
curl -fsSL https://raw.githubusercontent.com/billykwooten/synology-prometheus/master/configs/grafana.ini -o ${GRAFANA_ROOT}/configs/grafana.ini
echo; echo ">>>>>> Creating docker-compose file"
# Run docker-compose to stand up containers
curl -fsSL https://raw.githubusercontent.com/billykwooten/synology-prometheus/master/docker-compose.yml \
| sed "s/\${PROMETHEUS_ROOT}/${PROMETHEUS_ROOT//\//\\/}/g" \
| sed "s/\${ALERTMANAGER_ROOT}/${ALERTMANAGER_ROOT//\//\\/}/g" \
| sed "s/\${HOSTNAME}/${HOSTNAME//\//\\/}/g" \
| sed "s/\${GRAFANA_ROOT}/${GRAFANA_ROOT//\//\\/}/g" > ${DOCKER_VOLUME}/docker-compose.yml
echo "docker-compose file created ${DOCKER_VOLUME}/docker-compose.yml"
echo; echo ">>>>>> Running docker-compose file"
docker-compose -f ${DOCKER_VOLUME}/docker-compose.yml up -d
if [[ $? -eq 0 ]]; then
echo; echo ">>>>>> Install successful, docker-compose successful"
elif [[ $? -ne 0 ]]; then
echo; echo ">>>>>> Error during docker-compose, docker-compose exited with $?"
exit 1
fi
# Finish
echo ">>>>>> Program Information"
echo "
#############################################
Grafana http://`hostname`:3000
Prometheus http://`hostname`:9090
Alertmanager http://`hostname`:9093
Node-Exporter http://`hostname`:9100/metrics
Prometheus_reloader nil
#############################################
"