From 48a803e4393c4903333d53b685c1518092803a9c Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 4 May 2019 20:29:20 -0400 Subject: [PATCH] lookup hostname when in docker --- lgsm/functions/command_monitor.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 8df34c367..3b19a080e 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -33,8 +33,13 @@ for queryattempt in {1..5}; do fi querystatus="$?" elif [ "${querymethod}" == "tcp" ]; then - bash -c 'exec 3<> /dev/tcp/'${ip}'/'${queryport}'' - querystatus="$?" + if [ -f /.dockerenv ]; then + bash -c 'exec 3<> /dev/tcp/'$(hostname -i)'/'${queryport}'' + querystatus="$?" + else + bash -c 'exec 3<> /dev/tcp/'${ip}'/'${queryport}'' + querystatus="$?" + fi fi if [ "${querystatus}" == "0" ]; then