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

Linux Performance Monitoring with Monit Application

by neo
November 28, 2025
in Solutions
0
Linux Performance Monitoring with Monit Application

Linux Performance Monitoring with Monit Application

0
SHARES
46
VIEWS
Share on FacebookShare on LinkedIn
Table of Contents
  • Linux Performance Monitoring
  • What is Monit?
    • Key Features of Monit
  • Setting Up Monit
    • Monit Installation on Ubuntu Server
    • Monit Configuration
    • My Example of Configuration File
    • Testing the Configuration
    • Enable Monit Service
  • Monitoring with Bash Scripts

Linux Performance Monitoring

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.

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:

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:

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.

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

Fortinet FortiGate: Automation – Send Notification Email on Event

Next Post

Fortinet FortiGate: Enable Hidden Features

neo

Related Posts

Install Portainer on Ubuntu 24.04 Using Docker Compose
Docker

Install Portainer on Ubuntu 24.04 Using Docker Compose

Automatic Windows Service Monitoring and Restart Script
Solutions

Automatic Windows Service Monitoring and Restart Script

Host a Website on Raspberry Pi – Real Benchmark Tests
Solutions

Host a Website on Raspberry Pi – Real Benchmark Tests

My Ultimate Docker Command Cheat Sheet (2025 Edition)
Docker

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script
Docker

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script

Raspberry Pi Monitoring with Monit: Docker, Temperature, Network & More
Solutions

Raspberry Pi Monitoring with Monit: Docker, Temperature & More

Next Post
Fortinet FortiGate: Enable Hidden Features

Fortinet FortiGate: Enable Hidden Features

Recommended

Oracle VirtualBox: Port Forwarding in NAT Network Mode

Oracle VirtualBox: Port Forwarding in NAT Network Mode

MikroTik: Configure static IP Address on the Interface

MikroTik: Configure Static IP Address on the Interface

My Top 5 Applications to Run on Raspberry Pi with Ubuntu

My Top 5 Applications to Run on Raspberry Pi with Ubuntu (2026)

Maximizing Network Efficiency with AdGuard: My 7-Day Results

Maximizing Network Efficiency with AdGuard: My 7-Day Results

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

Categories

  • 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
  • Web Tools

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

Recent News

My Top 5 Applications to Run on Raspberry Pi with Ubuntu

My Top 5 Applications to Run on Raspberry Pi with Ubuntu (2026)

Maximizing Network Efficiency with AdGuard: My 7-Day Results

Maximizing Network Efficiency with AdGuard: My 7-Day Results

  • 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
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.