Install and Configure OpenNMS on Ubuntu 22.04

This tutorial intends to teach you to Install and Configure OpenNMS Horizon on Ubuntu 22.04.

OpenNMS (Network Management System) is a free and open-source initiative-grade network monitoring and management platform. It is written in Java and is issued under the GNU (General Public License).

There are two types of OpenNMSMeridian and Horizon. When we need stability and long-term support, choose Meridian, which is best for enterprises and businesses. Horizon is used where innovation occurs frequently. It is best for IT-ecosystem, and new technologies monitoring.

You can follow the steps below to Install OpenNMS Horizon on Ubuntu 22.04.

Steps To Install and Configure OpenNMS on Ubuntu 22.04

To complete this guide, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with Ubuntu 22.04.

Install Java on Ubuntu 22.04

Because OpenNMS is written in Java, you must install Java on your server. First, run the system update:

sudo apt update

Now use the command below to install Java on Ubuntu 22.04:

sudo apt install default-jdk -y

Verify your Java installation by checking its version:

java -version
Output
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu222.04)
OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu222.04, mixed mode, sharing)

Set Java Environment Variables

At this point, you need to set the Java home path by using the command below:

sudo export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64

Then, source the /etc/profile file:

sudo source /etc/profile

Set up OpenNMS Horizon on Ubuntu 22.04

The OpenNMS packages aren’t available in the default Ubuntu repository. So you need to add it manually.

Import OpenNMS GPG Key

At this point, you need to use the following command to import the OpenNMS GPG key:

sudo apt-key adv --fetch-keys https://debian.opennms.org/OPENNMS-GPG-KEY

Add OpenNMS Repository

Then, you need to add the OpenNMS repo to your server by using the command below:

sudo add-apt-repository -s 'deb https://debian.opennms.org stable main'

Install OpenNMS on Ubuntu

Now you can easily use the command below to install OpenNMS:

sudo apt -y install opennms

This will install all the dependencies on your server. You need to choose an internet site and set a mail address.

Configure PostgreSQL for OpenNMS on Ubuntu 22.04

When your dependencies and OpenNMS are installed on your server, you need to configure PostgreSQL.

First, verify your PostgreSQL is active and running on Ubuntu 22.04:

sudo systemctl status postgresql
Output
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr>
     Active: active (exited) since Sat 2023-02-25 09:33:55 UTC; 22s ago
    Process: 9700 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 9700 (code=exited, status=0/SUCCESS)
        CPU: 2ms
...

Next, switch to your PostgreSQL user:

sudo -i -u postgres

Create OpenNMS Database and User

At this point, use the following command to create an OpenNMS user:

createuser -P opennms
Enter password for new role: 
Enter it again: 

Then, create the OpenNMS database on Ubuntu 22.04 by using the command below:

createdb -O opennms opennms

Next, protect the default user with a password:

psql -c "ALTER USER postgres WITH PASSWORD 'StrongPassword';"
Output
ALTER ROLE

Exit the PostgreSQL shell:

[postgres@localhost ~]$ exit

Define database credentials in OpenNMS Config File

At this point, you need to define the database credentials in the OpenNMS config file. Open the file with your favorite text editor, here we use the vi editor:

sudo vi /usr/share/opennms/etc/opennms-datasources.xml

Find the lines below and define your database credentials:

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

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

When you are done, save and close the file.

Manage OpenNMS Service on Ubuntu 22.04

First, you need to initialize OpenNMS by adding the Java settings:

sudo /usr/share/opennms/bin/runjava -s
Output
runjava: Looking for an appropriate JVM...
runjava: Checking for an appropriate JVM in JAVA_HOME...
runjava: Found: "/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java" is an appropriate JVM.
runjava: Value of "/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java" stored in configuration file.

Next, initialize the database and detect system libraries in the /usr/share/opennms/bin/install directory:

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

At this point, you can use the following commands to start and enable your OpenNMS service:

# sudo systemctl start opennms
# sudo systemctl enable opennms

Verify your OpenNMS service is active and running on Ubuntu 22.04:

sudo systemctl status opennms
Output
● opennms.service - OpenNMS server
     Loaded: loaded (/lib/systemd/system/opennms.service; enabled; vendor prese>
     Active: active (running) since Sat 2023-02-25 09:43:51 UTC; 10s ago
   Main PID: 11550 (java)
      Tasks: 45 (limit: 4575)
     Memory: 380.1M
        CPU: 34.763s
     CGroup: /system.slice/opennms.service
             ├─11549 bash /usr/share/opennms/bin/opennms -s start
             └─11550 /usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java --add-modu
...

Configure Firewall For OpenNMS

Here we assumed that you have enabled UFW. By default, OpenNMS is listening on port 8980. You have to allow this port through the firewall using the following command:

sudo ufw allow 8980/tcp

Reload the firewall to apply the changes:

sudo ufw reload

Access OpenNMS Web Interface

At this point, you can access OpenNMS Horizon through the Web interface on Ubuntu 22.04 by typing your server’s IP address in your web browser followed by 8980/opennms:

http://IP_Address:8980/opennms

You will see the OpenNMS horizon login screen. Enter admin as the username and password and click Login.

OpenNMS Login
OpenNMS Login

Then, you should see the OpenNMS Horizon dashboard on Ubuntu 22.04.

OpenNMS Dashboard Ubuntu 22.04
OpenNMS Dashboard

You can now change the password to a preferred one by navigating to admin → Change Password.

Change default Admin Password OpenNMS
Change default Admin Password
Add New Admin Password for OpenNMS
Add New Admin Password

How To Monitor Systems with OpenNMS

To be able to monitor systems, you need to add them to OpenNMS. Begin by clicking on the “+“ icon as shown below.

Add node to OpenNMS
Add node

Enter the required details such as requisitionIP Address, and Node Label, and click Provision.

OpenNMS Node Credentials
Node Credentials

After the node has been added, it will appear under Info → Nodes.

You can now view graphs and create alerts for the device.

Monitor Devices with OpenNMS Ubuntu 22.04
Monitor Devices

For more information, you can visit OpenNMS Documentation.

Conclusion

At this point, you have learned to Install and Configure OpenNMS Horizon on Ubuntu 22.04.

Hope you enjoy it. You may be like these articles on the Orcacore website:

Set up OpenJDK 19 on Ubuntu 22.04

Install Nginx with Brotli Compression on Ubuntu 22.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!