watchowl/cake-server-monitor
Composer 安装命令:
composer require watchowl/cake-server-monitor
包简介
Server Monitor built with CakePHP 3
README 文档
README
CakePHP 3 Plugin for Monitoring Server Stats
Installation
-
To install the CakeServerMonitor plugin, you can use composer. From your application's ROOT directory (where composer.json file is located) run the following:
composer require watchowl/cake-server-monitor -
You will need to add the following line to your application's
config/bootstrap.phpfile:Plugin::load('Watchowl/CakeServerMonitor',['bootstrap' => true]);
Notification
CakeServerMonitor currently supports notification via email. You can configure recipients' email addresses in your applications 'config/bootstrap.php' file using overwriting the CakeServerMonitor.email.recipients key:
Configure::write( 'CakeServerMonitor.email.recipients', ['my-first-email@address.com','my-second-email@address.com'] );
Scheduling task
The last step to make this work is to add a cron job. You can do so by adding a similar line as shown below to your system's crontab file. Do remember to update the path to your own project. The following cron job runs at 1 am every day, you can change it to your own preference.
* 1 * * * cd path && bin/cake monitor run
Customisation
CakeServerMonitor does provide some customisation options.
- Changing email profile
by default CakeServerMonitor uses the default profile to send an email. You can change it to your own preference using the CakeServerMonitor.email.profile key:
Configure::write( 'CakeServerMonitor.email.profile', 'debug' );
- Changing checking stats
by default CakeServerMonitor checks following stats:
- Disk Space
- MySql Process
- Nginx Process
- Php5Fpm Process
Under the hood, each checker is actually a class under WatchOwl namespace. You can overwrite what checkers to run via the CakeServerMonitor.commands key:
Configure::write( 'CakeServerMonitor.commands', [ 'disk_space' => 'WatchOwl\CakeServerMonitor\CommandDefinition\DiskSpace', 'mysql' => 'WatchOwl\CakeServerMonitor\CommandDefinition\MySql', 'nginx' => 'WatchOwl\CakeServerMonitor\CommandDefinition\Nginx', 'php5fpm' => 'WatchOwl\CakeServerMonitor\CommandDefinition\Php5Fpm', ] );
You can remove any checkers above so it won't run.
- Creating your own checker
As you might have already guessed, you can create your own checker to extend CakeServerMonitor's abilities. To do so, creates a class extends from WatchOwl\CakeServerMonitor\CommandDefinition\CommandDefinition abstract class and implement its defined abstract methods.
After that, add your own checker to the CakeServerMonitor.commands key as shown in previous section.
Helper methods
To view current server stats:
bin/cake server_monitor view
watchowl/cake-server-monitor 适用场景与选型建议
watchowl/cake-server-monitor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 watchowl/cake-server-monitor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 watchowl/cake-server-monitor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-28