Greenguy's Board


Go Back   Greenguy's Board > I'm Looking For.......
Register FAQ Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2006-07-17, 08:35 AM   #1
Doug E
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
 
Doug E's Avatar
 
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.
__________________
Asian Porn | Sora Aoi | Natt Kesarin
Doug E is offline   Reply With Quote
Old 2006-07-17, 11:24 AM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
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;
}
You could put that in cron to run every 10 minutes.

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
cd34 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:26 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc