Linux Server Monitoring with Monit
Monit is an open-source tool which we can use to monitor Linux servers:
- Performance Metrics (CPU and RAM Utilization)
- Disk space
- Running Services (Databases, Web servers etc)
Also, we can receive email notifications at defined thresholds and take automated actions using scripts.
Prerequisites
- Linux Server with privileged user access
- SMTP service provider (Ex: SendGrid/Gmail) if you want to configure email notifications on changes
Let’s set up Monit on the Server
Step 1: Install Monit
Step 2: Edit the configuration file (/etc/monit/monitrc)
# Email Configuration
# Alert Subscriptions
# Monitoring Config
# Enable Web Interface
It is recommended to expose the web interface internally. If you want Monit to accept connections on any addresses, remove use address localhost
Step3: Check configuration and apply configuration changes
sudo monit -t # check configuration
sudo monit reload # apply configuration changes
You are all set now!!! 👏👏👏
Let’s see how we can see the Monit status from CLI and Web Interface
To see Monit status from CLI
sudo monit status
To see the Web Interface
# If you have GUI access then visit http://localhost:2812 from you browser# Use SSH Port Forwording to see internaly exposed web interface of remote server from your computerssh -L [LOCAL_IP:]LOCAL_PORT:DESTINATION:DESTINATION_PORT [USER@]SSH_SERVER
(Ex: ssh -L 8080:ubuntu@12.12.1.X:2812 ubuntu@12.12.x.)
Thanks for reading :)