0a450b7f1d8b6c833e4255e1c800d4e8df6cb464
[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 MONITOR_CONFIG="/home/opnfv/bottlenecks/monitor/config"
11 DISPATCH="/home/opnfv/bottlenecks/monitor/dispatch"
12
13 # INSTALL GRAFANA + PROMETHEUS + CADVISOR + BAROMETER on the JUMPERSERVER
14 # # Node-Exporter
15 echo == installation of monitoring module is started ==
16
17 # # Collectd
18 # # Configure IP Address in collectd server configuration
19 # python ${DISPATCH}/server_ip_configure.py ${MONITOR_CONFIG}/collectd_server.conf
20 # sudo docker run --name bottlenecks-collectd -d \
21 #   --privileged \
22 #   -v ${MONITOR_CONFIG}/collectd_server.conf:/etc/collectd/collectd.conf:ro \
23 #   -v /proc:/mnt/proc:ro \
24 #   fr3nd/collectd:5.5.0-1
25
26 set +e
27 # Prometheus
28 sudo docker run --name bottlenecks-prometheus \
29   -d -p 9090:9090 \
30   -v ${MONITOR_CONFIG}/prometheus.yaml:/etc/prometheus/prometheus.yml \
31   prom/prometheus:v1.7.1
32
33 # Collectd-Exporter
34 sudo docker run --name bottlenecks-collectd-exporter \
35   -d -p 9103:9103 -p 25826:25826/udp \
36   prom/collectd-exporter:0.3.1 \
37   -collectd.listen-address=":25826"
38
39 sudo docker run --name bottlenecks-node-exporter \
40   -d -p 9100:9100 \
41   -v "/proc:/host/proc:ro" \
42   -v "/sys:/host/sys:ro" \
43   -v "/:/rootfs:ro" \
44   --net="host" \
45   quay.io/prometheus/node-exporter:v0.14.0 \
46     -collector.procfs /host/proc \
47     -collector.sysfs /host/sys \
48     -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
49
50 # Openstack-Exporter
51 sudo docker run --name bottlenecks-openstack-exporter \
52   -v /tmp:/tmp \
53   -p 9104:9104 --env-file ${MONITOR_CONFIG}/openstack_exporter.conf \
54   -d gabrielyuyang/att-prometheus-openstack-exporter:latest
55
56 # Grafana
57 sudo  docker run --name bottlenecks-grafana \
58   -d -p 3000:3000 \
59   -v ${MONITOR_CONFIG}/grafana.ini:/etc/grafana/grafana.ini \
60   grafana/grafana:4.5.0
61 # Automate Prometheus Datasource and Grafana Dashboard creation
62
63 set -e
64 sleep 5
65 python ${DISPATCH}/../dashboard/automated_dashboard_datasource.py
66
67 set +e
68 # Cadvisor
69 sudo docker run \
70   --volume=/:/rootfs:ro \
71   --volume=/var/run:/var/run:rw \
72   --volume=/sys:/sys:ro \
73   --volume=/var/lib/docker/:/var/lib/docker:ro \
74   --volume=/dev/disk/:/dev/disk:ro \
75   --publish=8080:8080 \
76   --detach=true \
77   --name=bottlenecks-cadvisor \
78   google/cadvisor:v0.25.0
79
80
81 set -e
82 # Barometer
83 # Configure IP Address in barometer server configuration
84 sleep 5
85 python ${DISPATCH}/server_ip_configure.py ${MONITOR_CONFIG}/barometer_server.conf
86
87 set +e
88 # Install on jumpserver
89 docker pull opnfv/barometer
90 sudo docker run  --name bottlenecks-barometer -d --net=host \
91   -v ${MONITOR_CONFIG}/barometer_server.conf:/src/barometer/src/collectd/collectd/src/collectd.conf \
92   -v ${MONITOR_CONFIG}/barometer_server.conf:/opt/collectd/etc/collectd.conf \
93   -v /var/run:/var/run \
94   -v /tmp:/tmp \
95   --privileged opnfv/barometer /run_collectd.sh
96
97 set -e
98 # INSTALL BAROMETER + CADVISOR (+ COLLECTD) CLIENTS on COMPUTE/CONTROL NODES
99 # Configure IP Address in barometer client configuration
100 python ${DISPATCH}/client_ip_configure.py ${MONITOR_CONFIG}/barometer_client.conf
101
102
103 # Automate Barometer client installation
104 python ${DISPATCH}/automate_barometer_client.py
105
106 # # Configure IP Address in collectd client configuration
107 # python ${DISPATCH}/client_ip_configure.py ${MONITOR_CONFIG}/collectd_client.conf
108 # # Automate Collectd Client installation
109 # python ${DISPATCH}/automate_collectd_client.py
110
111 # Automate Cadvisor Client
112 python ${DISPATCH}/automate_cadvisor_client.py
113
114 echo == installation of monitoring module is finished ==