Sunday, April 14, 2024
HomeHow toHow to Install OpenNMS Monitoring Solution on Ubuntu 22.04

How to Install OpenNMS Monitoring Solution on Ubuntu 22.04

OpeNNMS is free and open-source network monitoring and network management. It is an enterprise-grade network monitoring platform that visualizes and monitors everything on both local networks and remote networks. OpenNMS is a fully open-source solution for network monitoring and management, it is published under the AGPLv3 license.

OpenNMS is a scalable network monitoring platform allowing you to monitor tens of thousands of networks via distributed and tiered systems. Also, OpenNMS is a flexible monitoring platform that easily integrates with your core business and third-party extensions.

OpenNMS has multiple components listed below:

  1. OpenNMS Horizon – bundles of three main components: Core (the main component of Horizon), Minion (used for remote distributed monitoring), and Sentinel (for scalability).
  2. Helm – customized dashboard for OpenNMS.
  3. Architecture for Learning Enabled Correlation (ALEC) (alarm triage).
  4. Provisioning Integration Server (PRIS) (extracted data integration).

This guide shows you how to install OpenNMS Monitoring Solution with a PostgreSQL database server and Nginx Reverse Proxy on an Ubuntu 22.04 server. Also, this guide will show you the installation of Java OpenJDK, the basic configuration of the PostgreSQL database server, and the Nginx web server.

Prerequisites

First of all, you will need the following requirements to finish this guide:

  • An Ubuntu 22.04 server – This example uses the Ubuntu server with hostname ‘opennms-server’ and the memory is 4GB.
  • A non-root user with sudo/root administrator privileges.\
  • A domain name or local domain will be used to run OpenNMS.

Installing Java OpenJDK

The OPneNMS monitoring solution is a monitoring tool mainly written in Java. At the time of this writing, the latest version of OpenNMS supports at minimum Java 11. The default Ubuntu 22.04 repository provides the Java OpenJDK 11 that you can easily install via APT.

Before installing Java, run the following apt command to update and refresh your package index.

sudo apt update

Now install Java OpenJDK 11 via the apt command below. The default Java version for Ubuntu 22.04 system is Java OpenJDK 11, which is suitable for the OpenNMS installation.

sudo apt install default-jdk

When prompted, input y to confirm and press ENTER. The Java OpenJDK installation will begin.

After Java OpenJDK is installed, run the below command to verify the installed version of Java. You should get Java OpenJDK 1.11 installed on your Ubuntu system.

java -version

With Java OpenJDK installed, move to the PostgreSQL database installation.

Installing and Configuring PostgreSQL Server

PostgreSQL is a high-performance RDMS (Relational Database Management System). The OpenNMS supports only PostgreSQL as the database backend. At the time of this writing, the OpenNMS supports PostgreSQL v10.x-14.x.

You’ll now install and configure the PostgreSQL database v14 on an Ubuntu server. By default, the Ubuntu repository provides multiple versions of PostgreSQL, and you will install PostgreSQL 14.x for the OpenNMS deployment.

Run the below apt command to install PostgreSQL 14.

sudo apt install postgresql-14

When prompted for confirmation, input y and press ENTER to proceed.

After the PostgreSQL package is installed, run the following systemctl command to verify the PostgreSQL service and make sure that the service is running and enabled.

sudo systemctl is-enabled postgresql
sudo systemctl status postgresql

You’ll then see that the PostgreSQL service is enabled and will be run automatically upon bootup. And the status of the PostgreSQL service is running.

Now that the PostgreSQL database is running, you will go over the database and user creation for the OpenNMS. You’ll also set up the password for the default PostgreSQL user ‘postgres‘.

Run the below command to create a new PostgreSQL user ‘opennms’. When prompted for the password, input the new password for the ‘opennms‘ user and repeat it.

sudo -u postgres createuser -P opennms

Next, create a new database database ‘opennms‘ with the owner ‘opennms‘ via the following command.

sudo -u postgres createdb -O opennms opennms

Lastly, change the password of the ‘postgres‘ user via the following command. And be sure to change it with a new strong password.

sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '5up3rp4ssw0rd';"

Now that you have java OpenJDK and PostgreSQL installed, you’re ready to install OpenNMS.

Installing and Configuring OpenNMS

You’ve installed Java OpenJDK and PostgreSQL database, also you’ve created a new database and user for OpenNMS, and configured the default password for PostgreSQL ‘postgres’ user. You’ll then start installing and configuring the OpenNMS.

In this section, you will install OpenNMS via the official OpenNMS repository. Then, you will set up OpenNMS with the PostgreSQL database, set up the Java environment, initialize database schema, detect system libraries, and allow the OpenNMS to run in privileged ports.

First, run the following command to add the OpenNMS GPG key and repository.

sudo apt-key adv --fetch-keys https://debian.opennms.org/OPENNMS-GPG-KEY
sudo add-apt-repository -s 'deb https://debian.opennms.org stable main'

When prompted, press ENTER to confirm and add the OpenNMS repository.

Now install the OpenNMS package with additional R packages via the apt command below.

sudo apt install opennms r-recommended

When prompted for the confirmation, input y to confirm and press ENTER to proceed.

Next, run the below apt command to disable the OpenNMS package from auto-update. The OpenNMS requires manual steps and configurations when upgrading to a new version, so you must upgrade it manually to prevent errors during/after upgrades.

sudo apt-mark hold libopennms-java \
libopennmsdeps-java \
opennms-common \
opennms-db

Now that the OpenNMS is installed, you can verify the OpenNMS installation directory ‘/usr/share/opennms‘ via the command below. Also, any changes related to OpenNMS should be applied to files under the ‘/usr/share/opennms‘ directory.

sudo apt install tree -y
sudo tree /usr/share/opennms -L 1

You could see a list of directories and files for the OpenNMS package.

Next, you will set up the database configuration for OpenNMS. Open the file ‘/usr/share/opennms/etc/opennms-datasources.xml‘ using the following nano editor command. The ‘sudo -u opennms command..‘ indicates that you’re running the command as the ‘opennms‘ user, and not the root user.

sudo -u opennms nano /usr/share/opennms/etc/opennms-datasources.xml

Change the ‘jdbc-data-source’ for the ‘opennms‘ should be using the details of the ‘opennms‘ database and user. And for ‘opennms-admin‘, you should be using the ‘postgres‘ PostgreSQL admin user.

<jdbc-data-source name="opennms"
                    database-name="opennms"
                    class-name="org.postgresql.Driver"
                    url="jdbc:postgresql://localhost:5432/opennms"
                    user-name="opennms"
                    password="p4ssw0rd" />

<jdbc-data-source name="opennms-admin"
                    database-name="template1"
                    class-name="org.postgresql.Driver"
                    url="jdbc:postgresql://localhost:5432/template1"
                    user-name="postgres"
                    password="5up3rp4ssw0rd" />

Save the file and exit the editor when you are finished.

Now run the following command to detect the Java environment on your system, which will be stored permanently in the configuration file ‘/usr/share/opennms/etc/java.conf‘.

sudo -u opennms /usr/share/opennms/bin/runjava -s

After that, run the below command to initialize the database and detects system libraries for the OpenNMS. Libraries for the OpenNMS will be listed in the file ‘/opt/opennms/etc/libraries.properties‘.

sudo -u opennms /usr/share/opennms/bin/install -dis

Next, edit the OpenNMS service file via the following systemctl command. You shuld get the default EDITOR on your system.

sudo systemctl edit --full opennms.service

Add the following configuration to the ‘[Service]‘ section. This allows the OpenNMS service to run and bind in privileged ports (ports 1-1024).

[Service]
...
AmbientCapabilities=CAP_NET_RAW CAP_NET_BIND_SERVICE

Save the file and exit the editor when you are finished.

After modifying the OpenNMS service file, run the following command to reload the systemd manager, restart and enable the OpenNMS service.

sudo systemctl daemon-reload
sudo systemctl restart opennms
sudo systemctl enable opennms

Now that the OpenNMS service is up and running with new configurations, you’ll then verify the OpenNMS service via the systemctl command below.

sudo systemctl is-enabled opennms
sudo systemctl status opennms

The output – The OpenNMS service is enabled and will be run automatically upon system bootup. And the OpenNMS service currently is running.

At this point, you have finished the installation and configuration of OpenNMS. But, you will run the OpenNMS with Nginx reverse proxy. Read on to learn how to set up Nginx as a reverse proxy for OpenNMS.

Installing Nginx as a Reverse Proxy for OpenNMS

Now that you have OpenNMS running on the default port ‘8980’, you’ll then install and configure Nginx as a reverse proxy for OpenNMS.

Run the following apt command to install the Nginx package to your system.

sudo apt install nginx

Input y when prompted, then press ENTER to proceed. And the installation will begin.

Next, verify the Nginx service with the following systemctl command.

sudo systemctl is-enabled nginx
sudo systemctl status nginx

You should see the Nginx service is enabled and will be run automatically upon the bootup. Also, the Nginx service is automatically started after the installation is finished.

After Nginx is installed, create a new Nginx server block ‘/etc/nginx/sites-available/opennms.conf‘ using the following nano editor command.

sudo nano /etc/nginx/sites-available/opennms.conf

Add the following configuration to the file. Be sure to change the domain name with your domain.

server {
    listen 80;
    server_name opennms.hwdomain.io;
    access_log /var/log/nginx/opennms.access.log;
    error_log /var/log/nginx/opennms.error.log;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-OpenNMS-Server-URL https://opennms.hwdomain.io/;
        proxy_pass http://localhost:8980;
    }

}

Save the file and exit the editor when you are finished.

Next, activate the ‘opennms.conf‘ server block and verify the Nginx configuration to ensure that you have the correct configuration.

sudo ln -s /etc/nginx/sites-available/opennms.conf /etc/nginx/sites-enabled/
sudo nginx -t

If you see the output message such as ‘test successful – syntax ok‘, that means that your Nginx configuration is correct.

Now restart the Nginx service to apply the new server block configuration.

sudo systemctl restart nginx

Now that the Nginx is running as a reverse proxy for the OpenNMS, you’ll then go over the UFW firewall configuration and open some ports for some services.

Setting up UFW Firewall

After configured Nginx reverse proxy, you’ll then set up the UFW on your OpenNMS server. You’ll be running the OpenNMS Monitoring Tool with the UFW enabled, so you must add some ports that will be used for OpenNMS.

Run the following apt command to install UFW on your system.

sudo apt install ufw -y

After UFW installed, run the below command to add the OpenSSH service. Then, start and enable the UFW service.

sudo ufw allow OpenSSH
sudo ufw enable

When prompted, input y to confirm and press ENTER to proceed. Now the UFW will be running and it’s enabled and will be run automatically upon the bootup.

Next, add a new rule to allow traffics to the Nginx web server.

sudo ufw allow "Nginx Full"

After that, open the file ‘/etc/ufw/before.rules‘ using the following nano editor command.

sudo nano /etc/ufw/before.rules

Add the following configuration before the ‘*filter’ section. This will enable NAT and reroute/forward traffic from 62/udp to 10162/udp.

*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -p udp --dport 162 -j REDIRECT --to-port 10162
COMMIT

Save the file and exit the editor when you are done.

Now add the new rule to allow both ports 62/udp to 10162/udp.

sudo ufw allow in 162/udp
sudo ufw allow in 10162/udp

Reload the UFW to apply changes and verify the status of UFW via the following command.

sudo ufw reload
sudo ufw status

So far, you’ve finished the installation and configuration of OpenNMS with package dependnencies such as PostgreSQL database, and Nginx web server, and also configured the UFW. For the final step, you’ll access the OpenNMS installation via a web browser and set up the admin user for OpenNMS.

Open your web browser and visit the domain name of your OpenNMS installation (i.e: http://opennms.hwdomain.io). You should see the login page of the OpenNMS Monitoring Tool.

Input the default user/password ‘admin/admin‘ and click ‘Log In‘.

You’ll then see the OpenNMS administration dashboard.

After logging in to OpenNMS via the default user/password ‘admin/admin‘, you’ll then change the default username and password for your OpenNMS installation.

On the top menu bar, click menu ‘Admin‘ and select ‘Change Password‘.

Now input the old password ‘admin’ and input the new OpenNMS password and repeat the password. Then, click ‘Submit‘ to apply.

You’ve now finished the OpenNMS configuration.

Conclusion

You now have the OpenNMS, a high-scalable and customizable monitoring tool, installed on your Ubuntu 22.04 server. You also have configured the PostgreSQL database server installed and the Nginx web server configured as a reverse proxy for the OpenNMS. With OpenNMS fully configured, you can now add a new host to monitor via SNMP protocol, set up distributed monitoring via OpenNMS Minion, scale the OpenNMS via Sentinel, and start customizing the dashboard via Helm.

If you want to run OpenNMS on large deployments, check out the official documentation.


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here


spot_img

Most Popular