Configuration
I'm a Netscaler CLI User (Cisco Academy Training ...), so the whole article will describe the configuration using the command line interface..
I assume that your Netscaler Appliance is configured and has an IP adress. I'll not cover the HA node creation.
First Step : Enable KAS Scripts Support
To do this, you have to edit the rc.conf file (or create it if it does not exist) and add the following lines :
mkdir /usr/local/lib/perl5/site_perl/Netscaler
ln -s /nsconfig/monitors/perl_mod/Netscaler/KAS.pm /usr/local/lib/perl5/site_perl/Netscaler/KAS.pm
A reboot is needed for this setting to be validated.
Second Step : Create the XML Service Monitoring Scripts
To create these files, you just have to cut and paste the following content in two .pl files (Perl).
In this Article, I'm using test_xml_service_NoLog.pl and test_xml_service_Log.pl
Once the two files are created, you must upload them onto the Netscaler, in /nsconfig/monitors/
Script 1 : Monitoring without Logs | test_xml_service_NoLog.pl
#!/usr/bin/perl -w
use strict;
require LWP::UserAgent;
use Netscaler::KAS;
sub probe_launcher
{
#my $fh;
#open ($fh, ">> /var/nstmp/monitors/xml_broker_cps4_lwp_kas_uni_wd_$_[0].log");
my $url = "http://" . $_[0] . ":" . $_[1] . "/scripts/wpnbr.dll";
#print $fh "globname" . $fh . "\n";
my $xml_request = '<?xml version="1.0" encoding="UTF-8"?>' .
'<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">' .
'<NFuseProtocol version="4.1">' .
'<RequestAddress>' .
'<Flags>no-load-bias</Flags>' .
'<Name>' .
'<AppName>' . $_[2] . '</AppName>' .
'</Name></RequestAddress>' .
'</NFuseProtocol>';
my $ua = LWP::UserAgent->new;
$ua->timeout(3);
my $request = HTTP::Request->new(POST => $url);
$request->content_type('text/xml');
$request->header('User-Agent' => 'Citrix NetScaler Application Switch');
$request->content($xml_request);
my $response = $ua->request($request);
if ($response->content =~ /tickettag/i) {
#print $fh $request->as_string;
#print $fh $response->content;
#print $fh "returning 0\n";
#close($fh);
return 0
}
else {
#print $fh $request->as_string;
#print $fh $response->content;
#print $fh "returning 1\n";
#close($fh);
return 1;
}
}
probe(\&probe_launcher);
Script 2 : Monitoring with Logs | test_xml_service_Log.pl
#!/usr/bin/perl -w
use strict;
require LWP::UserAgent;
use Netscaler::KAS;
sub probe_launcher
{
my $fh;
open ($fh, ">> /var/nstmp/monitors/xml_broker_cps4_lwp_kas_uni_wd_$_[0].log");
my $url = "http://" . $_[0] . ":" . $_[1] . "/scripts/wpnbr.dll";
print $fh "globname" . $fh . "\n";
my $xml_request = '<?xml version="1.0" encoding="UTF-8"?>' .
'<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">' .
'<NFuseProtocol version="4.1">' .
'<RequestAddress>' .
'<Flags>no-load-bias</Flags>' .
'<Name>' .
'<AppName>' . $_[2] . '</AppName>' .
'</Name></RequestAddress>' .
'</NFuseProtocol>';
my $ua = LWP::UserAgent->new;
$ua->timeout(3);
my $request = HTTP::Request->new(POST => $url);
$request->content_type('text/xml');
$request->header('User-Agent' => 'Citrix NetScaler Application Switch');
$request->content($xml_request);
my $response = $ua->request($request);
if ($response->content =~ /tickettag/i) {
print $fh $request->as_string;
print $fh $response->content;
print $fh "returning 0\n";
close($fh);
return 0
}
else {
print $fh $request->as_string;
print $fh $response->content;
print $fh "returning 1\n";
close($fh);
return 1;
}
}
probe(\&probe_launcher);