How to Install OpenNMS Horizon Network Monitoring System on Debian 11

OpenNMS is a free, open-source, and one of the most powerful network monitoring and network management platforms used for monitoring remote devices from a central location. It supports many functionalities including, Provisioning, Services Monitoring, Event managing, chart support, and more. OpenNMS uses SNMP and JMX and gathers information from remote systems. It runs on Linux and Windows operating systems and provides a web-based interface to easy monitoring.

In this tutorial, I will show you how to install OpenNMS on Debian 11.

Prerequisites

  • A server running Debian 11.
  • A valid domain name pointed with your server IP.
  • A root password is configured on the server.

Install Java on Debian 11

OpenNMS is a Java-based application. So Java must be installed on your server. If not installed you can install it by running the following command:

apt-get install default-jdk -y

Once the Java is installed, verify the Java version using the command below:

java --version

You will get the Java version in the following output:

openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.13+8-post-Debian-1deb11u1, mixed mode, sharing)

Install OpenNMS on Debian 11

By default, OpenNMS is not included in the Debian 11 main repository. So you will need to add the OpenNMS official repository to the APT.

First, install all the required dependencies using the following command:

apt-get install curl gnupg2 wget -y

Once all the packages are installed, create an OpenNMS repository file using the command below:

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 then import the GPG key with the following command:

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

You will get the following output:

Connecting to debian.opennms.org (debian.opennms.org)|3.214.84.83|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1335 (1.3K)
Saving to: ‘STDOUT’

-                                   100%[=================================================================>]   1.30K  --.-KB/s    in 0s      

2021-11-28 07:58:07 (16.0 MB/s) - written to stdout [1335/1335]

OK

Next, update the repository cache and install the OpenNMS with the following command:

apt-get update -y
apt-get install opennms -y

You will get the following error during the installation:

Failed to install iplike into the template1 or opennms databases. See /tmp/install_iplike.log for details. To skip this step and install manually, set the         
environment variable SKIP_IPLIKE_INSTALL before installing this package. To install iplike into your database, use the /usr/sbin/install_iplike.sh script.  See    
`install_iplike.sh -h` for more details.

To resolve this error, you will need to create a database and user for OpenNMS in PostgreSQL.

Create a Database in PostgreSQL

PostgreSQL server installed automatically during the OpenNMS installation process.

First, start the PostgreSQL service using the following command:

systemctl start postgresql

Next, connect to the PostgreSQL instance using the following command:

su - postgres

Once you are connected, create a user for OpenNMS and set a password using the following command:

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

Next, create a database for OpenNMS and set a password for postgres user:

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

Next, exit from the PostgreSQL shell with the following command:

exit

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

Configure OpenNMS

Next, you will need to edit the OpenNMS data source file and define your database credentials:

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

Define your database credentials as shown below:

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

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

Save and close the file when you are finished then run the following command to detect of Java environment:

sudo -u opennms /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: "/etc/alternatives/java"...
runjava: Did not find an appropriate JVM in the PATH: "/etc/alternatives/java"
runjava: Searching for a good JVM...
runjava: Found a good JVM in "/usr/lib/jvm/java-11-openjdk-amd64/bin/java".
runjava: Value of "/usr/lib/jvm/java-11-openjdk-amd64/bin/java" stored in configuration file.

Next, run the following command to complete the OpenNMS setup:

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

You will get the following output:

Finished in 0 seconds

Processing RemotePollerServiceConfigMigratorOffline: Remove deprecated RemotePoller service entry from service-configuration.xml, see NMS-12684
- 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!

Start OpenNMS Service

After setting up OpenNMS, start the OpenNMS service and enable it to start at system reboot using the following command:

systemctl start opennms
systemctl enable opennms

You can verify the OpenNMS status using the following command:

systemctl status opennms

You will get the following output:

? opennms.service - OpenNMS server
     Loaded: loaded (/lib/systemd/system/opennms.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-11-28 08:10:51 UTC; 16s ago
    Process: 22990 ExecStart=/usr/share/opennms/bin/opennms -s start (code=exited, status=0/SUCCESS)
   Main PID: 24106 (java)
      Tasks: 68 (limit: 4679)
     Memory: 559.2M
        CPU: 48.083s
     CGroup: /system.slice/opennms.service
             ??24105 bash /usr/share/opennms/bin/opennms -s start
             ??24106 /usr/lib/jvm/java-11-openjdk-amd64/bin/java --add-modules=java.base,java.compiler,java.datatransfer,java.desktop,java.in>

Nov 28 08:11:02 debian11 opennms[24106]: [DEBUG] System property 'opennms.library.jicmp' set to '/usr/lib/jni/libjicmp.so.  Attempting to loa>
Nov 28 08:11:02 debian11 opennms[24106]: [INFO] Successfully loaded jicmp library.
Nov 28 08:11:02 debian11 opennms[24106]: [DEBUG] System property 'opennms.library.jicmp6' set to '/usr/lib/jni/libjicmp6.so.  Attempting to l>
Nov 28 08:11:02 debian11 opennms[24106]: [INFO] Successfully loaded jicmp6 library.
Nov 28 08:11:02 debian11 opennms[24106]: [DEBUG] System property 'opennms.library.jicmp' set to '/usr/lib/jni/libjicmp.so.  Attempting to loa>
Nov 28 08:11:02 debian11 opennms[24106]: [INFO] Successfully loaded jicmp library.
Nov 28 08:11:02 debian11 opennms[24106]: [DEBUG] System property 'opennms.library.jicmp6' set to '/usr/lib/jni/libjicmp6.so.  Attempting to l>
Nov 28 08:11:02 debian11 opennms[24106]: [INFO] Successfully loaded jicmp6 library.
Nov 28 08:11:07 debian11 opennms[24106]: Nov 28, 2021 8:11:07 AM org.hibernate.validator.internal.util.Version 
Nov 28 08:11:07 debian11 opennms[24106]: INFO: HV000001: Hibernate Validator 4.3.2.Final

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

ss -antpl | grep 8980

You will get the following output:

LISTEN 0      50                      *:8980             *:*    users:(("java",pid=24106,fd=1046))     

Configure Nginx as a Reverse Proxy for OpenNMS

Next, it is recommended to install and configure the Nginx as a reverse proxy for OpenNMS. First, install the Nginx server with the following command:

apt-get install nginx -y

Once the Nginx is installed, create an Nginx virtual host configuration file:

nano /etc/nginx/conf.d/opennms.conf

Add the following configuration:

server {
  listen 80;
  server_name opennms.example.com;
    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://nms.hacc.edu/;
    proxy_pass http://server-ip:8980;

  }
}

Save and close the file then verify the Nginx for any syntax configuration error:

nginx -t

You will get the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Next, restart the Nginx service to apply the changes:

systemctl restart nginx

To check the Nginx running status, run the following command:

systemctl status nginx

You should see the following output:

? nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-11-28 08:17:14 UTC; 6s ago
       Docs: man:nginx(8)
    Process: 25964 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 25965 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 25967 (nginx)
      Tasks: 3 (limit: 4679)
     Memory: 3.2M
        CPU: 53ms
     CGroup: /system.slice/nginx.service
             ??25967 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??25968 nginx: worker process
             ??25969 nginx: worker process

Nov 28 08:17:14 debian11 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 28 08:17:14 debian11 systemd[1]: Started A high performance web server and a reverse proxy server.

Access OpenNMS Dashboard

Now, open your web browser and access the OpenNMS web interface using the URL http://opennms.example.com. You should see the OpenNMS login page:

OpenNMS Horizon

Provide default username and password as admin and click on the Login button. You should see the OpenNMS dashboard on the following screen:

Horizon Dashboard

Now, click on the admin > Change Password to change the default admin password as shown below:

Change password

Change your default password and click on the Submit button. You should see the following screen:

Password changed

Conclusion

Congratulations! you have successfully installed OpenNMS with Nginx as a reverse proxy on Debian 11 server. You can now add the remote devices to OpenNMS and start monitoring them from the web browser. Feel free to ask me if you have any questions.

Share this page:

Suggested articles

0 Comment(s)

Add comment