Abstract

This document describes how you can monitor an MySQL database server such as:

  • Connection time
  • The number of connections
  • Cache hit
  • etc

 

There are some steps you’ll need to follow in order to monitor a new database machine: 

  • Understand what is already available (in the Shinken Entreprise installation) 
  • Setup the MySQL user account
  • Test the connection to the database 
  • Setup your server host definition  
On this page

What is already available in the Shinken Installation

To make your life a bit easier, a few configuration tasks have already been done for you:

  1. Installation of check_mysql_health plugin : /var/lib/shinken/libexec/check_mysql_health
  2. Several host templates are ready to be used

 

Note

We suppose here that the MySQL server you want to monitor is named srv-lin-1 and is a Linux. Please change the configuration and commands according with the real name of your server.

Setup the MySQL user account

Connect with a root account on your MySQL database. change ‘password’ with your mysql root password:

 lin-srv-1:# mysql -u root -ppassword

And create a shinken user:

GRANT usage ON *.* TO 'shinken'@'%' IDENTIFIED BY 'shinkenpassword';

It’s a good thing to change the shinkenpassword to another password. Then you need to update the /etc/shinken/resource.d/mysql.cfg

$MYSQLUSER$=shinken
$MYSQLPASSWORD$=shinkenpassword

Test the connection

To see if the connection to the MySQL server is ok, just launch :

/var/lib/shinken/libexec/check_mysql_health --hostname "srv-lin-1" --username "shinken" --password "shinkenpassword" --mode connection-time

What is checked with the templates


Public templates

mysql

This is the very basic MySQL template allowing to know if your MySQL database server is running and usable.

Every MySQL templates (except Mysql-connection-method) use it as a parent template.

CheckDetailCheck rangeDefault WarningDefault Critical
connectionTime to connect to the server0 to n15
restartTime the server is running0 to n10:5:
slow_queriesslow_queries0 to n0.11
tmp_disk_tablesPercent of temp tables created on disk0 to n2550

mysql-full

Contains all MySQL host templates listed in the Shinken Adminstrators templates.

Warning

Using the mysql-full template will require a lot of resources on your poller daemon. We advise to use only the needed templates.

Shinken Administrator templates (can't be seen by other users)

mysql-connection-method

This template describes the method to connect to MySQL server. Every MySQL templates use it as a parent template.

 

mysql-cluster

This template gives informations about the MySQL cluster.

 

 

mysql-innoDB

This template gives informations about innoDB buffers and logwaits.

 

CheckDetailCheck rangeDefault WarningDefault Critical
bufferpool_hitrateInnoDB buffer pool hitrate0 to n99:95:
bufferpool_wait_freeInnoDB buffer pool waits for clean page available0 to n110
log_waitsInnoDB log waits because of a too small log buffer0 to n110

mysql-MyISAM

This template gives informations about MyISAM key cache hitrate.

 

CheckDetailCheck rangeDefault WarningDefault Critical
keycache-hitrateMyISAM key cache hitrate0 to n99:95:

mysql-performance

This template gives informations about the global server performance.

 

CheckDetailCheck rangeDefault WarningDefault Critical
index_usageUsage of indexes0 to n90:80:
long_running_procslong running processes0 to n1020
table_lock_contentionTable lock contention0 to n12
tablecache_hitrateTable cache hitrate0 to n99:95:
threadcache_hitrateHit rate of the thread-cache0 to n1020

mysql-query-cache

This template gives informations about query cache.

 

CheckDetailCheck rangeDefault WarningDefault Critical
qcache_hitrateQuery cache hitrate0 to n90:80:
qcache_lowmem_prunesQuery cache entries pruned because of low memory0 to n110

mysql-usage

This template gives informations about MySQL server usage.

 

CheckDetailCheck rangeDefault WarningDefault Critical
open_filesPercent of opened files0 to n8095
threads_connectedNumber of currently open connections0 to n1020

How to 

Configuration of Mysql-connection-method host template

Click on Hosts then on Hosts Templates in the Elements menu

In the Name field, type mysql-connection.

Then clic on mysql-connection-method

Clic on Data tab 

You can setup the following DATA : 

  • MYSSQLPASSWORD : the MySQL password of the user used to connect to database
  • MYSQLUSER : the MySQL user name used to connect to database

 

 

You can also set the user and password directly in /etc/shinken/resource.d/myslq.cfg

$MYSQLUSER$=shinken
$MYSQLPASSWORD$=shinkenpassword



Attach a MySQL template to you host

Clic on Hosts in the Elements menu

Add the chosen MySQL host template to the Host Templates to inherit field.

For example the MySQL host template.

Click on the Data tab

Check if the Following data are ok.