OpenNMS is a free and web-based network management and monitoring solution developed and supported by a community of users. It is written in Java and collects important information from local and network hosts via the SNMP protocol. It is cross-platform and can be installed on Linux and Windows operating systems. It has a simple and user-friendly web interface allows you to monitor network traffic via a web browser. It has many useful features, such as service monitoring, event management, charting support, performance measurement, and much more.

This article will show you how to install the OpenNMS network monitoring program on Ubuntu 22.04.

Requirements

  • A server running Ubuntu 22.04.
  • A root password is set up on the server.

First steps

Before you start, you must update your system to the latest version. You can do this with the following command:

apt-get update -y
apt-get upgrade -y

After you have updated all packages, install the Java JDK and other dependencies by running the following command:

apt-get install default-jdk gnupg2 curl wget -y

Next, check the Java version with the following command:

java -version

You should see the Java version in the following output:

openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16 8-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.16 8-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)

When you are done, you can proceed to the next step.

Add OpenNMS repository

By default, the OpenNMS package is not included in the default Ubuntu 22.04 repository. Therefore, you need to add the OpenNMS repository to the APT. You can add it with the following command:

nano /etc/apt/sources.list.d/opennms.list

Add the following lines:

deb https://debian.opennms.org stable main
deb-src https://debian.opennms.org stable main

Save and close the file and then add the GPG key with the following command:

wget -O - https://debian.opennms.org/OPENNMS-GPG-KEY | apt-key add -

Once the repository and key are added, refresh the repository cache with the following command:

apt-get update -y

When you’re done, you can proceed to the next step.

Install OpenNMS on Ubuntu 22.04

You can now run the following command to install the OpenNMS package on your system.

apt-get install opennms -y

During the installation, you will be prompted to select the email configuration:

How to Install OpenNMS Network Monitoring Program on Ubuntu linux ubuntu

Select your preferred option and click “Ok”. You will be prompted to enter a system email name:

How to Install OpenNMS Network Monitoring Program on Ubuntu linux ubuntu

Enter your system email name and click the Ok button to complete the installation.

The above command will also automatically install the PostgreSQL server package. You can start it with the following command:

systemctl start postgresql

Next, check the status of PostgreSQL with the following command:

systemctl status postgresql

You will get the following output:,/p>

? postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Mon 2022-08-15 02:26:52 UTC; 1min 57s ago
   Main PID: 25237 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Aug 15 02:26:52 ubuntu2204 systemd[1]: Starting PostgreSQL RDBMS...
Aug 15 02:26:52 ubuntu2204 systemd[1]: Finished PostgreSQL RDBMS.

Once you are done, you can proceed to the next step.

Create a PostgreSQL database

Next, you need to create a database and a user for OpenNMS. First, log in to PostgreSQL with the following command:

su - postgres

Once you are logged in, create a user with the following command:

createuser opennms

Next, set a password for the opennms user with the following command:

psql -c "ALTER USER opennms WITH PASSWORD 'opennms';"

Next, create a database for OpenNMS with the following command:

createdb -O opennms opennms

Next, set a password for the Postgres user with the following command:

psql -c "ALTER USER postgres WITH PASSWORD 'securepassword';"

Exit the PostgreSQL shell with the following command:

exit

Once you’re done, you can proceed to the next step.

Configure OpenNMS

Next, you need to edit the OpenNMS datasource file and define your database settings.

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

Change the following lines according to your database settings:



Save and close the file when you are done.

Initializing and starting OpenNMS

First you need to integrate OpenNMS with Java. You can do this by executing the following command:

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

You will get the following output:

runjava: Looking for an appropriate JVM...
runjava: Checking for an appropriate JVM in JAVA_HOME...
runjava: Skipping... JAVA_HOME not set.
runjava: Checking JVM in the PATH: "https://vitux.com/etc/alternatives/java"...
runjava: Did not find an appropriate JVM in the PATH: "https://vitux.com/etc/alternatives/java"
runjava: Searching for a good JVM...
runjava: Found a good JVM in "https://vitux.com/usr/lib/jvm/java-11-openjdk-amd64/bin/java".
runjava: Value of "https://vitux.com/usr/lib/jvm/java-11-openjdk-amd64/bin/java" stored in configuration file.

Next, initialize the database and detect the system libraries with the following command:,/p>

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

You will receive the following output:

- Running pre-execution phase
  Creating backup of /usr/share/opennms/etc/service-configuration.xml
    Zipping /usr/share/opennms/etc/service-configuration.xml
- Running execution phase
  Current configuration: 32 services.
  A service entry named 'OpenNMS:Name=PerspectivePoller' already exists.
  Final configuration: 32 services.
- Saving the execution state
- Running post-execution phase
  Removing backup /usr/share/opennms/etc/service-configuration.xml.zip

Finished in 0 seconds


Upgrade completed successfully!

Finally, start OpenNMS and activate it so that it is started when the system is restarted:

systemctl start opennms
systemctl enable opennms

You can also check the status of OpenNMS with the following command:

systemctl status opennms

You should see the following output:

? opennms.service - OpenNMS server
     Loaded: loaded (/lib/systemd/system/opennms.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-08-15 02:32:40 UTC; 3s ago
    Process: 26413 ExecStart=/usr/share/opennms/bin/opennms -s start (code=exited, status=0/SUCCESS)
   Main PID: 27375 (java)
      Tasks: 16 (limit: 2242)
     Memory: 98.3M
        CPU: 12.825s
     CGroup: /system.slice/opennms.service
             ??27374 bash /usr/share/opennms/bin/opennms -s start
             ??27375 /usr/lib/jvm/java-11-openjdk-amd64/bin/java --add-modules=java.base,java.compiler,java.datatransfer,java.desktop,java.in>

Aug 15 02:32:39 ubuntu2204 opennms[26413]: real-time priority                  (-r) 0
Aug 15 02:32:39 ubuntu2204 opennms[26413]: stack size                  (kbytes, -s) 8192
Aug 15 02:32:39 ubuntu2204 opennms[26413]: cpu time                   (seconds, -t) unlimited
Aug 15 02:32:39 ubuntu2204 opennms[26413]: max user processes                  (-u) 7473
Aug 15 02:32:39 ubuntu2204 opennms[26413]: virtual memory              (kbytes, -v) unlimited
Aug 15 02:32:39 ubuntu2204 opennms[26413]: file locks                          (-x) unlimited
Aug 15 02:32:39 ubuntu2204 opennms[26413]: (not waiting for startup) ok
Aug 15 02:32:39 ubuntu2204 systemd[1]: opennms.service: Can't open PID file /run/opennms/opennms.pid (yet?) after start: Operation not permit>
Aug 15 02:32:40 ubuntu2204 systemd[1]: opennms.service: Supervising process 27375 which is not our child. We'll most likely not notice when i>
Aug 15 02:32:40 ubuntu2204 systemd[1]: Started OpenNMS server.

At this point, OpenNMS is started and listening on port 8980 You can check this with the following command:

ss -antpl | grep 8980

You will get the following output:

LISTEN 0      50                      *:8980             *:*    users:(("java",pid=27375,fd=1161))                                                                                                                                                                                                                                                                              

Access OpenNMS Web Interface

Now open your web browser and call up the OpenNMS web console at the URL http://your-server-ip:8980/opennms. You should see the OpenNMS login page:

How to Install OpenNMS Network Monitoring Program on Ubuntu linux ubuntu

Enter the default username and password admin/admin and click the Login button. On the following page you should see the OpenNMS dashboard:

How to Install OpenNMS Network Monitoring Program on Ubuntu linux ubuntu

Conclusion

Congratulations! You have successfully installed and configured OpenNMS on Ubuntu 22.04. Now, you can implement OpenNMS in your organization and monitor all hosts and servers via the OpenNMS dashboard.