Blog

Saturday, November 05, 2011

Monitor MySQL: Restart when it uses excess system resources and alert me

MySQL when left running for extended periods of time can use more and more system resources, this is especially true for very busy websites where the usage can become so extreme that all the ram is used and cpu usage hits 100%. When this happens, your website will fail to load and your entire server will lock up. daeMON can solve this by monitoring and restarting MySQL before it reaches these danger levels.

Reconfiguring the FireDaemon MySQL Service

First you need to configure your MySQL service to shutdown firedaemon if it crashes. The "Upon Program Exit" option in the "Settings" tab should set to: "Disabled" or "Shutdown FireDaemon".

FireDaemon Settings

Install and Configure daeMON

1. Download and install FireDaemon.

2. Download daeMON and unzip it into the directory of your choice (eg. C:\Program Files\daeMON).

3. Make a note of the short name of the MySQL service you want to monitor (eg. mysql).

4. Start the FireDaemon Service Manager from the Start/Programs menu or desktop icon. Click on the Create A New Service Definition button in the Toolbar or press Ctrl+N. Fill out the panel as per the screen shot below (adjust your paths and parameters to suite) - you can use the TAB or SHIFT+TAB keys to move between fields:

Daemon Program Tab

The working directory is where you have placed the daeMON Perl script. Note the Parameters list. This is the list of services (in startup order) that you want to monitor. Each service short name is prefixed with a -s. If you want to change the monitoring facility frequency use the -f flag. The following settings are good in most cases: High CPU load threshold (as a percentage): 75 High memory threshold (in MB): 1024 Monitoring frequency (in seconds): 60 Ignore high CPU/Memory for X monitored intervals (in minutes): 5 [Look in readme.txt included with Daemon for more flags and descriptions]

5. You should really change the desktop interaction flag as it's not necessary to see what's going on (but you can leave it on if you are curious):

Daemon Settings Tab

6. If you want to capture the debug log output of the utility then you can enable it as per the Output Capture section in the screenshot below. If your services take quite a while to initialise then you can set the Pre-Launch delay (in the Process section). This will defer the startup of daeMON by the number of milliseconds you specify (5000 = 5s).

Daemon Advanced Tab

7. Alternately, you can make the daeMON dependent on the services it is monitoring. For example:

Daemon Dependencies Tab

8. Then click the Install button and daeMON should be installed and monitoring your group of services. Should you accidently shutdown a service or a process dies, then all the services that you specified in the Parameters list will be restarted. To find out how to receive email alerts when MySQL restarts go here.

Comments
Post has no comments.



Captcha Image

Recent Posts



Tags


Archive

    Sign up for Product Updates and Discounts
    Captcha Image
    ×