How to Monitor Ubuntu 24.02 Server with Monit

By Raman Kumar

Updated on Jun 14, 2025

In this tutorial, we'll learn how to setup Monit on Ubuntu 24.02 to montior server health, configure Nginx as a reverse proxy, and secure Monit with HTTPS using Certbot.

Monitoring our Ubuntu 24.02 server is critical to ensure it runs smoothly, efficiently, and securely. Downtime or undetected failures can severely impact service availability. To tackle this, we can set up a lightweight, reliable, and powerful tool called Monit.

Monit is an open-source utility that automatically monitors system processes, files, directories, and services on Unix systems. It can restart crashed services and send alerts when something goes wrong. Here’s how we can set it up step-by-step on our Ubuntu 24.02 server.

Prerequisites

Before starting, make sure our new Ubuntu server is ready. The following components should be installed and configured:

  • A Ubuntu 24.04 installed dedicated server or KVM VPS.
  • A root user or normal user with administrative privileges.
  • A domain name with pointing A record to server.

How to Monitor Your Ubuntu 24.02 Server with Monit and Secure It Using Nginx and SSL (Step-by-Step Guide)

Step 1: Update Our Ubuntu 24.02 Server

Before installing any packages, it’s a best practice to update our system to the latest state:

sudo apt update && sudo apt upgrade -y

This ensures our packages and security patches are current.

Step 2: Install Monit

Monit is available in the default Ubuntu repositories, so installation is straightforward:

sudo apt install monit -y

Once installed, the Monit daemon starts automatically. We can check its status using:

sudo systemctl status monit

Step 3: Enable and Start Monit

To make sure Monit starts at boot:

sudo systemctl enable monit
sudo systemctl start monit

Step 4: Configure Monit for Web Access

Monit comes with a built-in web interface, which we can enable for easier monitoring.

Open the Monit configuration file:

sudo nano /etc/monit/monitrc

Uncomment and edit the following lines:

set httpd port 2812 and
    use address 0.0.0.0  # or 127.0.0.1 for local access only
    allow admin:monit   # username:password for web login

Save and exit the file (Ctrl+O, Enter, Ctrl+X).

Restart Monit to apply changes:

sudo systemctl restart monit

Now we can access the Monit dashboard via:

http://<your-server-ip>:2812

Login using the credentials we defined (admin / monit in the example above).

Step 5: Set Up Email Alerts

To receive notifications when something fails, we need to configure Monit to send email alerts.

In the same /etc/monit/monitrc file, find and update these lines:

set mailserver smtp.gmail.com port 587
    username "your-email@gmail.com" password "your-app-password"
    using tlsv12

set alert your-email@gmail.com

Replace with actual email and an App Password if using Gmail (due to 2FA).

Save and exit the file.

Restart Monit:

sudo systemctl restart monit

We will now receive alerts when monitored services or resources encounter issues.

Step 6: Monitor Critical Services

Let’s configure Monit to monitor critical services like Nginx, MySQL, or SSH.

Example: Monitor Nginx

Create a config file:

sudo nano /etc/monit/conf-enabled/nginx

Add:

check process nginx with pidfile /run/nginx.pid
    start program = "/usr/sbin/service nginx start"
    stop program  = "/usr/sbin/service nginx stop"
    if failed port 80 protocol http then restart
    if 5 restarts within 5 cycles then timeout

Save and close.

Check the config syntax:

sudo monit -t

Then reload Monit:

sudo systemctl reload monit

Repeat similar steps to monitor other services (e.g., MySQL, Apache, SSH).

Step 7: Monitor System Resources

Monit can also track CPU, memory, disk usage, and more.

Add this to /etc/monit/monitrc or a separate file in conf-enabled:

check system ubuntu-server
    if loadavg (1min) > 2 then alert
    if memory usage > 80% then alert
    if cpu usage (user) > 70% then alert
    if cpu usage (system) > 30% then alert
    if cpu usage (wait) > 20% then alert

Reload Monit again:

sudo systemctl reload monit

Step 8: View Monit Status

Use the following command to view all monitored services:

sudo monit status

It gives us a quick overview of what’s running fine and what isn’t.

Step 9: Install and Configure Nginx on Ubuntu 24.02

Nginx is a popular and high-performance web server. We'll start by setting it up.

1. Install Nginx

sudo apt install nginx -y

2. Start and Enable Nginx

sudo systemctl enable nginx
sudo systemctl start nginx

3. Allow Nginx Through the Firewall

sudo ufw allow 'Nginx Full'
sudo ufw reload

We assume UFW (Uncomplicated Firewall) is active. If not, you can enable it using sudo ufw enable.

Step 10: Create a Server Block (Virtual Host)

Let’s say our domain is monitor.example.com.

1. Create a new config file:

sudo nano /etc/nginx/sites-available/monitor.example.com

2. Add this content:

server {
    listen 80;
    server_name monitor.example.com;

    location / {
        proxy_pass http://127.0.0.1:2812/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Enable this config:

sudo ln -s /etc/nginx/sites-available/monitor.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 11: Keep Monit Listening Only on localhost

In /etc/monit/monitrc, update:

set httpd port 2812 and
    use address 127.0.0.1  # Only allow local access (secure)
    allow admin:monit

This ensures Monit is not directly exposed to the internet.

Then restart Monit:

sudo systemctl restart monit

Step 12: Secure Nginx with SSL Using Certbot (Let’s Encrypt)

Let’s Encrypt provides free SSL certificates and Certbot automates the process.

1. Install Certbot and Nginx plugin:

sudo apt install certbot python3-certbot-nginx -y

2. Obtain and install the SSL certificate:

sudo certbot --nginx -d monitor.example.com

Certbot will:

  • Obtain SSL certificates
  • Update your Nginx config with HTTPS settings
  • Set up auto-renewal

3. Test auto-renewal:

sudo certbot renew --dry-run

This ensures our certificate will automatically renew before it expires.

Step 13: Update Monit to Monitor Nginx with HTTPS

If we’ve already added Nginx monitoring (as shown earlier), we can adjust the port/protocol to reflect HTTPS:

check process nginx with pidfile /run/nginx.pid
    start program = "/usr/sbin/service nginx start"
    stop program  = "/usr/sbin/service nginx stop"
    if failed port 443 protocol https then restart
    if 5 restarts within 5 cycles then timeout

Reload Monit after changes:

sudo systemctl reload monit

Final Thoughts

In this tutorial, we've learnt how to setup Monit on Ubuntu 24.02. Monit is an ideal tool for setting up a lightweight monitoring and alerting system on our Ubuntu 24.02 server. It not only watches over critical services and resources but also takes recovery actions automatically. With web UI and email alerting, we stay informed and in control 24/7 — even when we’re not logged in.

By now, we’ve:

  • Installed and configured Monit to monitor our system and services
  • Set up Nginx as our web server
  • Secured Nginx with Let’s Encrypt SSL using Certbot
  • Integrated Nginx with Monit for automatic monitoring and alerting

By implementing Monit, we are actively improving the uptime, stability, and resilience of our infrastructure.

If you're running production workloads or hosting critical services, Monit should be one of the first tools we deploy.

Check out our low cost dedicated server.