A sample Laravel app for monitoring the status of remote servers. This includes monitoring for the following:
- Disk space
- Memory
- CPU
- Apache
- MySQL
- Beanstalkd
You can read the full tutorial at: https://pusher.com/tutorials/server-health-monitor-laravel
- PHP development environment - you need to have Apache, PHP, MySQL, and Node. You can use either Laravel Homestead, Laravel Valet, or Laradock.
- Pusher channels app instance
- Remote server to monitor which already has the public ssh keys from your local machine. Note that the ssh keys shouldn't have a password assigned to it.
- Clone the repo:
git clone https://github.com/anchetaWern/realtime-server-health-monitor.git
- Create a new Laravel project:
composer create-project --prefer-dist laravel/laravel liveservermonitor
-
Copy all the relevant files from the cloned repo over to your newly generate project. Note that only the files that were changed or added for the app is added in the repo. So don't replace entire folders in your project with the one's in the repo. Only copy over the relevant files.
-
Install the backend dependencies:
composer install
- Install the frontend dependencies and compile the scripts:
npm install
npm run dev
- Update the
.env
file with your database credentials:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=server_monitor
DB_USERNAME=YOUR_DB_USERNAME
DB_PASSWORD=YOUR_DB_PASSWORD
And Pusher credentials:
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
PUSHER_APP_ID=YOUR_PUSHER_APP_ID
PUSHER_APP_KEY=YOUR_PUSHER_APP_KEY
PUSHER_APP_SECRET=YOUR_PUSHER_APP_SECRET
PUSHER_APP_CLUSTER=YOUR_PUSHER_APP_CLUSTER
- Migrate the database:
php artisan migrate
-
Add virtual host for your project (e.g. liveservermonitor.loc).
-
Add a host to monitor:
php artisan server-monitor:add-host
- Run the checks:
php artisan server-monitor:run-checks
- Add project to cron:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
- Monitor your servers.
If this project helped you reduce time to develop, please consider buying me a cup of coffee :)