nawasara/database-monitor 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nawasara/database-monitor

Composer 安装命令:

composer require nawasara/database-monitor

包简介

MySQL/MariaDB server + database monitoring for the Nawasara superapp framework — inventory, capacity, performance, slow query, and alerting via a single read-only monitoring user.

README 文档

README

MySQL/MariaDB inventory, capacity, performance, and alert monitoring for the Nawasara superapp framework.

Scoped to one central MySQL server (the Kominfo deployment baseline as of 2026-05-25) but the schema stays multi-server capable.

Phases

Phase Scope Status
A Inventory + uptime scaffolding
B Capacity (DB size, top tables, growth) planned
C Performance (processlist, slow query auto-detect, global status) planned
D Backup + replication DROPPED — no replication, no standard backup tool yet
E Alerts via nawasara/notification planned
F Administration (CREATE/DROP DB, manage MySQL users) planned, separate PR

See docs/todo-database-monitor.md for the full plan.

Setup

1. Create the monitoring user on the target MySQL server

CREATE USER 'nawasara_monitor'@'%' IDENTIFIED BY '<strong-password>';

GRANT SELECT, PROCESS, REPLICATION CLIENT, SHOW DATABASES, SHOW VIEW
    ON *.* TO 'nawasara_monitor'@'%';

FLUSH PRIVILEGES;

Restrict the host to your Nawasara container IP when possible:

CREATE USER 'nawasara_monitor'@'10.x.x.x' IDENTIFIED BY '<strong-password>';

Verify:

SHOW GRANTS FOR 'nawasara_monitor'@'%';
-- Must be exactly:
-- GRANT SELECT, PROCESS, REPLICATION CLIENT, SHOW DATABASES, SHOW VIEW ON *.* TO `nawasara_monitor`@`%`

The user is read-only by design — no INSERT, UPDATE, DELETE, CREATE, DROP, or GRANT privileges. Phase F administration uses a separate, higher-privilege user (created when that phase ships).

2. Store credentials in Vault

Open Nawasara → Pengaturan → Vault → Database Monitor and fill:

  • Host — hostname or IP of the MySQL server
  • Port — usually 3306
  • Database — leave blank (we connect server-wide, not per-DB)
  • Usernamenawasara_monitor
  • Password — the strong password from step 1

Click Test Connection to verify.

3. Seed permissions

php artisan db:seed --class="Nawasara\\DatabaseMonitor\\Database\\Seeders\\PermissionSeeder"

This creates the database-monitor.* permissions and grants them to the developer role (if present).

Privileges explained

Grant Purpose
SELECT ON *.* Reads information_schema (sizes, table list), performance_schema (status, processlist), and mysql.slow_log (slow query, when enabled)
PROCESS Required for SHOW PROCESSLIST to see all sessions, not just the monitor user's own
REPLICATION CLIENT SHOW REPLICA STATUS — granted defensively so replication monitoring works the day replication is enabled, without re-granting
SHOW DATABASES Lists all schemas regardless of user permissions
SHOW VIEW Reads view definitions for sizing

Runtime connection — no .env leakage

The package never registers DATABASE_MONITOR_* env vars or pushes anything into config/database.php. Connection config is built at runtime from Vault each time a job or page needs it, used, then purged to release the LAN socket. Defence-in-depth: every session runs with SET SESSION TRANSACTION READ ONLY regardless of the granted privileges.

License

MIT.

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固