blob: 301d78576c6037e7c359e4b0a59ecc0e21c8415a [file] [log] [blame]
santanude00f87672021-11-02 17:55:00 +05301# Copyright 2021 Xoriant Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15cd /opt/ves
16touch monitor.log
17
18config_file="influxdb-connector/config/influxdb_connector.conf"
19
20sed -i -- "s/influxdb =/influxdb = $ves_influxdb_host:$ves_influxdb_port/g" \
21 $config_file
22sed -i -- "s/kafka_server =/kafka_server = $kafka_host_2:$kafka_port_2/g" \
23 $config_file
24
25echo; echo $config_file
26cat $config_file
27
28echo; echo "wait for InfluxDB API at $ves_influxdb_host:$ves_influxdb_port"
29STARTTIME=$(date +%s)
30max_time=60
31while ! curl http://$ves_influxdb_host:$ves_influxdb_port/ping ;
32 do
33 ELAPSED_TIME=$(($(date +%s) - $STARTTIME))
34 if [ $ELAPSED_TIME -ge $max_time ]; then
35 echo "InfluxDB API is not yet up after several attempts! Exiting from script."
36 exit 1
37 fi
38 echo "InfluxDB API is not yet responding... waiting 10 seconds"
39 sleep 10
40 done
41 echo "Done."
42echo; echo "setup veseventsdb in InfluxDB"
43# TODO: check if pre-existing and skip
44curl -X POST http://$ves_influxdb_host:$ves_influxdb_port/query \
45 --data-urlencode "q=CREATE DATABASE veseventsdb"
46
47if [ "$ves_loglevel" != "" ]; then
48 python3 /opt/ves/influxdb-connector/code/influxdb_connector.py \
49 --config /opt/ves/influxdb-connector/config/influxdb_connector.conf \
50 --influxdb $ves_influxdb_host:$ves_influxdb_port \
51 --section default > /opt/ves/monitor.log 2>&1
52else
53 python3 /opt/ves/influxdb-connector/code/influxdb_connector.py \
54 --config /opt/ves/influxdb-connector/config/influxdb_connector.conf \
55 --influxdb $ves_influxdb_host:$ves_influxdb_port \
56 --section default
57fi