MySQL monitoring - Linux, Mac and FreeBSD

Server Density supports monitoring of a running MySQL server.

This article is outdated and will eventually be removed. See v2 agent MySQL monitoring

1) Dependencies

The agent uses the MySQLdb module to interact with MySQL. You must have this installed to use the MySQL monitoring functionality.

a) Installation - package managed (try this first)

CentOS, Fedora, RHEL:

yum install python-devel
yum install MySQL-python

Debian, Ubuntu:

apt-get install python-dev
apt-get install python-mysqldb

b) Installation - manual (try this if option a) above does not work)

Download MySQLdb and install it: This will require the Python build tools and MySQL development headers.

python setup.py build
python setup.py install

You will also need to set the permissions if you installed the agent using our OS packages: 

chmod -R 777 /usr/bin/sd-agent/

c) Installation - manual (dependancies)

If you get errors in step b) above, you may need to install some extra packages. Install the Python build tools and MySQL headers using your OS package management:

CentOS, Fedora, RHEL:

yum install python-devel
yum install mysql-devel

Debian, Ubuntu:

apt-get install python-dev
apt-get install mysql-devel

Then install the Python setuptools by following the instructions on the website. You will then be able to go back to step b).

2) Agent configuration

The agent /etc/sd-agent/config.cfg file requires 3 additional config lines to be completed to allow the agent to connect to your MySQL server. 

mysql_server:
mysql_user:
mysql_pass:

Fill out the details for each line for a MySQL user. Your mysql_server will generally belocalhost unless you want the agent to connect to a remote server.

mysql_server: localhost
mysql_user: myMysqlUsername
mysql_pass: myMysqlPassword

Custom ports and sockets

You can specify a custom port and/or socket if you are not running the default. You do this by adding 2 new config options to the config file underneath the existing options e.g.: 

mysql_port: 3307
mysql_socket: /tmp/mysql.sock

Users

You can use any user to connect to the database, although we recommend you create a specific user with no privileges (except for connect). See the MySQL documentation for user management instructions.

Database privileges

When configuring MySQL you must provide a user that the agent will use to log into your MySQL server. This user does not require any special privileges unless you wish to monitor replication when the user will require SUPER or REPLICATION CLIENT privileges. 

3) Restart agent

Restart the agent to start the monitoring. Using replication? Make sure you set up the right alerts.

4) Add graphs

Click the name of your server from the Devices list in your Server Density account then go to the Metrics tab. Click the + Graph button on the right then choose the MySQL metrics to display the graphs. The metrics will also be available to select when building dashboard graphs.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.