Skip to content

Controlling ExaBGP : using a named PIPE

Thomas Mangin edited this page Dec 23, 2013 · 1 revision

Sebastien Gross on Google issue 28 shares with us ways to control ExaBGP using pipes with a little bit of shell scripting.

His helper program looks like :

/etc/exabgp/processes/checks

#!/bin/sh

FIFO="/var/run/exabgp/exabgp.cmd"
trap "rm -f $FIFO" SIGINT

mkfifo $FIFO
$(dirname $0)/checks-loop &
tail -f $FIFO

/etc/exabgp/processes/checks-loop

#!/bin/sh

while `true`; do
   # do some checks
   run-parts $(dirname $0)/checks.d > $FIFO
   sleep 5
done

and put that in exabgp.conf:

process service-dynamic {
   run /etc/exabgp/processes/checks;
}

Highjacking ExaBGP own PIPE

It is possible on Linux to recover the PIPE used by ExaBGP to communicate with its process. This trick assumes that only one process is running.

Obviously very hacky but may be useful in emergency cases.

echo "announce ...." > /proc/`cat /var/run/exabgp/exabgp.pid`/fd/$(lsof -p `cat /var/run/exabgp/exabgp.pid` |grep FIFO | sed -n 's/.*\([0-9]\+\)r.*/\1/p' | head -n1)