Re: [X-POST] PHP script to make sure MySQL is up?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Dunning wrote:
> I host at Rackspace, and one thing that their monitoring service does
> NOT catch is a problem when too many connections hit MySQL, and for some
> reason it remains hung up until the service is manually restarted. In
> the meantime, this is happening to us once or twice a month. It gets
> hammered with a huge number of brief connections from other Apache servers.
> 
> Slow queries and mysql_close() are NOT the problem. It's just too many
> connections, even though they're super fast.
> 
> Is there such a thing as a PHP script that I can put on a cron job to
> run every minute and make a test query, and upon failure, restart the
> service and maybe send an email to Rackspace support? I don't know how
> you'd check that the query was refused due to too many connections, and
> I also don't know how PHP would restart the MySQL service.
> 
> Thanks...  :)

You can write a perl or PHP script which makes a connection to the
database (using a low privileged mysql account of course). If the
connection succeeds, you are okay, otherwise send an alert.

I'd be hesitant to have the script restart the mysql server since you'd
have to put the mysql admin password into the script. Also, if you are
checking every minute and have legitimate downtime on the database, that
pesky script will cause you problems.

Also, if the restart is required on a regular basis, you probably need
to modify the number of active connections allowed in the mysql config file.

Good luck,
Roberto

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux