santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 1 | # 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 | # |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 15 | cd /opt/smo |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 16 | touch monitor.log |
| 17 | |
| 18 | config_file="influxdb-connector/config/influxdb_connector.conf" |
| 19 | |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 20 | sed -i -- "s/influxdb =/influxdb = $smo_influxdb_host:$smo_influxdb_port/g" \ |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 21 | $config_file |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 22 | sed -i -- "s/kafka_server =/kafka_server = $smo_kafka_host:$smo_kafka_port/g" \ |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 23 | $config_file |
| 24 | |
| 25 | echo; echo $config_file |
| 26 | cat $config_file |
| 27 | |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 28 | echo; echo "wait for InfluxDB API at $smo_influxdb_host:$smo_influxdb_port" |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 29 | STARTTIME=$(date +%s) |
| 30 | max_time=60 |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 31 | while ! curl http://$smo_influxdb_host:$smo_influxdb_port/ping ; |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 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." |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 42 | echo; echo "setup eventsdb in InfluxDB" |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 43 | # TODO: check if pre-existing and skip |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 44 | curl -X POST http://$smo_influxdb_host:$smo_influxdb_port/query \ |
| 45 | --data-urlencode "q=CREATE DATABASE eventsdb" |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 46 | |
santanude | 31cb268 | 2021-12-21 20:19:01 +0530 | [diff] [blame] | 47 | if [ "$loglevel" != "" ]; then |
santanude | afcbd78 | 2022-02-24 20:39:42 +0530 | [diff] [blame] | 48 | 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 |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 59 | else |
santanude | afcbd78 | 2022-02-24 20:39:42 +0530 | [diff] [blame] | 60 | 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 |
santanude | 00f8767 | 2021-11-02 17:55:00 +0530 | [diff] [blame] | 71 | fi |