From be36973ccc4f99f63daec7af288c5d75e63d1be7 Mon Sep 17 00:00:00 2001 From: alarig Date: Mon, 4 Feb 2019 10:49:53 +0100 Subject: [PATCH] Handle bird error --- check_bird2_oneshot | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/check_bird2_oneshot b/check_bird2_oneshot index f303e39..105f1e6 100755 --- a/check_bird2_oneshot +++ b/check_bird2_oneshot @@ -92,8 +92,13 @@ DIR="$(mktemp -d '/tmp/nrpe-bird.XXXX')" # ${DIR}/bgp_protocols_up.txt # The sed removes the first two lines (BIRD 2.0.2 ready and Name Proto blah) -birdc 'show protocols all' | sed '1,2d;$d' | \ +birdc 'show protocols all' 2>${DIR}/bird-err | sed '1,2d;$d' | \ awk -v RS= -v DIR=$DIR '{print > (DIR "/" $1 ".txt")}' +if [ $? != 0 ]; then + printf "ERROR: $(cat ${DIR}/bird-err)\n" + rm -r ${DIR} + exit 2 +fi for protocol in $(cat ${CONF_IGNORE_FILE}); do rm "${DIR}/${protocol}.txt"