Install Monitorix on Debian 11: Easy Monitoring – OrcaCore

Posted on

Install Monitorix on Debian 11: Easy Monitoring - OrcaCore

Install Monitorix on Debian 11: Easy Monitoring – OrcaCore

This tutorial, brought to you by Orcacore, aims to guide you through the process of installing Monitorix on Debian 11. If you’re looking for a robust and user-friendly monitoring solution for your Linux servers, Monitorix is an excellent choice. It provides detailed insights into various aspects of your system’s performance, allowing you to proactively identify and address potential issues. With Monitorix, you can monitor a wide array of metrics, including:

  • System Load Average
  • CPU Usage
  • Memory Allocation
  • Disk Drive I/O activity
  • Network Traffic
  • Services

This guide will walk you through the installation, configuration, and basic usage of Monitorix on Debian 11, covering both single-host and multi-host monitoring scenarios.

If you’re interested in installing Monitorix on other Linux distributions, you can refer to these guides:

Install and Configure Monitorix on Ubuntu 22.04

How To Install Monitorix on AlmaLinux 8

Before proceeding, ensure you have the following prerequisites:

  • Access to your Debian 11 server as a non-root user with sudo privileges.
  • A basic firewall configured with UFW (Uncomplicated Firewall). You can follow our guide on Initial Server Setup with Debian 11 for assistance with this.

With the prerequisites in place, let’s begin the Monitorix configuration.

Step 1 – Monitorix Installation on Debian 11

The Monitorix packages are readily available in the default Debian 11 repository. Begin by updating your system’s package list to ensure you have the latest versions:

sudo apt update

Next, install Monitorix along with its required dependencies using the following command:

sudo apt install monitorix rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl libio-socket-ssl-perl -y

This command installs Monitorix, the RRDtool (for data storage and graphing), and various Perl modules that Monitorix relies on.

Step 2 – Verify Monitorix Installation

After the installation is complete, verify that Monitorix is installed correctly by checking its version:

monitorix -v

The output should resemble the following:

**Output**
Monitorix version 3.12.0 (21-Feb-2020)

This confirms that Monitorix has been successfully installed on your Debian 11 system.

Step 3 – Start and Enable Monitorix Service

To ensure Monitorix starts automatically on system boot and is currently running, enable and start the Monitorix service:

sudo systemctl enable --now monitorix

Now, check the status of the Monitorix service to confirm it’s active and running:

sudo systemctl status monitorix

You should see output similar to this:

**Output**
● monitorix.service - Monitorix
     Loaded: loaded (/lib/systemd/system/monitorix.service; enabled; vendor preset: enabled)
     Active: **active** (**running**) since Tue 2023-05-23 03:42:42 EDT; 4min 5s ago
       Docs: man:monitorix(8)
   Main PID: 2509 (/usr/bin/monito)
      Tasks: 2 (limit: 4679)
     Memory: 80.6M
        CPU: 1.231s
     CGroup: /system.slice/monitorix.service
             └─2509 /usr/bin/monitorix -c /etc/monitorix/monitorix.conf -p /run/monitorix.pid
             └─2592 monitorix-httpd listening on 8080
...

The "active (running)" status indicates that the Monitorix service is functioning correctly.

Step 4 – Configure Monitorix on Debian 11

The primary configuration file for Monitorix is located at /etc/monitorix/monitorix.conf. This file allows you to customize various aspects of Monitorix’s behavior.

Before making any changes, it’s highly recommended to create a backup of the original configuration file:

sudo cp /etc/monitorix/monitorix.conf /etc/monitorix/monitorix.conf.backup

Now, open the configuration file using your preferred text editor (e.g., vi, nano):

sudo vi /etc/monitorix/monitorix.conf

Within the configuration file, adjust the following settings to suit your environment:

# line 6: change to any title you like
title = **Monitorix**

# line 7: change to your hostname
hostname = **your-hostname**

# line 8: background color of admin site
theme_color = **black**

# line 12: change network units to bps (default is Bytes per/sec)
netstats_in_bps = **y**

# 28-43: change if you need
<httpd_builtin>
        enabled = y
        host =
        port = 8080
        user = nobody
        group = nobody
        log_file = /var/log/monitorix-httpd
        # if enable permission for admin site, add settings
        hosts_deny = **all**
        hosts_allow = **10.0.0.0/24**
        autocheck_responsiveness = y
        <auth>
                # if enable Basic auth, turn to [y]
                enabled = n
                msg = Monitorix: Restricted access
                htpasswd = /var/lib/monitorix/htpasswd
        </auth>
</httpd_builtin>

# line 76: set kind of graphs you'd like to monitor
# Graphs (de)activation
# -----------------------------------------------------------------------------
<graph_enable>
        system          = y
        kern            = y
        proc            = y
        hptemp          = n
        lmsens          = n
        gensens         = n
        ipmi            = n
        ambsens         = n
        nvidia          = n
        disk            = y
.....
.....
  • title: Sets the title displayed in the Monitorix web interface.
  • hostname: Sets the hostname displayed in the Monitorix web interface.
  • theme_color: Defines the background color of the web interface.
  • netstats_in_bps: Changes the network statistics display to bits per second (bps) instead of bytes per second.
  • <httpd_builtin>: Configures the built-in web server. You can restrict access using hosts_deny and hosts_allow.
  • <graph_enable>: Enables or disables specific graphs.

After making the desired changes, save and close the configuration file.

To apply the changes, restart the Monitorix service:

sudo systemctl restart monitorix

Configure Firewall for Monitorix

If you have UFW enabled, you’ll need to allow traffic to port 8080, which Monitorix uses by default:

sudo ufw allow 8080/tcp

Reload the firewall to activate the new rule:

sudo ufw reload

Step 5 – How To Access Monitorix Dashboard?

Access the Monitorix web interface by opening your web browser and navigating to:

http://<server-ip-address>:8080/monitorix

Replace <server-ip-address> with the actual IP address of your Debian 11 server.

Perform Simple Monitoring with Monitorix

Upon accessing the web interface, you’ll be presented with a selection screen. Choose the desired graph and the time period (daily, weekly, monthly, or yearly), and click "ok."

Monitorix 1

You can then view the graphs displaying your server’s performance metrics.

Monitorix graphs

Step 6 – How To Enable Multi-Host Monitoring with Monitorix?

To monitor multiple servers using a single Monitorix instance, you need to configure the <multihost> section in the monitorix.conf file. Open the configuration file:

sudo vi /etc/monitorix/monitorix.conf

Locate the <multihost> section and configure it as follows:

<multihost>
        # enable with [y]
        enabled = **y**
        footer_url = y
        graphs_per_row = 2
        default_option_when_all = "System load"
        # remote host list (display name)
        remotehost_list = **Enter your Node List Here**
        #remotehost_list = server 1, server 2, server 3
        <remotehost_desc>
                # access path of remote hosts
                 **0 = http://node.example.com:8080,/monitorix**
                #0 = http://www.example.com,/monitorix,/monitorix-cgi
                #1 = http://10.0.0.1,/monitorix,/monitorix-cgi
                #2 = http://192.168.0.100:8080,/,/
        </remotehost_desc>
        groups = n
        remotegroup_list = My Group
        <remotegroup_desc>
                0 = server 2, server 3
        </remotegroup_desc>
</multihost>
  • enabled = y: Enables multi-host monitoring.
  • remotehost_list: A comma-separated list of display names for your remote servers.
  • <remotehost_desc>: Defines the access paths to the Monitorix instances on each remote server. The format is index = http://<server-ip>:<port>,/monitorix.

After saving the changes, restart Monitorix:

sudo systemctl restart monitorix

Access your controller node’s web interface (e.g., http://node.example.com:8080,/monitorix) and click on the hostname. You can then select a node from the list and click "ok" to view its graphs.

That’s it! You’ve successfully configured multi-host monitoring with Monitorix on Debian 11.

Conclusion

This tutorial has provided a comprehensive guide to installing and configuring Monitorix on Debian 11. You’ve learned how to perform basic monitoring and enable multi-host monitoring, making it easier to monitor your Linux servers. Monitorix is a simple but powerful monitoring tool for Linux.

Here are some other articles you may find interesting:

Upgrade Linux Kernel on Debian 11

Set up PHP ionCube Loader on Debian 11

Alternative Solutions for Server Monitoring on Debian 11

While Monitorix offers a straightforward and effective monitoring solution, other options provide different features, scalability, and complexity levels. Here are two alternative approaches to server monitoring on Debian 11:

1. Using Prometheus and Grafana:

Prometheus is a powerful, open-source monitoring and alerting toolkit that excels at collecting time-series data. Grafana is a data visualization and dashboarding tool that integrates seamlessly with Prometheus. This combination provides a highly scalable and customizable monitoring solution.

  • Explanation: Prometheus scrapes metrics from configured targets (your Debian 11 server) at regular intervals. These metrics are stored in a time-series database. Grafana then queries Prometheus to visualize the data in customizable dashboards. This setup offers advanced features like alerting, anomaly detection, and the ability to monitor a wide range of applications and services.

  • Why it’s an alternative: Prometheus offers a more robust and scalable solution than Monitorix, especially for larger infrastructures. Its query language, PromQL, is powerful and flexible, allowing for complex data analysis. Grafana’s dashboarding capabilities are far more advanced than Monitorix’s built-in web interface.

  • Code Example (simplified Prometheus configuration for system metrics):

    First, install Prometheus:

    wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
    tar xvfz prometheus-2.45.0.linux-amd64.tar.gz
    cd prometheus-2.45.0.linux-amd64

    Then, create a prometheus.yml file:

    global:
      scrape_interval:     15s
      evaluation_interval: 15s
    
    scrape_configs:
      - job_name: 'system'
        static_configs:
          - targets: ['localhost:9100'] # Assuming node_exporter is running on the same host

    Install node_exporter on your Debian 11 server to expose system metrics to Prometheus:

    wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
    tar xvfz node_exporter-1.7.0.linux-amd64.tar.gz
    cd node_exporter-1.7.0.linux-amd64
    ./node_exporter

    Run Prometheus:

    ./prometheus --config.file=prometheus.yml

    Finally, install Grafana and configure a Prometheus data source to create dashboards.

2. Using Cockpit:

Cockpit is a web-based interface for managing Linux servers. It provides a simple and intuitive way to monitor system resources, configure networking, manage storage, and perform other administrative tasks.

  • Explanation: Cockpit presents a user-friendly interface for interacting with your Debian 11 server. It leverages systemd and other system utilities to gather and display information about the server’s health and performance.

  • Why it’s an alternative: Cockpit is easier to set up and use than Prometheus and Grafana, especially for users who prefer a graphical interface. It provides a comprehensive view of the server’s status and allows you to perform various administrative tasks directly from the web browser.

  • Code Example (Installing Cockpit on Debian 11):

    sudo apt update
    sudo apt install cockpit
    sudo systemctl enable --now cockpit.socket

    Then, access Cockpit by browsing to https://<server-ip-address>:9090. Log in with your system user credentials.

These alternative solutions offer different trade-offs in terms of complexity, scalability, and features. The best choice depends on your specific requirements and technical expertise. Monitorix remains a solid choice for simpler deployments.

Leave a Reply

Your email address will not be published. Required fields are marked *