Implement a version of the O1/VES interface for SMO
[smo/ves.git] / collector / ves-start.sh
1 #!/bin/bash
2
3 # Script to run the ves project and its dependent containers 
4 # Maintainer shrinivas.joshi@xoriant.com 
5
6 #List of containers for this project
7
8 #collector -- Read the event received from ves-agent and write it to
9 #             influxdb
10 #grafana -- Read the events written by ves-collector in influxdb and
11 #           show the graphs on UI
12 #influxdb -- Store the events in DB sent by ves-agent
13
14 #Port allotment on host system for the micro services running in docker.
15
16 #Stop all containers if those are running accedently.
17
18 ./ves-stop.sh
19
20 influx_port=3330
21 grafana_port=8880
22 vel_ves_port=9999
23
24 #Check Docker, collectd and git is installed on the VM
25
26 #get local ip address of VM from first interface
27
28
29 local_ip=`/sbin/ip -o -4 addr list | grep enp | head -n 1 | awk '{print $4}' | cut -d/ -f1`
30 echo -e "Binding VES Services to local ip address $local_ip \n "
31 echo ""
32 echo -e "--------------------------------------------------------------------\n"
33 #Spin influx DB
34 echo -e "Starting influxdb container on Local Port Number $influx_port. Please wait..\n"
35 docker run -d -p $influx_port:8086 -v $PWD/influxdb influxdb
36 if [ $? != 0 ]
37 then
38     exit 1
39 fi
40
41 sleep 5 #Give some time to spin the container and bring service up
42 echo "Done."
43 echo""
44 echo -e "--------------------------------------------------------------------\n"
45 #Spin Grafana Cotainer
46 echo -e "Starting Grafana cotainer on Local port number $grafana_port. Please wait..\n"
47 docker run -d -p $grafana_port:3000 grafana/grafana
48 if [ $? != 0 ]
49 then
50     exit 1
51 fi
52 sleep 5 #Give some time to spin the container and bring service up
53 echo "Done."
54 echo ""
55 echo -e "--------------------------------------------------------------------\n"
56 echo ""
57 echo -e "--------------------------------------------------------------------\n"
58 #Spin collector container.
59 echo -e "Starting ves collector container on Local port number $vel_ves_port. Please wait\n"
60 docker run -d -e ves_influxdb_host=$local_ip \
61        -e ves_influxdb_port=$influx_port -e ves_grafana_host=$local_ip \
62        -e ves_grafana_port=$grafana_port -e ves_host=$local_ip \
63        -e ves_port=$vel_ves_port -e ves_grafana_auth='admin:admin' \
64        -e ves_user='user' -e ves_pass='password' -e ves_path=''\
65        -e ves_topic='events' -e ves_loglevel='DEBUG' \
66        -p $vel_ves_port:$vel_ves_port ves-collector
67 if [ $? != 0 ]
68 then
69     exit 1
70 fi
71 sleep 6
72 echo "Done."
73 echo ""
74 echo""
75 echo -e "ves stack summary\n"
76
77 echo -e "===================================================================================================================\n"
78 echo ""
79 echo -e "ves collector listner port: $vel_ves_port \n"
80 echo -e "Grafana port: $grafana_port \n"
81 echo -e "To access grafana dashboard paste url  http://$local_ip:$grafana_port in web browser. "
82 echo -e "Grafana username/password is admin/admin *** DO NOT CHANGE THE ADMIN PASSWORD, CLICK SKIP OPTION ***\n"
83 echo ""
84 echo -e "===================================================================================================================\n"