external monitor

bash script for external monitor using curl to check the status of the following http://x.y.z.com/BroadcastState/Default.aspx?obj=Smtpbackendserver which checks the smtp service

What is the expected output of http://x.y.z.com/BroadcastState/Default.aspx?obj=Smtpbackendserver if the SMTP server is healthy?

yes

That means you only need an HTTP monitor.

You can create a custom monitor for the SMTP server, specifying the following:

Type: HTTP
Send String: "GET /BroadcastState/Default.aspx?obj=Smtpbackendserver HTTP/1.0\r\nHost: x.y.z.com\r\n\r\n" (No quotes)
Receive String: yes
Alias Address: IP address of x.y.z.com
Alias Service Port: 80

.

SMTP scripted monitor

Other useful links:

K00764435: Expected behavior of an SMTP monitor myF5

K7444: Requirements for external monitor output myF5

Not sure why you need an external but here’s one based on /config/monitors/sample_monitor anyway:

!/bin/sh


 (c) Copyright 1996-2006, 2010-2013 F5 Networks, Inc.

 This software is confidential and may contain trade secrets that are the
 property of F5 Networks, Inc.  No part of the software may be disclosed
 to other parties without the express written consent of F5 Networks, Inc.
 It is against the law to copy the software.  No part of the software may
 be reproduced, transmitted, or distributed in any form or by any means,
 electronic or mechanical, including photocopying, recording, or information
 storage and retrieval systems, for any purpose without the express written
 permission of F5 Networks, Inc.  Our services are only available for legal
 users of the program, for instance in the event that we extend our services
 by offering the updating of files via the Internet.

 @() $Id: //depot/maint/bigip11.6.2/tm_daemon/monitors/sample_monitor1 $




 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.

echo "GET /" | /usr/bin/nc $node_ip $2 2> /dev/null | grep -E -i $3 > /dev/null
echo "GET /BroadcastState/Default.aspx?obj=Smtpbackendserver HTTP/1.0\r\nHost: x.y.z.com\r\n\r\n" | /usr/bin/nc ip_addr_of_x.y.z.com 80 2> /dev/null | grep -E -i "yes" > /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

You need to add the monitor name, host name and IP address where necessary.