Skip to main content

Élenchos: Check MySQL and MariaDB Replication

A Élenchos command for checking the replication of a MySQL or MariaDB instance.

Installation and Configuration

Primary Instance

On the primary instance create a heartbeat by executing the following SQL commands.

create schema heartbeat;

use heartbeat;

create table heartbeat
(
  heartbeat datetime not null
) engine = InnoDB;

insert into heartbeat(heartbeat)
values (now());

create definer=root@localhost event heartbeat
on schedule every 1 minute starts '2016-02-07 09:22:34'
on completion preserve enable
comment 'Heartbeat for replication monitoring.'
do
update heartbeat
set heartbeat = now();

Using this heartbeat is more reliable than Seconds_Behind_Master as provided by the show replica status SQL command which is NULL when the SQL thread is not running.

Replica Host

On the host where the replication instance is running, install Élenchos by executing the following commands.

cd /opt

mkdir elenchos
cd elenchos

python -m venv .venv
mkdir bin
ln -s ../.venv/bin/elenchos bin/elenchos

. .venv/bin/activate
pip install elenchos_check_mymaria_replication
/opt/elenchos/bin/elenchos gather-commands

Create the configuration file /etc/nagios/replication.cfg:

[nagios]
name           = MariaDB Replication <hostname>
max_lag        = 60
warning        = 15000
critical       = 20000
timestamp_path = timestamp.txt

[database]
host       = localhost
database   = heartbeat
port       = 3306
charset    = utf8mb4
collation  = utf8mb4_general_ci
supplement = credentials.cfg

The values of host, port, charset, and collation in the database section are the defaults and can be omitted.

Create the file /etc/nagios/credentials.cfg for storing the credentials of the replication monitoring user:

[database]
user     = rep_monitor
password = secret

Set the proper mode and ownership of /etc/nagios/credentials.cfg by executing the following commands.

chmod 400  /etc/nagios/credentials.cfg
chown nrpe.nrpe /etc/nagios/credentials.cfg

Create the configuration file /etc/nrpe.d/check_mysql_replication.cfg for nrpe:

command[check_mysql_replication]=/opt/elenchos/bin/elenchos check:mariadb-replication /etc/nagios/replication.cfg

Create the user for monitoring the replication by executing the following SQL statements.

create user `rep_monitor`@`localhost` identified by password('secret') with max_user_connections 1;
grant binlog monitor, slave monitor on *.* to `rep_monitor`@`localhost`;
grant select on heartbeat.heartbeat to rep_monitor@localhost;

Finally, restart the nrpe daemon.

systemctl reload nrpe

License

This project is licensed under the terms of the MIT license.

Metadata

Release files for elenchos_check_mymaria_replication 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elenchos_check_mymaria_replication 1.4.0
File Size Uploaded
elenchos_check_mymaria_replication-1.4.0.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for elenchos_check_mymaria_replication 1.4.0
File Interpreter ABI Platform
elenchos_check_mymaria_replication-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / elenchos_check_mymaria_replication-1.4.0.tar.gz

Download URL elenchos_check_mymaria_replication-1.4.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bfa625cc0712eaab6845f3af05bc6d64e308f5ee6c149cad94c2bac192217f82
BLAKE2b-256 checksum
How to use checksums
5bec7822b86215ecbdfc37bf99e5cedb0f53a5b6fdbbd9aae5678c5421746889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Linux/6.14.6-300.fc42.x86_64

Release files / elenchos_check_mymaria_replication-1.4.0-py3-none-any.whl

Download URL elenchos_check_mymaria_replication-1.4.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afa91ba0fc5e83477c5e307e0c4384cee4b9c0590c86526733aab826d4cb9a2a
BLAKE2b-256 checksum
How to use checksums
bafb4381e31db67eb46adcea84a4758bae0551f25b13f70e302debbcc831dfa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Linux/6.14.6-300.fc42.x86_64

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page