[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ha-dev
Subject: [Linux-ha-dev] patch for ldirectord 1.42
From: imak () endosys ! com
Date: 2002-04-11 4:34:35
[Download RAW message or body]
This message is in MIME format.
I have added dns and fixed a few typos with 1.42.
["ldirectord.v1.42.dns.patch" (text/plain)]
--- /tmp/ldirectord Wed Apr 10 20:06:41 2002
+++ /usr/sbin/ldirectord Thu Apr 11 00:27:30 2002
@@ -180,7 +180,7 @@
means no checking will take place and no real or fallback servers will be
activated. Default is I<negotiate>.
-B<service = http>|B<https>|B<ftp>|B<smtp>|B<pop3>|B<imap>|B<none>
+B<service = http>|B<https>|B<ftp>|B<smtp>|B<pop3>|B<imap>|B<dns>|B<none>
The type of service to monitor. None denotes a service that will not be
monitored. If the port specfied for the virtual server is 21, 25, 80,
@@ -564,6 +564,9 @@
if ($ip_port) {
$vsrv{checktype} = "negotiate";
$vsrv{protocol} = "tcp";
+ if ($ip_port =~ /:53/) {
+ $vsrv{protocol} = "udp";
+ }
} else {
$vsrv{fwm} = $fwm;
$vsrv{checktype} = "negotiate";
@@ -669,8 +672,8 @@
} elsif ($rcmd =~ /^service\s*=\s*(.*)/) {
lc($1);
$1 =~ /(\w+)/ && ($1 eq "http" || $1 eq \
"https"
- || $1 eq "ftp" || $1 eq "none" || $1 eq \
"smtp" || $1 eq "pop3" || $1 eq "imap")
- or &config_error($line, "service must be \
http, https, ftp, smtp, pop3, imap or none"); + \
|| $1 eq "ftp" || $1 eq "none" || $1 eq "smtp" || $1 eq "pop3" || $1 eq "imap" || $1 \
eq "dns") + or &config_error($line, \
"service must be http, https, ftp, smtp, pop3, imap, dns or none"); $vsrv{service} = \
$1;
} elsif ($rcmd =~ /^sitename\s*=\s*(.*)/) {
$1 =~ /(\w+)/ or &config_error($line, \
"invalid sitename"); @@ -807,6 +810,9 @@
elsif ($vsrv->{port} eq "143") {
$vsrv->{service} = "imap";
}
+ elsif ($vsrv->{port} eq "53") {
+ $vsrv->{service} = "dns";
+ }
else {
$vsrv->{service} = "none";
}
@@ -1319,7 +1325,7 @@
sub ld_stop
{
foreach my $v (@VIRTUAL) {
- y $real = $$v{real};
+ my $real = $$v{real};
foreach my $r (@$real) {
if ($$r{status}>0) {
&system_wrapper("$IPVSADM -d $$v{proto} " . \
&get_virtual($v) . " -r $$r{server}:$$r{port}"); @@ -1367,6 +1373,8 @@
$$r{num_connects} = 0 if \
(check_smtp($v, $r));
} elsif ($$v{service} eq "ftp") {
$$r{num_connects} = 0 if \
(check_ftp($v, $r)); + } elsif \
($$v{service} eq "dns") { + \
$$r{num_connects} = 0 if (check_dns($v, $r)); } else {
$$r{num_connects} = 0 if \
(check_none($v, $r)); }
@@ -1586,6 +1594,42 @@
return 0;
}
+sub check_dns
+{
+ my $res;
+ my $query;
+ my $rr;
+ my ($v,$r) = @_;
+ use Net::DNS;
+ $res = new Net::DNS::Resolver;
+
+ eval {
+ local $SIG{'__DIE__'} = "DEFAULT";
+ local $SIG{'ALRM'} = sub { die "timeout\n"; };
+ alarm($$v{checktimeout});
+ $res->nameservers($$r{server});
+ $query = $res->search("www.cisco.com"); ## my test domain...
+ alarm(0);
+ };
+
+ if (@$ eq "timeout\n") {
+ service_set($v,$r,"down");
+ return 0;
+ }
+
+ if ($query) {
+ foreach $rr ($query->answer) {
+ next unless $rr->type eq "A";
+ service_set($v,$r,"up");
+ return 1;
+ }
+ }
+
+ service_set($v,$r,"down");
+ return 0;
+}
+
+
# check_none
# Dummy function to check service if service type is none.
@@ -1702,7 +1746,7 @@
# _restore_service
-# Make a retore a real server. The opposite of _quiescent_server.
+# Retore a real server. The opposite of _quiescent_server.
# Should be called by _service_up or fallback_on
# I.e. If you want to change the state of a real server call set_service.
# If you call this function directly then ldirectord will lose track
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.community.tummy.com
http://lists.community.tummy.com/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic