Hello everyone, I want to create a new external health check. This is an application for sending XML messages by TCP. It is similar to the client sending 011101<?xml version=“1.0” encoding=“UTF-8”><abc>XXX<abc><MsgID>0001<MsgID>. When the success is received, the application is considered normal. When MsgID is a fixed value, it has been tested successfully. Now we want to add 1 to MsgID every time, from 0001 to 9999. Excuse me, how can this be achieved?
Hi,
Have you tried to use istats to store the counter?
This is the only way I can see now.
e.g.
#!/bin/sh
#
# these arguments supplied automatically for all external pingers:
# $1 = IP (::ffff:nnn.nnn.nnn.nnn notation or hostname)
# $2 = port (decimal, host byte order)
# $3 and higher = additional arguments
#
# $MONITOR_NAME = name of the monitor
#
# In this sample script, $3 is the regular expression
#
# Name of the pidfile
pidfile="/var/run/$MONITOR_NAME.$1..$2.pid"
# Send signal to the process group to kill our former self and any children
# as external monitors are run with SIGHUP blocked
if [ -f $pidfile ]
then
kill -9 -`cat $pidfile` > /dev/null 2>&1
fi
echo "$$" > $pidfile
# Remove the IPv6/IPv4 compatibility prefix
node_ip=`echo $1 | sed 's/::ffff://'`
port=$2
# Define istats key to store values
# Each node has a unique counter
istats_key="ltm.monitor ${node_ip}_${port} counter msgID"
# Increase value on node counter
istats incr "$istats_key" 1
# Get the current counter value
value=`istats get "$istats_key"`
# Keeping value between 1 and 9999 (4 digits)
if [[ $value -eq 0 || $value -gt 9999 ]]; then
value=1
istats set "$istats_key" $value
fi
# Using the nc utility to get data from the server.
# Search the data received for the expected expression
echo '011101<?xml version="1.0" encoding="UTF-8"><abc>XXX</abc><MsgID>'$(printf "%04d" $value)'</MsgID>' | /usr/bin/nc $node_ip $port 2> /dev/null | grep -E -i $3 > /dev/null
status=$?
if [ $status -eq 0 ]
then
# Remove the pidfile before the script echoes anything to stdout and is killed by bigd
rm -f $pidfile
echo "up"
fi
# Remove the pidfile before the script ends
rm -f $pidfile
I hope it helps.
Thanks,i will try
if the member is ok,it will replay “000000”,How add this to my external monitor
Sorry, I just saw it today, you may misunderstand what I mean. F5 does not need to send the parameters of 000000 to the server. When f5 sends the probe, if the server receives the impact message of 000000 , that is, the server replies 000000 to F5, the server is considered normal.
Hi, it’s OK and I think I got it at first time.
The third and additional argument on script is related to the expected response.
So, the first and second are implicit args because BIG-IP will pass that IP address and port number.
Then, the third and last parameter should be the expected on the replies.
Note:
# $1 = IP (::ffff:nnn.nnn.nnn.nnn notation or hostname)
# $2 = port (decimal, host byte order)
# $3 and higher = additional arguments
# Using the nc utility to get data from the server.
# Search the data received for the expected expression
echo ‘011101<?xml version=“1.0” encoding=“UTF-8”><abc>XXX</abc><MsgID>’$(printf “%04d” $value)‘</MsgID>’ | /usr/bin/nc $node_ip $port 2> /dev/null | grep -E -i $3 > /dev/null
Regards.
