From a54c730662343b70ab3611151638422327b2ed51 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 29 Jul 2024 01:04:55 -0400 Subject: [PATCH] Add retries to ipmitool output --- roles/base/files/usr/lib/check_mk_agent/plugins/ipmi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/base/files/usr/lib/check_mk_agent/plugins/ipmi b/roles/base/files/usr/lib/check_mk_agent/plugins/ipmi index e3cb85c..c1b8c4e 100755 --- a/roles/base/files/usr/lib/check_mk_agent/plugins/ipmi +++ b/roles/base/files/usr/lib/check_mk_agent/plugins/ipmi @@ -23,10 +23,16 @@ if [[ -z ${IPMIIP_INTERFACES} ]]; then fi # Grab IPMI IP from ipmitool -IPMIIP_IPMITOOL="$( ipmitool lan print 2>/dev/null | grep 'IP Address' | grep -v 'Source' | awk '{ print $NF }' )" +IPMIIP_IPMITOOL="" +COUNT=0 +while [[ -z ${IPMIIP_IPMITOOL} && ${COUNT} -lt 3 ]]; do + IPMIIP_IPMITOOL="$( ipmitool lan print 2>/dev/null | grep 'IP Address' | grep -v 'Source' | awk '{ print $NF }' )" + sleep 1 + COUNT=$(( ${COUNT} + 1 )) +done if [[ -z ${IPMIIP_IPMITOOL} ]]; then - echo "No IPMI IP returned by ipmitool" + echo "No IPMI IP returned by ipmitool in 3 tries" exit fi if [[ ${IPMIIP_INTERFACES} != ${IPMIIP_IPMITOOL} ]]; then