How Can We Help?
Categories
< All Topics
Print

How do I write my own Real Server Monitors?

Writing your own Real Server Monitors is not difficult. The EdgeADC provides for the import of custom written monitors.

Custom authored monitors need to be written using the PERL languange, and Edgenexus provides a template in the admin guide found here: https://www.edgenexus.io/documentation.

When writing a monitor, you need to be aware of some STRICT Variables that are used. These are listed below.

# my $host = $_[0]; - This uses the “Address” from IP Services--Real Server section
# my $port = $_[1]; - This uses the “Port” from IP Services--Real Server section
# my $content = $_[2]; - This uses the “Required Content” value from the Library--Real Server Monitoring section
# my $notes = $_[3]; - This uses the “Notes” column in Real Server section of IP Services
# my $page = $_[4]; - This uses the “Page Location” values from Library--Real Server Monitor section
# my $user = $_[5]; - This uses the “User” value from the Library--Real Server Monitor section
# my $password = $_[6]; - This uses the “Password” value from the Library--Real Server Monitor section

The monitor code must return the result as:

  • 1 for Success
  • 2 for Failure

An example monitor code is shown below.

#Monitor-Name: Edgenexus-Agfa-Status-Health-Check
use strict;
use warnings;
########################################################################################################
# Edgenexus custom health checking Copyright Edgenexus 2023
########################################################################################################
#
#
# This is a Perl script for Edgenexus customer health checking
# The monitor name as above is displayed in the dropdown of Available health checks
# There are 3 value passed to this script
#
# I am using:
# _[0] IP address of the server to be health checked
# _[2] Required content - 200OK
# _[4] Page - Location and Port to use
# my $host = $_[0]; - This uses the “Address” from IP Services--Real Server section
# my $port = $_[1]; - This uses the “Port” from IP Services--Real Server section
# my $content = $_[2]; - This uses the “Required Content” value from the Library--Real Server Monitoring section
# my $notes = $_[3]; - This uses the “Notes” column in Real Server section of IP Services
# my $page = $_[4]; - This uses the “Page Location” values from Library--Real Server Monitor section
# my $user = $_[5]; - This uses the “User” value from the Library--Real Server Monitor section
# my $password = $_[6]; - This uses the “Password” value from the Library--Real Server Monitor section
#
# The script will return the following values
# 1 is the test is successful
# 2 if the test is unsuccessful
#
sub monitor
{
my $host = $_[0]; ### Host IP or name
my $content = $_[2]; ### Required Response
my $cvar = $_[4]; ### Path to be checked (Path, Port, prefix)
my ($page, $port, $prefix) = split(/,\s*/, $cvar);
$host = "$host:$port";
my @lines = `/usr/bin/wget -q -S --tries=1 --timeout=1 --no-check-certificate --output-document=- $prefix://$host$page 2>&1`;
if (join("",@lines))
{
print "$prefix://$host$page looking for - $content - Healhcheck check successful\n";
return(1);
}
else
{
print "$prefix://$host$page looking for - $content - Healhcheck check failed.\n";
return(2)
}
}
monitor(@ARGV);
Scroll to Top
WordPress Appliance - Powered by TurnKey Linux