Forum Discussion
lovleen_arora_2
Jul 22, 2016Nimbostratus
Help to write the Monitor script
Hi,
my server response is like this, when I accss the URL on HTTPS
{"myStatus":"OK","datapowerStatus":{"status":"OK","message":"{\"result\": {\"domain\": \"My_StubServices\"}}","millisecondsTake...
JG
Jul 26, 2016Cumulonimbus
This one should do it:
!/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.
Edit: The count should be 8 or greater.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects