blob: 522b6a7653acc8a88447101e8280e3acfbc23bf9 [file] [log] [blame]
santanudef22d9b52021-07-27 15:43:30 +05301#!/bin/bash
santanudebc32a2a2021-09-24 17:47:31 +05302# Original work Copyright 2017 AT&T Intellectual Property, Inc
3# Modified work Copyright 2021 Xoriant Corporation
santanudef22d9b52021-07-27 15:43:30 +05304#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17#. What this is: Startup script for the OPNFV VES Agent running under docker.
18
santanudec82167d2021-10-21 17:42:34 +053019echo "Ves-agent is trying to connect Kafka Broker.."
20timeout 1m bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$ves_kafka_host/$ves_kafka_port; do sleep 2; done'
21success=$?
22if [ $success -eq 0 ]
23 then
24 echo "Kafka is up.."
25 else
26 echo "No Kafka found .. exiting container.."
27 exit;
28fi
29
30echo "Ves-agent is trying to connect ves-collector.."
31timeout 1m bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$ves_host/$ves_port; do sleep 2; done'
32success=$?
33if [ $success -eq 0 ]
34 then
35 echo "ves-collector is up.."
36 else
37 echo "No ves-collector found .. exiting container.."
38 exit;
39fi
40
santanudef22d9b52021-07-27 15:43:30 +053041echo "$ves_kafka_host $ves_kafka_hostname" >>/etc/hosts
42echo "ves_kafka_hostname=$ves_kafka_hostname"
43echo "*** /etc/hosts ***"
44cat /etc/hosts
45
46cd /opt/ves/barometer/3rd_party/collectd-ves-app/ves_app
47cat <<EOF >ves_app_config.conf
48[config]
49Domain = $ves_host
50Port = $ves_port
51Path = $ves_path
52Topic = $ves_topic
53UseHttps = $ves_https
54Username = $ves_user
55Password = $ves_pass
56SendEventInterval = $ves_interval
57ApiVersion = $ves_version
58KafkaPort = $ves_kafka_port
59KafkaBroker = $ves_kafka_host
60EOF
61
62cat ves_app_config.conf
63echo "ves_mode=$ves_mode"
64
65if [[ "$ves_loglevel" == "" ]]; then
66 ves_loglevel=ERROR
67fi
68
santanudebc32a2a2021-09-24 17:47:31 +053069python3 ves_app.py --events-schema=$ves_mode.yaml --loglevel $ves_loglevel \
santanudef22d9b52021-07-27 15:43:30 +053070 --config=ves_app_config.conf
71
72# Dump ves_app.log if the command above exits (fails)
73echo "*** ves_app.log ***"
74cat ves_app.log