/realtime-server-health-monitor

A sample Laravel app for monitoring the status of remote servers

Primary LanguagePHP

Laravel Live Server Monitoring App

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

Prerequisites

Getting Started

  1. Clone the repo:
git clone https://github.com/anchetaWern/realtime-server-health-monitor.git
  1. Create a new Laravel project:
composer create-project --prefer-dist laravel/laravel liveservermonitor
  1. 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.

  2. Install the backend dependencies:

composer install
  1. Install the frontend dependencies and compile the scripts:
npm install
npm run dev
  1. 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
  1. Migrate the database:
php artisan migrate
  1. Add virtual host for your project (e.g. liveservermonitor.loc).

  2. Add a host to monitor:

php artisan server-monitor:add-host
  1. Run the checks:
php artisan server-monitor:run-checks
  1. Add project to cron:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
  1. Monitor your servers.

Built With

Donation

If this project helped you reduce time to develop, please consider buying me a cup of coffee :)

Buy Me A Coffee