Net Soap Monitor

Problem this snippet solves:

This example perl scripts shows how to write a monitor for performing health checks against a .NET SOAP service.

The inbuilt SOAP check within the Big-IP LTM v9.x does not set "SOAPAction" in the HTTP header request. The check against the service then fails regardless.

HTTP Header Sample:

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.42)
Content-Type: text/xml; charset=utf-8
SOAPAction: "https://www.website.com.au/HealthCheck"

This is an example only, and the script will need to be modified to suit your needs.

Code :

#!/usr/bin/perl -w
# Big-IP SOAP for .NET Monitor - 08/15/2007 - Evan Taylor v1.0 - evan.taylor@dumbcomputers.net
# 
# This script allows you to specify SOAPAction in the HTTP header which .NET requires
# for processing SOAP requests.
# 
# HTTP Header Sample:
#
# User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.42)

# Content-Type: text/xml; charset=utf-8

# SOAPAction: "https://www.website.com.au/HealthCheck"
# ...
#
# This SOAP monitor is based off information gathered from the following sources;
#
# Interoperability demo: consume a .NET web service with Perl.
# http://users.skynet.be/pascalbotte/rcx-ws-doc/perldotnet.htm
#
# SOAP::Lite interoperability with .NET Web Services
# http://devfun.ncdesign.com/archives/000096.html
#
use strict;
use SOAP::Lite;
require 5.005;

# Derive and untaint programname.
my $programname = '/' . $0;
$programname =~ m/^.*\/([^\/]+)$/;
$programname = $1;

if ($programname eq '') {
    die "Bad data in program name\n"
}

# Process ID and file where it's to be stored.  The format
# is significant.

my $node = $ENV{"NODE_IP"};
my $port = $ENV{"NODE_PORT"};

my $pidfile = "/var/run/$programname.$node..$port.pid";
my $pid = "$$";

# Maintenence.  Clean up any existing EAV.

if (-f $pidfile ) {
    open(PID, "<$pidfile");
    my $pid = ;
    close(PID);
    if ( $pid ) {
        chomp $pid; $pid =~ m/^(\d+)$/; $pid = $1;
        if ( $pid ) {
            kill 9, $pid;
        }
    }
    unlink($pidfile);
}

# Create a new maintenence file.

open(PID, ">$pidfile");
print PID $pid, "\n";
close(PID);

# Strip preceding IPv6 characters for v9.x
my $ip = $ENV{"NODE_IP"};
$ip =~ s/::ffff://;
my $node_ip = $ip;

# Set some variables ...
# Variables set in EAV on the BIG-IP are $bigURI, $bigAction, and $bigProxy
# We don't currently use these ....

#my $bigProxy = $ENV{"bigProxy"};
#my $bigURI = $ENV{"bigURI"};
#my $bigAction = $ENV{"bigAction"};

# Setup the SOAP side of things ...

my $proxy = 'http://'.$node_ip.'/HealCheck.asmx';

my $soap = SOAP::Lite
    -> uri('https://www.website.com.au/')
    -> on_action( sub { 'https://www.website.com.au/HealthCheck' } )
    -> proxy( $proxy );

my $method = SOAP::Data->name('HealthCheck')
    ->attr({xmlns => 'https://wwww.website.com.au'});

my $params = ( SOAP::Data->name("accessKey" => 1234));

if (($soap->call($method => $params)->result) eq "true")
        {
        unlink($pidfile);
        print "up\n";
        exit(0);
        }
else{
        unlink($pidfile);
        exit(0);
}
Published Mar 12, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment