How to Monitor MySQL or MariaDB Database Server Using Icinga2 On Ubuntu 22.04 LTS Server – 2023



How to Monitor MySQL or MariaDB Database Server Using Icinga2 On Ubuntu 22.04 LTS Server – 2023

How to Monitor MySQL or MariaDB Database Server Using Icinga2 On Ubuntu 22.04 LTS Server - 2023

In this video, you will learn how to configure Icinga to monitor your MySQL source and replica servers in your clusters.

You will learn how to use the check-mysql-health plugin to monitor various states of your MySQL database. Such as the database uptime, database size, the clients that are currently connected to the database, and the replication status.

PLEASE SUBSCRIBE 🙂
PLEASE HIT LIKE IF IT HELPED 🙂

GIVE SUPPORT – https://www.patreon.com/lazysysad
BUY ME A COFFEE – https://www.buymeacoffee.com/lazysysad
PAYPAL – https://www.paypal.com/donate/?hosted_button_id=K4RQ3LAWHGVS6

LINKS:
Icinga2 Master Installation and Configuration – https://youtu.be/OP07bSASKVw
Icinga2 Agent Installation and Configuration – https://youtu.be/UGSuz_LGmHE
MySQL8 Replication – https://youtu.be/s4oYWBGy_FE
Using SQL Queries to Monitor MySQL Using Icinga2 – https://youtu.be/gHjKN4Wshes
check_mysql_health – https://labs.consol.de/nagios/check_mysql_health/

Steps:
mysql -u root -p
CREATE USER ‘icinga’@’icinga.lazy.test’ IDENTIFIED WITH mysql_native_password BY ‘password’;
GRANT USAGE ON mysql.* TO ‘icinga’@’icinga.lazy.test’;
apt –no-install-recommends install monitoring-plugins-contrib
/usr/lib/nagios/plugins/check_mysql_health -h

vi /etc/icinga2/conf.d/mysql-source.lazy.test.conf
object Host “mysql-source.lazy.test” {
import “generic-host”
address = “mysql-source.lazy.test”
check_command = “hostalive”
vars.os = “Linux”
vars.mysql = true
}

vi /etc/icinga2/conf.d/mysql-replica.lazy.test.conf
object Host “mysql-replica.lazy.test” {
import “generic-host”
address = “mysql-replica.lazy.test”
check_command = “hostalive”
vars.os = “Linux”
vars.mysql = true
}

vi /etc/icinga2/conf.d/mysql.conf
apply Service “mysql-uptime” {
import “generic-service”
display_name = “MySQL Uptime”
check_command = “mysql_health”
vars.mysql_health_mode = “uptime”
vars.mysql_health_username = “icinga”
vars.mysql_health_password = “password”
assign where host.vars.mysql == true
}

apply Service “mysql-threads-connected” {
import “generic-service”
display_name = “MySQL Open Connections”
check_command = “mysql_health”
vars.mysql_health_mode = “threads-connected”
vars.mysql_health_username = “icinga”
vars.mysql_health_password = “password”
assign where host.vars.mysql == true
}

sudo mkdir /var/cache/nagios
sudo chown nagios:nagios /var/cache/nagios

vi /etc/icinga2/conf.d/mysql.conf
apply Service “mysql-slow-queries” {
import “generic-service”
display_name = “MySQL Slow Queries”
check_command = “mysql_health”
vars.mysql_health_mode = “slow-queries”
vars.mysql_health_username = “icinga”
vars.mysql_health_password = “password”
assign where host.vars.mysql == true
}

apply Service “mysql-long-running-procs” {
import “generic-service”
display_name = “MySQL Long Running Processes”
check_command = “mysql_health”
vars.mysql_health_mode = “long-running-procs”
vars.mysql_health_warning = “120”
vars.mysql_health_critical = “300”
vars.mysql_health_username = “icinga”
vars.mysql_health_password = “password”
assign where host.vars.mysql == true
}

mysql -u root -p
GRANT REPLICATION CLIENT ON *.* TO ‘icinga’@’icinga.lazy.test’;

vi /etc/icinga2/conf.d/mysql-replica.lazy.test.conf
object Host “mysql-replica.lazy.test” {
import “generic-host”
address = “mysql-replica.lazy.test”
check_command = “hostalive”
vars.os = “Linux”
vars.mysql = true
vars.mysql_replica= true
}

vi /etc/icinga2/conf.d/mysql-replica.conf
apply Service “mysql-replica-lag” {
import “generic-service”
display_name = “MySQL Replica Lag”
check_command = “mysql_health”
vars.mysql_health_mode = “slave-lag”
vars.mysql_health_username = “icinga”
vars.mysql_health_password = “password”
assign where host.vars.mysql_replica== true
}

apply Service “mysql-replica-io-status” {
import “generic-service”
display_name = “MySQL Replica IO Status”
check_command = “mysql_health”
vars.mysql_health_mode = “slave-io-running”
vars.mysql_health_username = “icinga”
vars.mysql_health_password = “password”
assign where host.vars.mysql_replica== true
}

apply Service “mysql-replica-sql-status” {
import “generic-service”
display_name = “MySQL Replica SQL Status”
check_command = “mysql_health”
vars.mysql_health_mode = “slave-sql-running”
vars.mysql_health_username = “icinga”
vars.mysql_health_password = “password”
assign where host.vars.mysql_replica== true
}

Chapters:
00:00 Intro
00:33 Create icinga MySQL user
01:20 Install plugins
02:00 Modify object Host file
02:22 apply Service for uptime
03:28 apply Service for threads-connected
04:54 apply Service for slow-queries
06:15 apply Service for long-running-procs
08:03 Grant replication permission
08:33 vars.mysql_replica
09:01 apply Service for slave-lag
09:58 apply Service for slave-io-running
10:50 apply Service for slave-sql-running
13:10 Outro

If this video helped you in any way, please like share and subscribe!
Thank you!!!

Comments are closed.