Forum Discussion
danjerman_19651
Nimbostratus
Mar 09, 2010v9.4.5 external monitor not running
Hi,
I'm having issues running an external monitor. The code has been copied over from a v4 box and the paths and syntax amended to try and make it work with v9. I didn't write the original script.
The script runs from the command line ok but I don't see it running on the box when configured as a node monitor. The pid file doesn't get created and neither do I see it running when doing a ps. On the v4 box, I constantly see the pid files coming and going as the monitor runs and the processes in ps.
The script :
!/usr/bin/perl
use Socket;
The script prints something if finds the word "Available" in the page /test/status.html
It takes the hostname as the only parameter
sub open_TCP
{
get parameters
my ($FS, $ipvalue, $port, $poolname) = @_;
my $proto = getprotobyname('tcp');
socket($FS, PF_INET, SOCK_STREAM, $proto);
my $sin = sockaddr_in($port,inet_aton($ipvalue));
connect($FS,$sin) || return undef;
my $old_fh = select($FS);
$| = 1; don't buffer output
select($old_fh);
1;
}
$pidfile="/var/run/pinger.$1..$2.pid";
`kill -9 `cat $pidfile` > /dev/null 2>&1`;
$ipvalue = $ARGV[0];
$port = $ARGV[1];
$poolname = $ARGV[2];
$statefile="/tmp/down_$ARGV[1]_$ipvalue";
$logfile="/var/log/ltm";
if (open_TCP(F, $ipvalue, 80) == undef)
{
`/bin/bigpipe pool $poolname member $ipvalue:$port down`;
`/bin/touch $statefile`;
exit(-1);
}
else
{
if ( -e $statefile )
{
`/bin/bigpipe pool $poolname member $ipvalue:$port up`;
`rm -f $statefile`;
}
send the GET method with / as a parameter
print F "GET /test/status.html\n\n";
$available=0;
get the response
while($return_line=
{
if($return_line =~ /Available/)
{
$available=1;
}
}
close(F);
print "$available\n";
if($available==1)
{
print "it is up\n";
`/bin/bigpipe pool $poolname member $ipvalue:$port session enable`;
}
else
{
`/bin/bigpipe pool $poolname member $ipvalue:$port session disable`;
}
}
When I run it from the command line, I get this :
./v9script.pl x.x.x.x 80 v9poolname
1
it is up
I have chmod'd the file to 777 so it is executable but i just dont see anything occurring on the box when it is applied.
Any assistance will be gratefully received. I am using 9.4.5 build 1086.1
TIA
DM
D
11 Replies
- hoolio
Cirrostratus
One thing to add is handling for IPv6 addresses that LTM uses internally:
http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/HTTPMonitor_cURL_BasicGET.html
these arguments supplied automatically for all external monitors:
$1 = IP (IPv6 notation. IPv4 addresses are passed in the form
::ffff:w.x.y.z
where "w.x.y.z" is the IPv4 address)
$2 = port (decimal, host byte order)
remove IPv6/IPv4 compatibility prefix (LTM passes addresses in IPv6 format)
IP=`echo ${1} | sed 's/::ffff://'`
PORT=${2}
This is bash, but you could do something similar with perl to strip off the ::ffff: prefix.
Aaron - danjerman_19651
Nimbostratus
Is the IPv6 thing essential ?
Thanks
Dan - hoolio
Cirrostratus
bigd uses ::ffff:w.x.y.z where w.x.y.z is the IPv4 address, so yes, it's essential to remove that from the IP you reference in your script.
I'm not sure why the PID file wouldn't be created though. I'm also not sure that you can get the pool name from a monitor in 9.x or 10.x
Aaron - danjerman_19651
Nimbostratus
Thanks Aaron, I'll try and strip the IPv6 bit in perl then.
It seems that the LTM isn't running the script at all, even though it works at command line. The poolname is being supplied as a argument when calling the script.
You may have guessed I'm not really a scripter, I've inherited this and am trying to get it to work on v9. I can't say I know exactly what each line in the script does so am flying a little blind. :-|
Cheers
Dan - hwidjaja_37598
Altostratus
Do you see any error message in the log files? Verify the path, can u send us these:
b monitor list | grep run
b pool list | grep monitor
Remember to change and with the real name. - hwidjaja_37598
Altostratus
I think your script is expecting for a pool name as the third argument. By default, ltm is only passing 2 arguments (IP and port number):
$poolname = $ARGV[2];
You can add additional argument to the monitor. Try comparing the monitor setting from your v4. - danjerman_19651
Nimbostratus
Do you see any error message in the log files?
-No, I get nothing in the logs. if I run the script from the command line, I get the following entry in the ltm log...
Pool member x.x.x.x:80 session status enabled.
The output you requested (I've had to mask the appname/poolname/IPs due to company policy but they should show you how its setup).
b monitor m_appname_x.x.x.x_80 list
monitor m_appname_x.x.x.x_80 {
defaults from external
args "x.x.x.x 80 p_appname_80_p"
run "v9script"
}
b pool p_appname_80_p list
pool p_appname_80_p {
min active members 1
members
x.x.x.x:http
priority 100
monitor m_appname_x.x.x.x_80
y.y.y.y:http
priority 100
monitor m_appname_y.y.y.y_80
z.z.z.z:http
priority 100
monitor m_appname_z.z.z.z_80
}
Thanks
Dan - danjerman_19651
Nimbostratus
I think your script is expecting for a pool name as the third argument. By default, ltm is only passing 2 arguments (IP and port number):
$poolname = $ARGV[2];
You can add additional argument to the monitor. Try comparing the monitor setting from your v4.
-I added the line ...
$poolname = $ARGV[2];
...to the script to try and allow it to be passed the poolname (this is because of the way in v4 you could disable a node as x.x.x.x:port whereas in v9 you can only bring down a node as x.x.x.x. To specify the port in v9, you also need to say what pool it is in.
I now call the script with 3 arguments, ip, port and poolname.
Was I supposed to add something else to the script to get it to accept the 3 arguments?
Cheers
Dan - hwidjaja_37598
Altostratus
Can you try removing the IP and Port from monitor's args?
b monitor m_appname_x.x.x.x_80 list
monitor m_appname_x.x.x.x_80 {
defaults from external
args " x.x.x.x 80 p_appname_80_p"
run "v9script"
}
Can you also send us the unmodified script and the logic/explanation on what you want to achieve?
Feel free to mask the IP/hostname/etc. - danjerman_19651
Nimbostratus
I removed the ip and port from the supplied args and the only difference was that it seems to mark the node down quicker. (i.e. failed rather than timed out)
Here is the original v4 script. Its a legacy setup and the app needs the node to be disabled rather than marked down (Well, it did in v4...I'm trying to get the app guys to do some serious testing with me with v9 to see if we actually need the script in v9...however, its not clear exactly why this was setup this way to begin with tbh)
!/usr/bin/perl
use Socket;
The script prints something if finds the word "Available" in the page /test/status.html
It takes the hostname as the only parameter
sub open_TCP
{
get parameters
my ($FS, $ipvalue, $port) = @_;
my $proto = getprotobyname('tcp');
socket($FS, PF_INET, SOCK_STREAM, $proto);
my $sin = sockaddr_in($port,inet_aton($ipvalue));
connect($FS,$sin) || return undef;
my $old_fh = select($FS);
$| = 1; don't buffer output
select($old_fh);
1;
}
$pidfile="/var/run/pinger.$1..$2.pid";
`kill -9 `cat $pidfile` > /dev/null 2>&1`;
$ipvalue = $ARGV[0];
$port = $ARGV[1];
$statefile="/tmp/down_$ARGV[1]_$ipvalue";
$logfile="/var/log/bigd";
if (open_TCP(F, $ipvalue, 80) == undef)
{
`/sbin/bigpipe node $ipvalue:$port down`;
`/usr/bin/touch $statefile`;
exit(-1);
}
else
{
if ( -e $statefile )
{
`/sbin/bigpipe node $ipvalue:$port up`;
`rm -f $statefile`;
}
send the GET method with / as a parameter
print F "GET /test/status.html\n\n";
$available=0;
get the response
while($return_line=
{
if($return_line =~ /Available/)
{
$available=1;
}
}
close(F);
print "$available\n";
if($available==1)
{
print "it is up\n";
`/sbin/bigpipe node $ipvalue:$port enable`;
}
else
{
`/sbin/bigpipe node $ipvalue:$port disable`;
}
}
Cheers
DM
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
