13-Feb-2023 07:25
Hello.
i have configured an external monitor that uses a bash script. the script connects to the pool members via telnet and sends a command, it then searches for a string in the output of the telnet command. when i test this monitor the results are always "UP" even when i change the matching string to something not in the output of the command. It is like it is not even checking for the matching string and just marks the pool members as online. Even pool members that are switched off are showing as online. What am i missing, see below the monitor configuration and the script used.
#!/bin/bash
IP=`echo $1 | sed 's/::ffff://'`
# Check if there is a prior instance of the monitor running
bn=`basename $0`
pidfile="/var/run/${bn%_*}.$IP.pid"
if [ -f $pidfile ]
then
kill -9 `cat $pidfile` > /dev/null 2>&1
fi
echo "$$" > $pidfile
#start the test
output=$({
echo open $IP "10013"
sleep 1
echo "ENQUIRY.SELECT,,KONDWANIMA/Kondwani@1234,%DATES,"
sleep 2
} | telnet 2>/dev/null)
n=1
while read -r line; do
echo "line #$((n++)): $line | grep TODAY/VERSION" # maybe add a grep here
done <<< "$output"
if [[ ${output} == *"TODAY/VERSION"* ]]; then
echo "UP"
fi
rm -f "${pidfile}"
13-Feb-2023 08:30
@v2 First, I found this document that might assist you with your external monitor.
https://community.f5.com/t5/technical-articles/ltm-external-monitors-the-basics/ta-p/277128
Second, do you have a specific reason why an external monitor has been used rather than the build in health monitors? I'm not familiar enough with your bash script or bash in general to know exactly what your script is searching for but maybe we can come up with a health monitor that will work with internal monitors if you can provide exactly what you are sending to the server and what you are expecting back as a valid response?