System Monitoring

ZenvilaZenvila
3 min read

Back to home

Monitoring Systems with Monit Framework

In system administration, a common principle is that a good system administrator doesn't need to frequently configure the system. Instead, they set it up once and then focus on monitoring and maintaining it. Monitoring tools like Monit help ensure that systems remain operational by continuously checking their status and reporting any issues.

For example, imagine your website provides services with 90% uptime (90/100 minutes). In technical terms, this is referred to as SLA (Service Level Agreement). While you could manually check your website periodically to ensure it's running, this approach is inefficient. Monitoring tools automate this process by checking the system's status at regular intervals.

This guide explains how to monitor an Apache web server using the Monit framework on Arch Linux.


Installing Monit and Apache Web Server

Note: The following commands are based on Arch Linux. You may need to adapt them for your own Linux distribution.

  1. Install the Apache web server:

     sudo pacman -S apache
    
  2. Install Monit:

     sudo pacman -S monit
    

Configuring Monit

  1. Open the Monit configuration file:

     sudo nano /etc/monit/monitrc
    
  2. Configure the file according to your requirements. For example, you can set up Monit to monitor the Apache service. Ensure you include settings such as the port (default: 2812) and authentication if required.

  3. Check the syntax of the configuration file:

     sudo monit -t
    

Starting and Enabling Monit

  1. Enable the Monit service to start at boot:

     sudo systemctl enable monit
    
  2. Start the Monit service:

     sudo systemctl start monit
    
  3. If you make changes to the configuration, restart Monit:

     sudo systemctl restart monit
    

Configuring Apache Web Server

  1. Ensure Apache is installed:

     sudo pacman -S apache
    
  2. Enable Apache to start at boot:

     sudo systemctl enable httpd
    
  3. Start the Apache service:

     sudo systemctl start httpd
    

Verifying Monit Service

  1. Open the Monit defaults file:

     sudo nano /etc/default/monit
    
  2. Ensure Monit is configured to monitor the desired services.

  3. Install a text-based web browser to access Monit from the terminal:

     sudo pacman -S links
    

Checking Port Status

To ensure Monit is listening on the configured port, use the following command:

netstat -nutlp
  1. Use links to check the Monit web interface on port 2812 (or the port you configured):

     links http://localhost:2812
    

Conclusion of Monit

Monit is a lightweight and efficient tool for automating system monitoring and ensuring reliability. It simplifies the management of services like Apache, detects issues proactively, and reduces manual intervention. By using Monit, system administrators can achieve high uptime and focus on other critical tasks, making it an essential tool for maintaining system health.


P.S. If you spot any mistakes, please don't hesitate to point them out. We're all here to learn together!

Haris
FAST (NUCES)
BS Computer Science | Class of 2027

1
Subscribe to my newsletter

Read articles from Zenvila directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Zenvila
Zenvila

I'm Haris aka Zen, currently in my 4th semester of Computer Science at FAST-NUCES and a member of COLAB (Research Lab) in Tier 3. I'm currently exploring AI/ML in its early stages, and also focusing on improving my problem-solving techniques. ๐Ÿง Proud user of Arch Linux | Command line is my playground. I'm interested in Automation & Robotics Automation enthusiast on a mission to innovate! ๐Ÿš€ Passionate about turning manual tasks into automated brilliance.