Ok. I think I can say nevermind. There must have been something wrong
with my script. Either that or the server must have actually been
down/inaccessible. I tried it again, and it seems to work now, even with
the host being blocked from accessing mysql
(it still manages to connect before it gets the rejection message, which
is fine with me).
Here's s simplified version of the code that I'm using (without the
alert() subroutine):
#!/bin/perl
use strict;
use Socket;
while(1) {
my $x = &check_port(myserver,3306);
if ($x == 0) { &alert(); }
sleep 300;
}
sub check_port(server,port) {
# get the passed arguments, server and port
my @ARGS = @_;
my $server = $ARGS[0];
my $port = $ARGS[1];
my $thisaddr = gethostbyname($thisserver);
my $thataddr = gethostbyname($server);
my $this = pack($sockaddr, &AF_INET, 0, $thisaddr);
my $that = pack($sockaddr, &AF_INET, $port, $thataddr);
# create socket, bind it, and connect to it, otherwise return 0.
socket(S, &AF_INET, &SOCK_STREAM, $proto) || return 0;
bind(S,$this) || return 0;
connect(S,$that) || return 0;
# close the connection gracefully.
close(S);
# return success
return 1;
}
Mark R. Andrachek, Jr.
Analyst I
Federal Reserve Bank of Richmond
[EMAIL PROTECTED]
(804) 697-7971
Bhavin Vyas <[EMAIL PROTECTED]>
06/12/2002 07:56 PM
To: [EMAIL PROTECTED], MySQL <[EMAIL PROTECTED]>
cc:
Subject: Re: max_connections
If you are just doing a port scan, that shouldn't be a problem. However,
if
you are going to the DB server, you will need to grant at least 'usage'
permissions to user@host via the GRANT statement.
Regards,
Bhavin.
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "MySQL" <[EMAIL PROTECTED]>
Sent: Wednesday, June 12, 2002 1:29 PM
Subject: max_connections
> I've written a small port monitor in perl, just to check and make sure
> something
> is responding on the port. I don't want to do anything fancy, but it
> appears that
> MySQL doesn't like this. It doesnt block connections from localhost
(thank
>
> goodness), but my remote port monitor gets locked out.
>
> I'm not sending any data, I'm just establishing and then closing the
> connection
> to the port.
>
> Is there any way to exempt a specific host(s)? Or is there an easy way
in
> perl to
> tell the server that I'm just checking, so go ahead and disconnect me?
>
> Mark R. Andrachek, Jr.
> Analyst I
> Federal Reserve Bank of Richmond
> [EMAIL PROTECTED]
> (804) 697-7971
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php