Databases 8 min read

How to Build a Chinese‑UI MySQL Monitoring Dashboard with Email & WeChat Alerts

This guide walks you through setting up the open‑source MySQL Monitor tool, covering environment preparation, installation, database schema import, host configuration, alert channel setup (email and WeChat), cron scheduling, and accessing the monitoring pages, all with a clean Chinese interface.

dbaplus Community
dbaplus Community
dbaplus Community
How to Build a Chinese‑UI MySQL Monitoring Dashboard with Email & WeChat Alerts

Overview

The MySQL Monitor project provides a lightweight Chinese‑language web dashboard that displays MySQL performance metrics such as connection count, QPS/TPS, index usage, replication delay, and supports email and WeChat alerts.

Environment Setup

On a Linux host install the required packages and start the web server:

# yum install httpd mysql php-mysqlnd -y
# yum install python-simplejson -y
# service httpd start

Download the latest source archive from the GitHub repository and extract it into the web root:

# unzip https://github.com/hcymysql/mysql_monitor/archive/master.zip -d /var/www/html/

Database Schema Import

Create the sql_db database (if it does not exist) and import the provided schema:

# cd /var/www/html/mysql_monitor/
# mysql -uroot -pYOUR_PASSWORD < mysql_monitor_schema.sql

Configure Monitored Hosts

Insert a record for each MySQL instance you want to monitor into the mysql_status_info table. Example:

INSERT INTO mysql_status_info (id, ip, dbname, user, pwd, port, monitor, send_mail, send_mail_to_list, send_weixin, send_weixin_to_list, alarm_threads_running, threshold_alarm_threads_running, alarm_repl_status, threshold_warning_repl_delay)
VALUES (1,'127.0.0.1','sql_db','admin','your_password',3306,1,1,'[email protected],[email protected]',1,'weixin_user',NULL,NULL,NULL,NULL);

Adjust the fields (IP, database name, credentials, ports, and alert flags) to match your environment. Key field meanings:

ip – MySQL server address

dbname – database name used for the monitor’s own tables

user / pwd – credentials with sufficient privileges (preferably ALL privileges)

port – MySQL port

monitor – 1 to enable data collection, 0 to disable

send_mail – 1 to enable email alerts

send_mail_to_list – comma‑separated list of email recipients

send_weixin – 1 to enable WeChat alerts

send_weixin_to_list – WeChat recipient identifier

threshold_alarm_threads_running – connection‑count threshold (integer)

threshold_warning_repl_delay – replication‑delay threshold (seconds)

Connection Configuration

Edit /var/www/html/mysql_monitor/conn.php to use the correct MySQL credentials for the monitor’s own database:

$con = mysqli_connect("127.0.0.1","admin","your_password","sql_db",3306) or die("Database connection error: ".mysqli_error());

Email Alert Configuration

Modify /var/www/html/mysql_monitor/mail/mail.php to set the sender address, SMTP server, and authentication details. The script invokes an external sendEmail binary; ensure it is executable:

# chmod 755 ./mail/sendEmail

WeChat Alert Configuration

Edit /var/www/html/mysql_monitor/weixin/wechat.py with your enterprise WeChat credentials. Follow the GitHub tutorial at https://github.com/X-Mars/Zabbix-Alert-WeChat/blob/master/README.md for detailed setup.

Cron Jobs for Data Collection

Schedule the two PHP scripts to run every minute. Add the following lines to the crontab of the web‑server user:

*/1 * * * * cd /var/www/html/mysql_monitor/; /usr/bin/php check_mysql_status.php > /dev/null 2>&1
*/1 * * * * cd /var/www/html/mysql_monitor/; /usr/bin/php check_mysql_repl.php > /dev/null 2>&1
check_mysql_status.php

collects general MySQL status and triggers email/WeChat alerts; check_mysql_repl.php collects replication information and triggers alerts.

Adjust Page Refresh Rate

Both dashboard pages contain a meta refresh tag. Edit mysql_status_monitor.php and mysql_repl_monitor.php to change the refresh interval (default 600 seconds):

<meta http-equiv="refresh" content="600" />  <!-- change 600 to desired seconds -->

Access the Dashboard

After deployment, open the following URLs in a browser (replace yourIP with the server’s address):

http://yourIP/mysql_monitor/mysql_status_monitor.php

http://yourIP/mysql_monitor/mysql_repl_monitor.php

These pages display real‑time MySQL metrics with Chinese labels and will send alerts when configured thresholds are breached.

Source Repository

The source code and releases are hosted at:

https://github.com/hcymysql/mysql_monitor

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AutomationdatabaseAlertingLinuxmysqlPHP
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.