santanude | f22d9b5 | 2021-07-27 15:43:30 +0530 | [diff] [blame] | 1 | #!/bin/bash |
santanude | bc32a2a | 2021-09-24 17:47:31 +0530 | [diff] [blame] | 2 | # Original work Copyright 2017 AT&T Intellectual Property, Inc |
| 3 | # Modified work Copyright 2021 Xoriant Corporation |
santanude | f22d9b5 | 2021-07-27 15:43:30 +0530 | [diff] [blame] | 4 | # |
| 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 | |
santanude | c82167d | 2021-10-21 17:42:34 +0530 | [diff] [blame] | 19 | echo "Ves-agent is trying to connect Kafka Broker.." |
| 20 | timeout 1m bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$ves_kafka_host/$ves_kafka_port; do sleep 2; done' |
| 21 | success=$? |
| 22 | if [ $success -eq 0 ] |
| 23 | then |
| 24 | echo "Kafka is up.." |
| 25 | else |
| 26 | echo "No Kafka found .. exiting container.." |
| 27 | exit; |
| 28 | fi |
| 29 | |
| 30 | echo "Ves-agent is trying to connect ves-collector.." |
| 31 | timeout 1m bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$ves_host/$ves_port; do sleep 2; done' |
| 32 | success=$? |
| 33 | if [ $success -eq 0 ] |
| 34 | then |
| 35 | echo "ves-collector is up.." |
| 36 | else |
| 37 | echo "No ves-collector found .. exiting container.." |
| 38 | exit; |
| 39 | fi |
| 40 | |
santanude | f22d9b5 | 2021-07-27 15:43:30 +0530 | [diff] [blame] | 41 | echo "$ves_kafka_host $ves_kafka_hostname" >>/etc/hosts |
| 42 | echo "ves_kafka_hostname=$ves_kafka_hostname" |
| 43 | echo "*** /etc/hosts ***" |
| 44 | cat /etc/hosts |
| 45 | |
| 46 | cd /opt/ves/barometer/3rd_party/collectd-ves-app/ves_app |
| 47 | cat <<EOF >ves_app_config.conf |
| 48 | [config] |
| 49 | Domain = $ves_host |
| 50 | Port = $ves_port |
| 51 | Path = $ves_path |
| 52 | Topic = $ves_topic |
| 53 | UseHttps = $ves_https |
| 54 | Username = $ves_user |
| 55 | Password = $ves_pass |
| 56 | SendEventInterval = $ves_interval |
| 57 | ApiVersion = $ves_version |
| 58 | KafkaPort = $ves_kafka_port |
| 59 | KafkaBroker = $ves_kafka_host |
| 60 | EOF |
| 61 | |
| 62 | cat ves_app_config.conf |
| 63 | echo "ves_mode=$ves_mode" |
| 64 | |
| 65 | if [[ "$ves_loglevel" == "" ]]; then |
| 66 | ves_loglevel=ERROR |
| 67 | fi |
| 68 | |
santanude | bc32a2a | 2021-09-24 17:47:31 +0530 | [diff] [blame] | 69 | python3 ves_app.py --events-schema=$ves_mode.yaml --loglevel $ves_loglevel \ |
santanude | f22d9b5 | 2021-07-27 15:43:30 +0530 | [diff] [blame] | 70 | --config=ves_app_config.conf |
| 71 | |
| 72 | # Dump ves_app.log if the command above exits (fails) |
| 73 | echo "*** ves_app.log ***" |
| 74 | cat ves_app.log |