Operations 7 min read

Deploy and Use a Lightweight Redis Monitor for Real‑Time Metrics

This guide explains how to install, configure, and run a lightweight Redis Monitor that visualizes connection count, QPS, memory usage and replication delay, supports standalone, sentinel and cluster modes, and provides email and WeChat alerts via simple PHP scripts.

dbaplus Community
dbaplus Community
dbaplus Community
Deploy and Use a Lightweight Redis Monitor for Real‑Time Metrics

Overview

Redis Monitor is a lightweight web‑based visualization tool that collects key Redis metrics—connection count, QPS, memory usage, and replication lag—by parsing the output of redis-cli info. It works with Redis 6.2+ in single‑instance, Sentinel, and cluster deployments.

Features

Supports single‑instance, Sentinel, and cluster modes.

Auto‑discovers master/slave IPs after a single host entry.

Remote data collection requires no agent on the Redis server.

Built‑in email and WeChat alerting.

Environment Setup (CentOS 7)

yum install -y php-pear php-devel php httpd mysql php-mysqlnd php-redis
systemctl restart httpd.service
redis-cli config set requirepass yourPassword

Installation

git clone https://github.com/hcymysql/redis_monitor.git /var/www/html/redis_monitor
chmod 755 ./mail/sendEmail
chmod 755 ./weixin/wechat.py

Database Schema

mysql -uroot -p123456 < redis_monitor_schema.sql

Optionally change the mysql_status_history table engine to RocksDB for compression and I/O efficiency.

Register Monitored Host

INSERT INTO redis_status_info (id,host,tag,pwd,port,monitor,send_mail,send_mail_to_list,send_weixin,send_weixin_to_list,threshold_alarm_threads_running,threshold_warning_used_memory)
VALUES (1,'192.168.176.27','RedisTest','hechunyang123456',6379,1,1,'[email protected]',1,'hechunyang',150,'200M');

Host Table Fields

host : IP address of the Redis instance.

tag : Business name or identifier.

pwd : Password for the Redis instance.

port : Redis port number.

monitor : 1 to enable monitoring, 0 to disable.

send_mail : 1 to enable email alerts, 0 to disable.

send_mail_to_list : Comma‑separated list of email recipients.

send_weixin : 1 to enable WeChat alerts, 0 to disable.

send_weixin_to_list : WeChat recipient identifier.

threshold_alarm_threads_running : Connection count threshold (integer).

threshold_warning_used_memory : Memory usage threshold (e.g., 200M).

Connection Configuration

$con = mysqli_connect("127.0.0.1","admin","hechunyang","redis_monitor","3306") or die("Database connection error" . mysqli_error());

Email Alert Settings

system("./mail/sendEmail -f [email protected] -t '{$this->send_mail_to_list}' -s smtp.139.com:25 -u '{$this->alarm_subject}' -o message-charset=utf8 -o message-content-type=html -m 'Alert: {$this->alarm_info}' -xu [email protected] -xp 123456 -o tls=no");

WeChat Alert Settings

Configure the enterprise WeChat account according to the README at https://github.com/X-Mars/Zabbix-Alert-WeChat/blob/master/README.md

Cron Job

* * * * * /usr/bin/php /var/www/html/redis_monitor/check_redis_status.php > /dev/null 2>&1

Page Auto‑Refresh

Adjust the meta refresh interval in redis_status_monitor.php (default 600 seconds):

<meta http-equiv="refresh" content="600">

Access URL

Open the monitor in a browser: http:// yourIP /redis_monitor/redis_status_monitor.php

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.

AutomationredisLinuxmysqlPHP
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.