Forum Discussion

v2's avatar
v2
Icon for Nimbostratus rankNimbostratus
Feb 13, 2023

External monitor not working properly

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}"

 

 

 

  • 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?

  • Hello, sorry if I'm so late but I was looking for external monitor articles today and I bumped into this.

    From my experience, the most common error when scripting external monitors is to have some exceptions or some other string that populates the output file. 

    The easiest way for me to debug this, is to manually run the monitor instance.

    Every edit you make to the script in the "System > File Management > External Monitor Program File List" in the GUI is reflected in a file that's stored in /config/filestore/files_d/Common_d/external_monitor_d/ directory, which has the same name of your script and also append some "versioning" to it, ex. :Common:sample_monitor_VERSIONNUMBER 

    To run it manually you need to specify every parameter that you're passing in the script, the default is <server IP> <L4 port> <timeout> 
    example: 

    ./\:Common\:sample_monitor_123456_1 10.0.0.1 80 16 

     

    Doing so, you can easily see if there's syntax errors or anything when running the monitor, and what changes when you change the string. 
    You should expect NO OUTPUT when you want the script to mark an object down.