Install and Configure OpenNMS on Ubuntu 22.04: Efficient Steps

Posted on

Install and Configure OpenNMS on Ubuntu 22.04: Efficient Steps

Install and Configure OpenNMS on Ubuntu 22.04: Efficient Steps

This tutorial intends to teach you to Install and Configure OpenNMS 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 on the Orcacore website to Install OpenNMS Horizon 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.

1. Install Java For OpenNMS Horizon Setup

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
**<mark>Output</mark>**
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

2. 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.

3. 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
**<mark>Output</mark>**
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr>
     Active: **<mark>active</mark>** (**<mark>exited</mark>**) 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 <mark>opennms</mark>
Enter password for new role:
Enter it again:

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

createdb -O <mark>opennms opennms</mark>

Next, protect the default user with a password:

psql -c "ALTER USER <mark>postgres</mark> WITH PASSWORD '<mark>StrongPassword</mark>';"
**<mark>Output</mark>**
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:

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

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

When you are done, save and close the file.

4. 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
**<mark>Output</mark>**
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
**<mark>Output</mark>**
● opennms.service - OpenNMS server
     Loaded: loaded (/lib/systemd/system/opennms.service; enabled; vendor prese>
     Active: **<mark>active</mark>** (**<mark>running</mark>**) 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
...

5. 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

6. 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://<mark>IP_Address</mark>: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

7. 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 requisition, IP Address, and Node Label, and click Provision.

OpenNMS Node Credentials
Node Credentials

After the node has been added, it will appear under InfoNodes.

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. OpenNMS Horizon is a free tool that helps you with network monitoring.

Hope you enjoy it. You may also like these articles:

Set up OpenJDK 19 on Ubuntu 22.04

Install Nginx with Brotli Compression on Ubuntu 22.04

Sublime Text Editor Setup Ubuntu 22.04

Disabling NTP Network Time Synchronization on Ubuntu

Change Ubuntu File Permissions Recursively

Uninstall PPA Repository From Ubuntu

Resolve failed to bring up eth0 Ubuntu

Install Sniffnet on Ubuntu 22.04

Alternative Solutions for Network Monitoring on Ubuntu 22.04

While OpenNMS is a powerful and comprehensive solution, there are alternative approaches for network monitoring on Ubuntu 22.04, each with its own strengths and weaknesses. Here are two distinct alternatives:

1. Using Zabbix for Network Monitoring

Zabbix is another open-source monitoring solution that rivals OpenNMS in features and capabilities. It offers a robust set of monitoring options, including network devices, servers, virtual machines, and cloud services. Zabbix employs agents on monitored hosts for in-depth data collection, but it can also use agentless monitoring techniques like SNMP, SSH, and Telnet.

Why choose Zabbix over OpenNMS?

  • Lower Resource Consumption (Potentially): Zabbix can sometimes have a lighter footprint than OpenNMS, making it suitable for environments with resource constraints.
  • Extensive Template Library: Zabbix boasts a large library of pre-built templates for monitoring various devices and services, simplifying the setup process.
  • User-Friendly Web Interface: Many users find the Zabbix web interface more intuitive and easier to navigate compared to OpenNMS.
  • Active Community Support: Zabbix has a thriving community, offering ample support, documentation, and community-contributed templates.

How to install and configure Zabbix on Ubuntu 22.04:

  1. Install the Zabbix repository:

    sudo apt update
    sudo apt install gnupg
    wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu22.04_all.deb
    sudo dpkg -i zabbix-release_6.0-1+ubuntu22.04_all.deb
    sudo apt update
  2. Install Zabbix Server, Frontend, and Agent:

    sudo apt install zabbix-server-pgsql zabbix-frontend-php zabbix-agent
  3. Create the Zabbix database:

    sudo -u postgres createuser --superuser zabbix
    sudo -u postgres createdb -O zabbix zabbix
    sudo -u postgres psql -d zabbix -f /usr/share/doc/zabbix-server-pgsql/create.sql.gz
  4. Configure the Zabbix Server to use the database:
    Edit /etc/zabbix/zabbix_server.conf and set the following parameters:

    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=<zabbix_database_password>
  5. Configure the PHP settings for the Zabbix Frontend:
    Edit /etc/zabbix/apache.conf and uncomment/set the following parameters:

    php_value max_execution_time 300
    php_value memory_limit 128M
    php_value post_max_size 16M
    php_value upload_max_filesize 2M
    php_value max_input_time 300
    php_value date.timezone Europe/Your_Timezone  (e.g., Europe/London)
  6. Restart Apache and Zabbix Server and Agent:

    sudo systemctl restart apache2
    sudo systemctl restart zabbix-server
    sudo systemctl restart zabbix-agent
  7. Access the Zabbix web interface:

    Open your web browser and navigate to http://<your_server_ip>/zabbix. The default credentials are Admin/zabbix.

2. Using Prometheus and Grafana for Monitoring

Prometheus is a powerful open-source monitoring solution primarily designed for time-series data. It excels at collecting and storing metrics. Grafana is a data visualization tool that integrates seamlessly with Prometheus to create dashboards and visualizations from the collected metrics. This combination is particularly well-suited for monitoring dynamic and containerized environments.

Why choose Prometheus and Grafana over OpenNMS?

  • Excellent for Containerized Environments: Prometheus is a natural fit for monitoring Docker, Kubernetes, and other container technologies.
  • Scalability and Performance: Prometheus is designed to handle large volumes of time-series data efficiently.
  • Flexible Querying: PromQL, Prometheus’s query language, is highly expressive and allows for complex data analysis.
  • Modern Dashboards: Grafana provides visually appealing and customizable dashboards, making it easy to understand monitoring data.

How to install and configure Prometheus and Grafana on Ubuntu 22.04:

  1. Install Prometheus:

    • Download the latest Prometheus binary from the official website.

    • Extract the archive: tar xvf prometheus-*.tar.gz

    • Move the binaries to /usr/local/bin: sudo mv prometheus-*/prometheus /usr/local/bin/ and sudo mv prometheus-*/promtool /usr/local/bin/

    • Create user and group for Prometheus: sudo groupadd prometheus and sudo useradd -g prometheus -M -r prometheus

    • Create directories for data and configuration: sudo mkdir /etc/prometheus and sudo mkdir /var/lib/prometheus

    • Set ownership: sudo chown prometheus:prometheus /etc/prometheus and sudo chown prometheus:prometheus /var/lib/prometheus

    • Create a Prometheus configuration file /etc/prometheus/prometheus.yml. A basic configuration might look like this:

      global:
        scrape_interval:     15s
        evaluation_interval: 15s
      
      scrape_configs:
        - job_name: 'prometheus'
          static_configs:
            - targets: ['localhost:9090']
    • Create a systemd service file /etc/systemd/system/prometheus.service:

      [Unit]
      Description=Prometheus
      Wants=network-online.target
      After=network-online.target
      
      [Service]
      User=prometheus
      Group=prometheus
      Type=simple
      ExecStart=/usr/local/bin/prometheus 
          --config.file=/etc/prometheus/prometheus.yml 
          --storage.tsdb.path=/var/lib/prometheus/ 
          --web.console.enable-admin-api
      
      [Install]
      WantedBy=multi-user.target
    • Start and enable the Prometheus service: sudo systemctl start prometheus and sudo systemctl enable prometheus

  2. Install Grafana:

    • Install the Grafana repository:

      sudo apt-get install -y apt-transport-https software-properties-common wget
      wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
      echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
      sudo apt-get update
    • Install Grafana: sudo apt-get install grafana
    • Start and enable the Grafana service: sudo systemctl start grafana-server and sudo systemctl enable grafana-server
  3. Configure Grafana to use Prometheus as a data source:

    • Open your web browser and navigate to http://<your_server_ip>:3000. The default credentials are admin/admin.
    • Add Prometheus as a data source in Grafana (Configuration -> Data Sources -> Add data source). Use http://localhost:9090 as the URL.
  4. Create Grafana dashboards:

    • Import pre-built dashboards or create your own to visualize the metrics collected by Prometheus.

These alternative solutions offer diverse approaches to network monitoring on Ubuntu 22.04. Choosing the right one depends on your specific needs, infrastructure, and expertise. OpenNMS is a good all-around solution, while Zabbix provides a potentially lighter footprint and more templates. Prometheus and Grafana excel in modern, containerized environments. Remember to consider factors like scalability, data visualization, and integration capabilities when making your decision. Install and Configure OpenNMS on Ubuntu 22.04 is a viable path, but these other options provide flexibility.

Leave a Reply

Your email address will not be published. Required fields are marked *