This section covers the specific configuration for external health monitor type.

The external monitor type allows you to write scripts to provide highly customized and granular health checks. The scripts may be Linux shell, Python, or Perl, which can be used to execute wget, netcat, curl, snmpget, mysql-client, or dig. External monitors have constrained access to resources, such as CPU and memory to ensure the normal functioning of NSX Advanced Load Balancer Service Engines. As with any custom scripting, thoroughly validate the long-term stability of the implemented script before pointing it at production servers.

You can view the errors generated from the script in the output by navigating to Operations > Events log.

NSX Advanced Load Balancer includes three sample scripts via the System-Xternal Perl, Python, and Shell monitors.


NSX Advanced Load Balancer supports IPv6 external health monitors.

While building an external monitor, you need to manually test the successful execution of the commands. To test command from an SE, you need to switch to the proper namespace or tenant. The production external monitor will correctly use the proper tenant.

Creating or Editing External Health Monitor

You can edit any of the external health monitors by clicking on the required checkboxes and then click the edit icon:

  • System-Xternal-Perl

  • System-Xternal-Python

  • System-Xternal-Shell

To create a new External health monitor, click Create button. Select the External option from the drop-down list of the Type field. The following screen is displayed:

You can specify the following details related to External settings:



Script Code

Specify the script code. You can either upload the script by clicking on the Upload File option or paste the script code by clicking the Paste Text option.

Script Parameters

Specify the optional arguments to feed into the script. These strings are passed in as arguments to the script, such as $1 = server IP, $2 = server port.

Health Monitor Port

Specify the health monitor. Use this port instead of the port defined for the server in the pool. If the monitor succeeds to this port, the load-balanced traffic will still be sent to the port of the server defined within the pool.

Script Variables

Specify the environment variables to be fed into the script. For instance, a script that authenticates to the server may have a variable set to USER=test.


MySQL Example Script

#mysql --host=$IP --user=root --password=s3cret! -e "select 1"

SharePoint Example Script

#curl http://$IP:$PORT/Shared%20Documents/10m.dat -I -L --ntlm -u $USER:$PASS -I -L > /run/hmuser/$HM_NAME.out 2>/dev/null
curl http://$IP:$PORT/Shared%20Documents/10m.dat -I -L --ntlm -u $USER:$PASS -I -L | grep "200 OK"

SharePoint Script Variables

USER='foo\administrator' PASS=foo123

Oracle Example Script

import sys
import os
import cx_Oracle
conn_str='HR_user/HR_pw@' + IP  + '/hr_db'
connection = cx_Oracle.connect(conn_str)
cursor = connection.cursor()
cursor.execute('select * from JOBS')
for row in cursor:
    print row

Oracle Script Variables


RADIUS Example Script

The below example performs an Access-Request using PAP authentication against the RADIUS pool member and checks for an Access-Accept response.

import os
import radius

    r = radius.Radius(os.environ['RAD_SECRET'],
    if r.authenticate(os.environ['RAD_USERNAME'], os.environ['RAD_PASSWORD']):
        print 'Access Accepted'

You can pass RAD_SECRET, RAD_TIMEOUT, RAD_USERNAME, and RAD_PASSWORD in the health monitor script variables, for instance:


Applications like curl can have different syntax for v4 and v6 addresses. The external health monitor scripts should be aware of these syntax. The following are the examples:

Shell Script Example for IPV6 Support

#curl -v $IP:$PORT >/run/hmuser/$HM_NAME.$IP.$PORT.out
if [[ $IP =~ : ]];
then curl -v [$IP]:$PORT;
else curl -v $IP:$PORT;

perl Script Example for IPV6 Support

#!/usr/bin/perl -w
my $ip= $ARGV[0];
my $port = $ARGV[1];
my $curl_out;
if ($ip =~ /:/) {
$curl_out = `curl -v "[$ip]":"$port" 2>&1`;
} else {
$curl_out = `curl -v "$ip":"$port" 2>&1`;
if (index($curl_out, "200 OK") != -1) {
    print "Server is up";

List of SE Packages

Scripting Languages

The following are the scripting languages:

  • Bash (shell script)

  • Perl

  • Python

Linux Packages (apt)

The following are the Linux packages:

  • curl

  • snmp

  • dnsutils

  • libpython2.7

  • python-dev

  • mysql-client

  • nmap

  • freetds-dev

  • freetds-bin

Python Packages (pip)

The following are the Python packages:

  • pymssql

  • cx_Oracle (and related libraries for Oracle Database 12c)

  • py-radius