|
|
|
|
|
|
|
![]() |
#1 |
Kids are great, Appu. You can teach them to hate the things you hate and they practically raise themselves now-a-days, you know, with the internet and all
Join Date: Mar 2005
Location: Canadeh
Posts: 197
|
a tool to monitor mysql
I have frequent mysql crashes and need a tool to monitor for a pattern. Something that checks to see if mysql is running every 10 minutes or so. And im cheap so it would have to be a free one.
![]() |
![]() |
![]() |
![]() |
#2 |
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
Code:
#!/usr/bin/perl use DBI; use DBI::DBD; my $dbh = DBI->connect("DBI:mysql:database", "username", "password"); if (!$dbh) { my $SENDMAIL = '/usr/sbin/sendmail -t'; my $EMAILADDRESS = 'your@email.com'; open (SENDMAIL,"| $SENDMAIL"); print SENDMAIL "To: $EMAILADDRESS\n"; print SENDMAIL "From: $EMAILADDRESS\n"; print SENDMAIL "Subject: mysql failed to connect\n\n"; close SENDMAIL; } The question really is, what is the failure? can you connect, but queries cannot be executed? can you connect at all? is the machine overloaded and queries are slow? is it really down or just extremely slow? Are you running out of connections? If mysql is segfaulting and terminating, this script will alert. If it is just slow, it'll never register a failure because it is able to connect. You can add commands in there to do other things like actually run a query against a table to see if it is getting a response. Best place to check if mysql is really stopping is the error log. check /etc/my.cnf or /etc/mysql/my.cnf to see where it is logging the errors or have your web hosting company take a look at it. Mysql usually doesn't just die without some indication of the problem, and we've got mysql servers that have run for months on end under a heavy beating and I can't remember the last time we had mysql terminate except in the case of a disk failure.
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | Rate This Thread |
|
|