•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Infrastructure
      • iColocation
    • Compute
      • cMetal
      • cVirtual
    • Storage
      • sObject
      • sBlock
    • Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • Protection
      • pBackup
      • pDDoS
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • new-colocation-header-img
      Infrastructure
      • iColocation
    • new-compute-header-img
      Compute
      • cMetal
      • cVirtual
    • new-storage-header-img
      Storage
      • sObject
      • sBlock
    • new-networking-header-img
      Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • new-protection-header-img
      Protection
      • pBackup
      • pDDoS
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

How to monitor MySQL using Nagios?

  • Home
  • Client
  • Qa Forum
  • How to monitor MySQL using Nagios?

Posted By: Benjamin | 1 Replies | Last Reply On: Oct 12, 2017 09:53:27

can someone please guide me on how i can setup Nagios to monitor MySQL? 

Psychz - Ramesh

Votes: 0Posted On: Oct 12, 2017 09:53:27
 

We will help you in configuring Nagios so that you can use it to monitor your MySQL server. Before we begin, there are a few prerequisites that you have to fulfill. We will create commands and services that will perform different tasks.

 

Prerequisites

1. Operating System - CentOS 7 

2. Nagios Core(Latest stable version) - Installed and configured. Please visit the following link to install Nagios Core and Nagios Plugins on CentOS 7. 

https://www.psychz.net/client/question/en/how-to-install-nagios-on-linux-step-by-step.html

3. Nagios Plugins should be installed.

4. MySQL server(MariaDB) should be installed on your server.

 

 

MySQL User Creation

1. Log in to your MySQL server with the following command.

mysql -u root -p

 

2. Type in the following commands.

mysql> CREATE USER 'nagios'@'localhost' IDENTIFIED BY 'mercury';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'localhost';
mysql> CREATE USER 'nagios'@'%' IDENTIFIED BY 'mercury';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'%';
mysql> flush privileges;

These commands create a user "nagios" that can be used by local host as well as remotely. We have also granted all privileges to the user.

 

 

MySQL Plugin Installation

1. Run the following command to download the "check_mysql_health-2.2.2.tar.gz" package.

wget https://labs.consol.de/assets/downloads/nagios/check_mysql_health-2.2.2.tar.gz

 

2. Extract the downloaded package.

tar -zxvf check_mysql_health-2.2.2.tar.gz

 

3. Change into the check_mysql_health-2.2.2 directory.

cd check_mysql_health-2.2.2

 

4. Run the following commands to configure and install the plugin.

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl

make

make install

 

 

Nagios Configuration for MySQL Monitoring 

1. Open the Nagios configuration file.

vi /usr/local/nagios/etc/nagios.cfg 

Add following line to the file.

cfg_file=/usr/local/nagios/etc/objects/mysqlmonitoring.cfg

 

2. "check_mysql_health" Command Definition

The following file contains all the commands pertaining to Nagios. Open it in any text editor of your choice("vi" in this case).

vi /usr/local/nagios/etc/objects/commands.cfg

Edit the file and add the "check_mysql_health" command block.

define command{
command_name check_mysql_health
command_line $USER1$/check_mysql_health -H $ARG1$ --username $ARG2$ --password $ARG3$ --port $ARG4$ --mode $ARG5$
}


3. "check_mysql_health" Service Definition

# Open the "mysqlmonitoring.cfg" file we had created earlier using the "vi" editor.

vi /usr/local/nagios/etc/objects/mysqlmonitoring.cfg

 

# Add the following service blocks of Connection-time, io thread and sql thread. This will perform different tasks.


define service{
use local-service
host_name localhost
service_description MySQL connection-time
check_command check_mysql_health!127.0.0.1!nagios!mercury!3306!connection-time!
}
define service{
use local-service
host_name localhost
service_description MySQL slave-io-running
check_command check_mysql_health!127.0.0.1!nagios!mercury!3306!slave-io-running!
}
define service{
use local-service
host_name localhost
service_description MySQL slave-sql-running
check_command check_mysql_health!127.0.0.1!nagios!mercury!3306!slave-sql-running!
}

 

4. Restart the Nagios server.

service nagios restart

You can configure other MySQL services as well whose information can be found on the website.

https://labs.consol.de/nagios/check_mysql_health/index.html

 

Was this reply helpful?

Related topics

  • Ubuntu remove mysql
  • Beste Open-Source-Monitoring-Tools für Server
  • Installing MariaDB on Centos 7
  • How to create a table in mysql using phpmyadmin?
  • Cloudwatch vs Nagios
  • cVirtual Best Security Practices
  • Top SQL-Datenbanken
  • Überwachen des Netzwerkverkehrs auf meinem Server
  • Dedizierter MySQL Server
  • Automatische Sicherung der MySQL Datenbank
  • Reference Architecture (Active-Passive Configuration)
  • Installation of Lamp Stack on CentOS 7
  • Im Vergleich: SQL VS NoSQL
  • Tools That Make Kubernetes Easier
  • Best Open-Source-Software für Linux-Anwender
Copyright © 2025 Psychz Networks,
A Profuse Solutions Inc Company
Hosting Services
Infrastructure
  • iColocation
Compute
  • cMetal
  • cVirtual
Storage
  • sObject
  • sBlock
Networking
  • nCDN
  • nIP Transit
  • nWavelength
Protection
  • pBackup
  • pDDoS
Company
  • About Us
  • Blog
  • Careers
  • Contact Us
  • Data Centers
  • Looking Glass
  • Network
  • Reseller
Policies
  • Acceptable Usage Policy
  • Privacy Policy
  • Service Level Agreement
  • Terms and Conditions
Support
  • Community
  • Knowledge Base
  • Open A Ticket
Get In Touch
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801