saeedvaziry / laravel-monitoring
Monitor Laravel Hosted Servers
Fund package maintenance!
saeedvaziry
Ko Fi
Installs: 14 062
Dependents: 0
Suggesters: 0
Security: 0
Stars: 173
Watchers: 3
Forks: 33
Open Issues: 1
Requires
- php: ^7.1|^8.0
- laravel/framework: ^6.0|^7.0|^8.0|^9.0|^10.0
Requires (Dev)
- guzzlehttp/guzzle: ^6.5.5|^7.0
- orchestra/testbench: ^4.0|^5.0|^6.0
- phpunit/phpunit: ^8.0|^9.0
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
.
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).