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 | # |
| 15 | cd /opt/ves |
| 16 | touch monitor.log |
| 17 | |
| 18 | config_file="influxdb-connector/config/influxdb_connector.conf" |
| 19 | |
| 20 | sed -i -- "s/influxdb =/influxdb = $ves_influxdb_host:$ves_influxdb_port/g" \ |
| 21 | $config_file |
| 22 | sed -i -- "s/kafka_server =/kafka_server = $kafka_host_2:$kafka_port_2/g" \ |
| 23 | $config_file |
| 24 | |
| 25 | echo; echo $config_file |
| 26 | cat $config_file |
| 27 | |
| 28 | echo; echo "wait for InfluxDB API at $ves_influxdb_host:$ves_influxdb_port" |
| 29 | STARTTIME=$(date +%s) |
| 30 | max_time=60 |
| 31 | while ! 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." |
| 42 | echo; echo "setup veseventsdb in InfluxDB" |
| 43 | # TODO: check if pre-existing and skip |
| 44 | curl -X POST http://$ves_influxdb_host:$ves_influxdb_port/query \ |
| 45 | --data-urlencode "q=CREATE DATABASE veseventsdb" |
| 46 | |
| 47 | if [ "$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 |
| 52 | else |
| 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 |
| 57 | fi |