Forum Discussion

kykong_107132's avatar
kykong_107132
Icon for Nimbostratus rankNimbostratus
Dec 06, 2005

external mointor

Hi All,

 

 

Actually I not sure whether this the correct place for me to post this question. previously in version4.5 PTF 10, i'm using a external monitoring using perl script to monitor DNS server health. it work fine.

 

 

But when I move the script to v9.2, the monitoring fail. no sure what's the problem.

 

 

Appreciate that anyone can give me some help..

 

 

below is my bigip config and script file

 

 

============bigip.conf==================

 

monitor testdns {

 

defaults from external

 

args "www.test.com"

 

run "/usr/bin/monitors/DNS_pinger"

 

}

 

========================================

 

 

=========DNS_pinger=====================

 

!/usr/bin/perl -w

 

 

use strict;

 

use Net::DNS;

 

require 5.005;

 

 

 

my ($node, $port, @domain) = @ARGV;

 

 

 

Derive and untaint programname.

 

my $programname = '/' . $0;

 

$programname =~ m/^.*\/([^\/]+)$/;

 

$programname = $1;

 

 

 

$node =~ m/^(\d+\.\d+\.\d+\.\d+)$/;

 

$node = $1;

 

 

 

$port =~ m/^(\d+)$/;

 

$port = $1;

 

 

 

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

 

is significant.

 

 

 

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);

 

 

 

Connect to the DNS server.

 

Perform A record lookup

 

my $res = Net::DNS::Resolver->new;

 

$res->nameservers($node);

 

my $ipquery = $res->search("@domain");

 

 

 

if (!($ipquery))

 

{

 

print STDERR "Failed to connect, ", $res->errorstring, "\n";

 

unlink($pidfile);

 

exit 1;

 

}

 

 

 

print "up\n";

 

 

 

Clean up.

 

unlink($pidfile);

 

exit 0;

 

==================================================================

 

 

 

 

regards

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

regards
  • We seem to have the same issue when we upgraded, the Pool always thinks it is up, regardless of what the external monitoring script says. We haven't resolved it either.
  • Contrary to what is in the /usr/bin/monitors/sample_monitor it looks like the external monitors now operate in such a way that if the script outputs anything, such as "foo", then the system is up and if it outputs nothing the system is down. At least my initial testing seems to indicate that as the possible reason our script no longer operates.
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    As it seems you've discovered, monitors have always taken ANY output by the script to stdout as an indication that the node is responding as expected.

    Your issue is most likely due to a change in the format of the pool member IP address as passed to the script by the monitor deamon: In BIG-IP v4, a dotted quad IPv4 address was passed. LTM instead passes an IPv4-mapped IPv6 address in the format of ::ffff:10.10.10.1 (for IPv4 address 10.10.10.1)

    So to account for that when monitoring IPv4 nodes, you'll notice the sample_monitor shell script strips off the IPv6 prefix leaving only the IPv4 dot notation address:
    node_ip=`echo $1 | sed 's/::ffff://'`

    However, your script looks for a match of a v4 dotted-quad address with no leading or trailing characters, which fails, thus the value of $node is an empty list:
    $node =~ m/^(\d+\.\d+\.\d+\.\d+)$/;
    $node = $1; 

    Replace those 2 lines instead with the following and you should be good to go with no other changes to your original script:
    $node =~ m/(\d+\.\d+\.\d+\.\d+)$/;
    (Grabs the end of $node if it matches the dotted-quad address format.)

    (Props to Colin for assisting with the perl translation.)

    Post back if you still have trouble and we'll dig in further.

    /deb