My intention is to write a monitor (HTTPS), so it search the string “OK” in the response, and then counts it, and if the count is equal or more than 4, then set the monitor as pass.
thanks for looking into this, actually on the webpage it displays the response in 2 lines as text, nothing special..and another thing would there be much difference because the url is HTTPS and not HTTP. Regards
!/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://'`
Using the nc utility to get data from the server.
Search the data received for the expected expression.
count=$(echo -en "GET / HTTP/1.0\n\n\n\n" | nc $node_ip $2 2>/dev/null | egrep -v '200 OK' 2>/dev/null | tr -d -c 'OK' 2>/dev/null | awk '{ print length; }' 2>/dev/null)
if [ ! -z "$count" ]
then
count=$(($count+0))
if [ $count -gt 8 ]
then
Remove the pidfile before the script echoes anything to stdout and is killed by bigd
rm -f $pidfile
echo "up"
fi
fi
Remove the pidfile before the script ends
rm -f $pidfile
END.
You need to modify it to put in the URI specific for your application.