Forum Discussion

Paul_Slater's avatar
Paul_Slater
Icon for Nimbostratus rankNimbostratus
Jun 21, 2012

Creating an External Monitor in a partition

I am trying to get the NTP monitor working in a partition without much success.

 

 

I know that the config of the monitor is correct without any partition information as we have a Virtual F5 which I used to confirm that the Monitor responds and this is working fine.

 

 

I copied across the files from this virtual but the monitor fails so I can only presume that thepartion needs to be entered somewhere but where?

 

 

I took the standard NTP monitor on DEV Central as my base and removed the comments as it threw an error on line 48 but after the comments were removed the cli and the monitor worked straight away. can anyone shed some light?

2 Replies

  • Hi Paul,

     

     

    This is a bit ugly, and we've bastardized the original NTP monitor on Dev central but it seems to work thus far....

     

     

     

     

     

    !/usr/bin/perl -w

     

     

    use lib "/config/monitors/CPAN";

     

    use strict;

     

    use Net::NTP;

     

     

    Add this PM to /config/monitors/CPAN/Net

     

    use Net::IP;

     

     

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

     

     

     

     

    Create $ipv6 variable to change the $node IPv6 address

     

    to an 'un-shortened' IPv6 address ($fullipv6)

     

     

    my $ipv6 = new Net::IP ($node);

     

    my $fullipv6 = $ipv6->ip();

     

     

    Running "bigpipe db bigd.debug enable" can see "addr=2620:0:c10:f501:0:b:a20:97f6:123" when trying to test export (export

     

    NODE_IP="2620:0:c10:f501:0:b:a20:97fa" NODE_PORT="123") - the script failed.

     

    However, if used an IPv4 address it worked, tested on a virtual f5 debugging showed it

     

    was using IPv4 - assumed this was because we were using partitions on production

     

    boxes???

     

     

    took off the first 6 IPv6 octets as when debugging found this was the same for all

     

    addresses in the pool (this may be different on your box - partition name etc) - the last 2

     

    octets of NODE-IP converted from hex to dec equalled our IPv4 addresses.

     

     

    $fullipv6 =~ s/2620:0000:0c10:f501:0000:000b://;

     

     

    removed the colon between the 2 last octets

     

     

    $fullipv6 =~ s/://;

     

     

    pulled apart the $fullipv6 string into 4 variables ready to convert into decimal

     

     

    my ($v1, $v2, $v3, $v4) = unpack 'A2A2A2A2', $fullipv6;

     

     

    convert each of the hex (IPv6 Octet) variables into decimal

     

    my $ipv4v1 = hex($v1);

     

    my $ipv4v2 = hex($v2);

     

    my $ipv4v3 = hex($v3);

     

    my $ipv4v4 = hex($v4);

     

    my $dec = ".";

     

     

    create the IPv4 address from the above variables with decimals

     

    my $ipv4addy = ($ipv4v1 . $dec . $ipv4v2 . $dec . $ipv4v3 . $dec . $ipv4v4);

     

     

     

    put in the IPv4 address in the place of the old $node variable

     

    if (try_ntp_test($ipv4addy,$port)) {

     

    print "OK\n";

     

    }

     

     

    unlink($pidfile);

     

    exit(0);

     

     

     

     

    substituted the $node variable with the $ipv4addy variable

     

    sub try_ntp_test {

     

    we just make sure we get a response

     

    and that the server isn't a stratum

     

    16 server (ie, it's lost it's time source).

     

     

    my ($ipv4addy,$port) = @_;

     

    my %response;

     

     

    eval {

     

    %response = get_ntp_response($ipv4addy,$port);

     

    };

     

    if ($@) {

     

    return 0;

     

    } else {

     

    if ($response{'Stratum'} =~ /\d+/) {

     

    changed to drop the member if their stratum was 14 or higher

     

    if ($response{'Stratum'} >= 14) {

     

    return 0;

     

    } else {

     

    and it isn't 16

     

    return 1;

     

    }

     

    } else {

     

    return 0;

     

    }

     

    }

     

     

    }

     

     

     

     

  • 2620:0:c10:f501:0:b:a20:97f - Looks like the 'b' matches the partition id (in this case 11)

     

     

    And the first/48 bits are allocated to f5..

     

     

    NetRange: 2620:0:C10:: - 2620:0:C10:FFFF:FFFF:FFFF:FFFF:FFFF

     

    CIDR: 2620:0:C10::/48

     

    OriginAS: AS22317

     

    NetName: SEA-HQ

     

    NetHandle: NET6-2620-C10-1

     

    Parent: NET6-2620-1

     

    NetType: Direct Assignment

     

    RegDate: 2008-02-29

     

    Updated: 2012-02-24

     

    Ref: http://whois.arin.net/rest/net/NET6-2620-C10-1

     

     

    OrgName: F5 Networks, Inc.

     

    OrgId: F5NETW

     

    Address: 401 ELLIOTT AVE W

     

    City: SEATTLE

     

    StateProv: WA

     

    PostalCode: 98119

     

    Country: US

     

    RegDate: 1999-09-24

     

    Updated: 2011-09-24