• Contact
  • About Me
  • Privacy Policy
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Solutions

Linux Performance Monitoring with Monit Application

neo by neo
May 27, 2025
in Solutions
0
Linux Performance Monitoring with Monit Application

Linux Performance Monitoring with Monit Application

0
SHARES
21
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Introduction

Monitoring the performance and health of a Linux system (running services) is crucial for maintaining uptime and ensuring applications run smoothly. Monit is a powerful, lightweight tool designed to simplify system monitoring and management. This article explores how Monit can be used to effectively monitor Linux systems, covering its key features, setup process, and configuration examples.

I tested Monit on Ubuntu 22.04 Desktop, and below is my configuration. I used a lot of standard configuration. My idea is to install it parallel with WordPress server to monitor my WordPress environment.

What is Monit?

Monit is a simple application that I use to manage services and monitor performance on Ubuntu servers. The application has the ability to restart services that are not running, and can send alert notifications in case defined resource usage thresholds are exceeded.

You can check manual page at the link .

Key Features of Monit

  • Process Monitoring: Monit can check if a process is running and restart it if it crashes.
  • File System Monitoring: It can monitor file attributes like timestamps and checksums.
  • Resource Monitoring: Monit can track CPU and memory usage to identify resource bottlenecks.
  • Remote Monitoring: Monit includes a web interface for remote monitoring and management.
  • Alerting: It can send alerts via email when a service or system requires attention.
  • Automatic Restart: If a service fails, Monit can automatically attempt to restart it.

Setting Up Monit

Monit Dashboard – Monitoring for Linux Services and Performance

Monit Installation on Ubuntu Server

To install Monit on a Debian-based system, use:

sudo apt update
sudo apt install monit

Monit is available in most Linux distributions’ package repositories.

Monit Configuration

Please check the following link about more configuration examples.

Monit’s configuration file is typically located at /etc/monit/monitrc. I installed it on my Ubuntu Desktop 22.04 and tested it on this system.

You have to edit this file to define what Monit will monitor and how.

Step 1. Create Backup and Remove Defaulf Configuration

# Create a backup
sudo cp /etc/monit/monitrc /etc/monit/monitrc.bkp
# Clean the file
sudo echo " " > /etc/monit/monitrc

Step 2. Enable the Web Interface and Users – Example

  • To enable the web interface, uncomment and modify the following lines in the configuration file:
    • In this case application will be available on the port 2812
set httpd port 2812 and
# only accept connection from localhost
    use address localhost   # only accept connection from localhost  -> Comment this line to enable connection from outside your network! 
# allow localhost to connect to the server
    allow localhost      
# require user 'admin' with password 'monit'  
    allow admin:monit      

Step 3: Create Monitoring Services – More examples

Monit monitoring is a modular application so the user can decide completely which module they want to monitor. Below I will give you a few suggestions and my full configuration is below.

ADVERTISEMENT
Apache HTTP Server Monitoring

Here is an example of configuring Monit to monitor the Apache HTTP server:

check process apache with pidfile /var/run/apache2/apache2.pid
    start program = "/etc/init.d/apache2 start"
    stop program = "/etc/init.d/apache2 stop"
    if failed host 127.0.0.1 port 80 protocol http then restart
    if 5 restarts within 5 cycles then timeout
Disk I/O Monitoring

Monitor disk read/write performance and detect potential bottlenecks:

ADVERTISEMENT
check device sda with path /dev/sda
    if read rate > 100 MB/s for 5 cycles then alert
    if write rate > 100 MB/s for 5 cycles then alert
Network Connectivity Check (Ping)

Ensure the server can reach the internet or specific services.

check host google-dns with address 8.8.8.8
    if failed ping then alert

My Example of Configuration File

# Clean the file
sudo echo " " > /etc/monit/monitrc

sudo nano /etc/monit/monitrc
set daemon  15
set logfile /var/log/monit.log
set alert user@optimusing.com
set httpd
    port 2812 # set port for the application
    use address localhost  # only accept connection from localhost  -> Comment this line to enable connection from outside your network! 
    # allow localhost       
    allow youruser:yourpassword # set user and password

# Check MySQL
check host localmysql with address 127.0.0.1
      if failed ping then alert
      if failed port 3306 protocol mysql then alert

# Check php-fpm
check process phpfpm with pidfile /run/php/php7.0-fpm.pid
      if cpu > 70% for 2 cycles then alert
      if total cpu > 90% for 5 cycles then restart
      if memory > 600 MB then alert
      # if total memory > 800 MB then restart

# Check Apache
check process apache with pidfile /var/run/apache2/apache2.pid    
      start program = "/etc/init.d/apache2 start"    
      stop program = "/etc/init.d/apache2 stop"    
      if failed host 127.0.0.1 port 80 protocol http then restart    
      if 5 restarts within 5 cycles then timeout    
      if cpu > 70% for 2 cycles then alert   
      if memory > 600 MB then alert

# Check Network
check network enp0s3 with interface enp0s3
    if failed link then alert
    if changed link then alert
    if saturation > 80% then alert
    if download > 10 MB/s then alert
    if upload > 10 MB/s then alert

# include files for individual sites
include /etc/monit.d/*

If you change the configuration file, the application must be stopped and restarted for it to take effect:

sudo monit -t
sudo systemctl stop monit
sudo systemctl start monit

Testing the Configuration

After configuring Monit, test the configuration file with the following command:

sudo monit -t

If the configuration is correct, start Monit:

ADVERTISEMENT

Enable Monit Service

sudo systemctl start monit
sudo systemctl enable monit

Access to the Monit Application

To access to the monit applicaiton open your browser and open the address:

http://IP-ADDRESS-OF-THE-SERVER:2812

Monitoring with Bash Scripts

If you are interested in monitoring, for example disk usage with email alerting using a Bash scripts, check the link.

About The Author

neo

See author's posts

Tags: best-on-the-webmain-news
ADVERTISEMENT
Previous Post

Fortinet FortiGate: Automation – Send Notification Email on Event

Next Post

Fortinet FortiGate: Enable Hidden Features

neo

neo

Next Post
Fortinet FortiGate: Enable Hidden Features

Fortinet FortiGate: Enable Hidden Features

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

MikroTik: Check Your Wireless Password

MikroTik: Check Your Wireless Password

ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Browse by Category

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.