Forum Discussion
I imported a script and did an external monitor check. I created an external monitor (https://devcentral.f5.com/s/articles/ltm-external-monitors-the-basics) with the variable PREFERRED_STATE=1 and a script. Here is the script:
-----
#!/bin/sh
# remove IPv6/IPv4 compatibility prefix (LTM passes addresses in IPv6 format)
# OID i3IcGenSwitchoverRole = 1.3.6.1.4.1.2793.2.1.5.0
# Preferred States Numbers
#1 = NotApplicable because the Server is not in a Primary/Backup configuration.
#2 = Primary
#3 = Backup
#4 = Failed
OID="1.3.6.1.4.1.2793.2.1.5.0"
NODE_IP=`echo ${1} | sed 's/::ffff://'`
NODE_PORT=${2}
PIDFILE="/var/run/`basename ${0}`.${IP}_${PORT}.pid"
# kill of the last instance of this monitor if hung and log current pid
if [ -f $PIDFILE ]
then
echo "exceeded runtime needed to kill ${IP}:${PORT}" | logger -p local0.error
kill -9 `cat $PIDFILE` > /dev/null 2>&1
fi
status=$(snmpwalk -v 2c -c Genesys $NODE_IP $OID| awk '{print $4}')
if [ $status = $PREFERRED_STATE ]; then
echo $status
fi
rm -f $PIDFILE
exit