Restructure monitoring scripts
[bottlenecks.git] / monitor / monitoring.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 Huawei Tech and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 set -e
11
12 MONITOR_CONFIG="/home/opnfv/bottlenecks/monitor/config"
13 DISPATCH="/home/opnfv/bottlenecks/monitor/dispatch"
14
15
16 # INSTALL GRAFANA + PROMETHEUS + CADVISOR + BAROMETER on the JUMPERSERVER
17 # # Node-Exporter
18 # sudo docker run --name bottlenecks-node-exporter \
19 #   -d -p 9100:9100 \
20 #   -v "/proc:/host/proc:ro" \
21 #   -v "/sys:/host/sys:ro" \
22 #   -v "/:/rootfs:ro" \
23 #   --net="host" \
24 #   quay.io/prometheus/node-exporter:v0.14.0 \
25 #     -collector.procfs /host/proc \
26 #     -collector.sysfs /host/sys \
27 #     -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
28
29 # # Collectd
30 # # Configure IP Address in collectd server configuration
31 # python ${DISPATCH}/server_ip_configure.py ${MONITOR_CONFIG}/collectd_server.conf
32 # sudo docker run --name bottlenecks-collectd -d \
33 #   --privileged \
34 #   -v ${MONITOR_CONFIG}/collectd_server.conf:/etc/collectd/collectd.conf:ro \
35 #   -v /proc:/mnt/proc:ro \
36 #   fr3nd/collectd:5.5.0-1
37
38 echo == installation of monitoring module is started ==
39
40 set +e
41 # Collectd-Exporter
42 sudo docker run --name bottlenecks-collectd-exporter \
43   -d -p 9103:9103 -p 25826:25826/udp \
44   prom/collectd-exporter:0.3.1 \
45   -collectd.listen-address=":25826"
46
47 # Prometheus
48 sudo docker run --name bottlenecks-prometheus \
49   -d -p 9090:9090 \
50   -v ${MONITOR_CONFIG}/prometheus.yaml:/etc/prometheus/prometheus.yml \
51   prom/prometheus:v1.7.1
52
53 # Grafana
54 sudo  docker run --name bottlenecks-grafana \
55   -d -p 3000:3000 \
56   -v ${MONITOR_CONFIG}/grafana.ini:/etc/grafana/grafana.ini \
57   grafana/grafana:4.5.0
58 # Automate Prometheus Datasource and Grafana Dashboard creation
59
60 set -e
61 python dashboard/automated_dashboard_datasource.py
62
63 set +e
64 # Cadvisor
65 sudo docker run \
66   --volume=/:/rootfs:ro \
67   --volume=/var/run:/var/run:rw \
68   --volume=/sys:/sys:ro \
69   --volume=/var/lib/docker/:/var/lib/docker:ro \
70   --volume=/dev/disk/:/dev/disk:ro \
71   --publish=8080:8080 \
72   --detach=true \
73   --name=bottlenecks-cadvisor \
74   google/cadvisor:v0.25.0
75
76 set -e
77 # Barometer
78 # Configure IP Address in barometer server configuration
79 sleep 10
80 python ${DISPATCH}/server_ip_configure.py ${MONITOR_CONFIG}/barometer_server.conf
81
82 set +e
83 # Install on jumpserver
84 docker pull opnfv/barometer
85 sudo docker run  --name bottlenecks-barometer -tid --net=host \
86   -v ${MONITOR_CONFIG}/barometer_server.conf:/src/barometer/src/collectd/collectd/src/collectd.conf \
87   -v ${MONITOR_CONFIG}/barometer_server.conf:/opt/collectd/etc/collectd.conf \
88   -v /var/run:/var/run \
89   -v /tmp:/tmp \
90   --privileged opnfv/barometer /run_collectd.sh
91
92
93 set -e
94 # INSTALL BAROMETER + CADVISOR (+ COLLECTD) CLIENTS on COMPUTE/CONTROL NODES
95 # Configure IP Address in barometer client configuration
96 python ${DISPATCH}/client_ip_configure.py ${MONITOR_CONFIG}/barometer_client.conf
97
98 # Automate Barometer client installation
99 python ${DISPATCH}/automate_barometer_client.py
100
101 # # Configure IP Address in collectd client configuration
102 # python ${DISPATCH}/client_ip_configure.py ${MONITOR_CONFIG}/collectd_client.conf
103 # # Automate Collectd Client installation
104 # python ${DISPATCH}/automate_collectd_client.py
105
106 # Automate Cadvisor Client
107 python ${DISPATCH}/automate_cadvisor_client.py
108
109 echo == installation of monitoring module is finished ==