When first deploying the collector and kafka, it takes kafka a couple minutes to start. In some cases, the collector would proceed to startup without waiting for kafka. This resulted in the first few messages to be dropped, such as dropping the router init and peer up messages.
71 lines
1.8 KiB
Bash
Executable File
71 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# All-in-One run script
|
|
#
|
|
# Copyright (c) 2021 Cisco Systems, Inc. and Tim Evens. All rights reserved.
|
|
#
|
|
# Author: Tim Evens <tim@openbmp.org>
|
|
#
|
|
ADMIN_ID=${ADMIN_ID:="collector"}
|
|
|
|
DOCKER_HOST_IP=$(ip route | grep default | head -1 | awk '{ print $3}')
|
|
|
|
if [[ ${KAFKA_FQDN:-""} == "" ]]; then
|
|
echo "ERROR: Missing ENV KAFKA_FQDN. Cannot proceed until you add that in docker run -e KAFKA_FQDN=<...>"
|
|
exit 1
|
|
else
|
|
if [[ ${KAFKA_FQDN} == "localhost" ]]; then
|
|
KAFKA_FQDN="docker-localhost"
|
|
|
|
elif [[ ${KAFKA_FQDN} == "127.0.0.1" ]]; then
|
|
KAFKA_FQDN="docker-localhost"
|
|
|
|
elif [[ ${KAFKA_FQDN} == "::1" ]]; then
|
|
KAFKA_FQDN="docker-localhost"
|
|
fi
|
|
fi
|
|
|
|
|
|
if [[ -f /config/openbmpd ]]; then
|
|
source /config/openbmpd
|
|
else
|
|
source /etc/default/openbmpd
|
|
fi
|
|
|
|
#
|
|
# System info
|
|
#
|
|
if [[ ${MEM:-""} = "" ]]; then
|
|
SYS_TOTAL_MEM=$(grep MemTotal /proc/meminfo | awk '{print int($2 / 1000)}')
|
|
else
|
|
SYS_TOTAL_MEM=$(($MEM * 1024))
|
|
fi
|
|
|
|
SYS_NUM_CPU=$(grep processor /proc/cpuinfo | wc -l)
|
|
|
|
# Update the hosts file
|
|
echo "$DOCKER_HOST_IP docker-localhost" >> /etc/hosts
|
|
|
|
# Update the etc hosts file
|
|
if [[ -f /config/hosts ]]; then
|
|
cat /config/hosts >> /etc/hosts
|
|
fi
|
|
|
|
|
|
# Update openbmpd config file
|
|
OPENBMP_CFG_FILE=/usr/etc/openbmp/openbmpd.conf
|
|
sed -r -i "s/admin_id:.*/admin_id: ${ADMIN_ID}/" /usr/etc/openbmp/openbmpd.conf
|
|
sed -r -i "s/localhost:9092/${KAFKA_FQDN}/" /usr/etc/openbmp/openbmpd.conf
|
|
|
|
if [[ -f /config/openbmpd.conf ]]; then
|
|
OPENBMP_CFG_FILE=/config/openbmpd.conf
|
|
fi
|
|
|
|
# Startup delay to allow for Kafka to start if not already running
|
|
ehco "Waiting 30 seconds to allow for Kafka and other containers to startup."
|
|
sleep 30
|
|
|
|
# Start openbmpd and wait - openbmpd runs in foreground
|
|
|
|
echo "Running openbmpd collector, see /var/log/openbmpd.log "
|
|
/usr/bin/openbmpd -f -l /var/log/openbmpd.log -c ${OPENBMP_CFG_FILE}
|