blob: f4385027044923562f88d5644572bb848424c983 [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#
santanude31cb2682021-12-21 20:19:01 +053015cd /opt/smo
santanude00f87672021-11-02 17:55:00 +053016touch monitor.log
17
18config_file="influxdb-connector/config/influxdb_connector.conf"
19
santanude31cb2682021-12-21 20:19:01 +053020sed -i -- "s/influxdb =/influxdb = $smo_influxdb_host:$smo_influxdb_port/g" \
santanude00f87672021-11-02 17:55:00 +053021 $config_file
santanude31cb2682021-12-21 20:19:01 +053022sed -i -- "s/kafka_server =/kafka_server = $smo_kafka_host:$smo_kafka_port/g" \
santanude00f87672021-11-02 17:55:00 +053023 $config_file
24
25echo; echo $config_file
26cat $config_file
27
santanude31cb2682021-12-21 20:19:01 +053028echo; echo "wait for InfluxDB API at $smo_influxdb_host:$smo_influxdb_port"
santanude00f87672021-11-02 17:55:00 +053029STARTTIME=$(date +%s)
30max_time=60
santanude31cb2682021-12-21 20:19:01 +053031while ! curl http://$smo_influxdb_host:$smo_influxdb_port/ping ;
santanude00f87672021-11-02 17:55:00 +053032 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."
santanude31cb2682021-12-21 20:19:01 +053042echo; echo "setup eventsdb in InfluxDB"
santanude00f87672021-11-02 17:55:00 +053043# TODO: check if pre-existing and skip
santanude31cb2682021-12-21 20:19:01 +053044curl -X POST http://$smo_influxdb_host:$smo_influxdb_port/query \
45 --data-urlencode "q=CREATE DATABASE eventsdb"
santanude00f87672021-11-02 17:55:00 +053046
santanude31cb2682021-12-21 20:19:01 +053047if [ "$loglevel" != "" ]; then
santanudeafcbd782022-02-24 20:39:42 +053048 if [ "$enable_assert" != "True" ]; then
49 python3 -O /opt/smo/influxdb-connector/code/influxdb_connector.py \
50 --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
51 --influxdb $smo_influxdb_host:$smo_influxdb_port \
52 --section default > /opt/smo/monitor.log 2>&1
53 else
54 python3 /opt/smo/influxdb-connector/code/influxdb_connector.py \
55 --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
56 --influxdb $smo_influxdb_host:$smo_influxdb_port \
57 --section default > /opt/smo/monitor.log 2>&1
58 fi
santanude00f87672021-11-02 17:55:00 +053059else
santanudeafcbd782022-02-24 20:39:42 +053060 if [ "$enable_assert" != "True" ]; then
61 python3 -O /opt/smo/influxdb-connector/code/influxdb_connector.py \
62 --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
63 --influxdb $smo_influxdb_host:$smo_influxdb_port \
64 --section default
65 else
66 python3 /opt/smo/influxdb-connector/code/influxdb_connector.py \
67 --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
68 --influxdb $smo_influxdb_host:$smo_influxdb_port \
69 --section default
70 fi
santanude00f87672021-11-02 17:55:00 +053071fi