saeedvaziry/laravel-monitoring
Composer 安装命令:
composer require saeedvaziry/laravel-monitoring
包简介
Monitor Laravel Hosted Servers
README 文档
README
Monitor your Laravel applications server with a beautiful dashboard and get notified if anything gets wrong!
Supported OS
This package works only on Linux servers.
Installation
1) Install the latest version from composer
For PHP >= 8.1
composer require saeedvaziry/laravel-monitoring
For PHP <= 8.0
composer require saeedvaziry/laravel-monitoring "1.4.2"
2) Publish vendors
php artisan monitoring:publish
3) Run migrations
php artisan migrate
4) Set up a cronjob to collect data
* * * * * cd /path-to-your-project && php artisan monitoring:record
5) Visit /monitoring to see the statistics.
Configuration
You can find the configuration at config/monitoring.php.
| Key | Description |
|---|---|
instance_name |
This is your current server's name, And the data will be collected under this name. |
routes |
You can change the URL prefix of the monitoring dashboard. Also, You can protect the route by applying middlewares to it. |
models |
If you want to customize the models, define yours and update this config. |
chart_colors |
Chart colors are customizable by this config. |
notifications |
Currently, we support Slack and Email channels for notifications. However, You can add your custom channels. To add a custom channel, Create a class and implement it by SaeedVaziry\Monitoring\Channels\Channel and then add the class to channels under the notifications item. |
Multi-Server support
Sometimes your source code is deployed to multiple servers.
For example, You have multiple webservers with a load balancer and another server for your Backoffice.
In this case, you just need to set a unique name for MONITORING_INSTANCE_NAME environment variable on each server, Of course, assuming that you have one database in common with all the servers that you want to monitor.
The result will be similar to the Demo picture.
Command
You can use php artisan monitoring:record command to collect the data manually.
Facade
Add the bellow line to your config/app.php file, Under the allias:
'aliases' => [ ... 'Monitoring' => \SaeedVaziry\Monitoring\Facades\Monitoring::class ... ];
With this Facade you can access the server's resource usages.
Example usages:
Monitoring::cpu()->usage(); // returns CPU usage Monitoring::memory()->usage(); // returns Memory usage Monitoring::disk()->usage(); // returns Disk usage
Purge Records
Without purging, the monitoring_records table can accumulate records very quickly. To mitigate this, you should schedule the monitoring:purge Artisan command to run daily or any time you wish.
You can also, Set the purge_before configuration at config/monitoring.php.
$schedule->command('monitoring:purge')->daily();
Contributing
Please feel free to submit an issue or open a PR.
Credits
License
Laravel Monitoring is open-sourced software and licensed under the MIT License (MIT).
saeedvaziry/laravel-monitoring 适用场景与选型建议
saeedvaziry/laravel-monitoring 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.86k 次下载、GitHub Stars 达 177, 最近一次更新时间为 2022 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 saeedvaziry/laravel-monitoring 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 saeedvaziry/laravel-monitoring 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 177
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-05

