How to Install Nagios on Manjaro

Nagios is a popular open source monitoring system. In this tutorial, I'll guide you through the process of installing Nagios on a Manjaro system.

Prerequisites

Before we begin, ensure that the following prerequisites are met:

  1. A Manjaro system is up and running.
  2. A user account with sudo privileges is available.
  3. A stable internet connection is available.

Step 1: Install Required Dependencies

First, we need to install some required dependencies using the following command:

sudo pacman -S wget httpd php php-fpm gcc gd librabbitmq

This command installs the following packages:

  1. wget - a command-line tool for downloading files from the internet.
  2. httpd - the Apache HTTP server.
  3. php - the scripting language used by Nagios.
  4. php-fpm - PHP FastCGI Process Manager.
  5. gcc - GNU Compiler Collection for C and C++ programming language.
  6. gd - a library for image creation and manipulation.
  7. librabbitmq - a C library for working with the AMQP protocol.

Step 2: Download and Extract the Nagios Core

We'll now download the Nagios Core from the official Nagios website using the wget command. The latest version of Nagios Core as of writing this tutorial is 4.4.6. You can check for the latest version on the Nagios downloads page.

wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.4.6/nagios-4.4.6.tar.gz

Once the download is complete, extract the downloaded archive using the following command:

tar -xzf nagios-4.4.6.tar.gz

Step 3: Install Nagios Core

Navigate to the extracted Nagios Core directory using the following command:

cd nagios-4.4.6

We'll now configure the Nagios Core by running the following command:

sudo ./configure --with-command-group=nagcmd

This command sets up the Nagios Core with the user and group permissions required to run correctly.

Next, we'll compile and install the Nagios Core using the following commands:

sudo make all

sudo make install

Step 4: Install Nagios Plugins

Nagios Core needs plugins to monitor various services. The Nagios Plugins package contains various plugins that Nagios Core supports.

We'll download and extract the Nagios Plugins package from the Nagios website using the following commands:

cd ~

wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz

tar -xzf nagios-plugins-2.3.3.tar.gz

Once the download and extraction process is complete, navigate to the extracted Nagios Plugins directory and compile and install it using the following commands:

cd nagios-plugins-2.3.3

sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios

sudo make

sudo make install

Step 5: Configure Apache Server

Nagios Core uses the Apache web server to display its web interface. We'll now configure the Apache server to serve the Nagios web interface.

First, we'll create an Apache configuration file for Nagios using the following command:

sudo nano /etc/httpd/conf/extra/nagios.conf

Add the following lines to the configuration file:

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
 
<Directory "/usr/local/nagios/sbin">
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /opt/nagios/etc/htpasswd.users
    Require valid-user
 </Directory>
 
Alias /nagios "/usr/local/nagios/share"
 
<Directory "/usr/local/nagios/share">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /opt/nagios/etc/htpasswd.users
    Require valid-user
</Directory>

Save and close the file.

Next, we'll create a user to access the Nagios web interface using the following command:

sudo htpasswd -c /opt/nagios/etc/htpasswd.users nagiosadmin

Enter a password for the user nagiosadmin when prompted.

Now, we'll set permissions for the Nagios directory using the following commands:

sudo chown -R nagios:nagios /usr/local/nagios

sudo chmod -R 775 /usr/local/nagios

Finally, we'll restart the Apache server using the following command:

sudo systemctl restart httpd

Step 6: Access the Nagios Web Interface

Open a web browser and enter the following URL to access the Nagios web interface:

http://localhost/nagios

Enter the username and password you created in Step 5 to log in.

Conclusion

In this tutorial, we learned how to install Nagios on Manjaro Linux. We installed the required dependencies, downloaded and installed Nagios Core and its plugins, configured the Apache server to serve the Nagios web interface, and accessed the Nagios web interface.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!