OpenNMS was born out of the frustration its creators observed from how expensive, inflexible and hard to deploy existing network management tools were. In addition to that, they observed how clients had to change their business process to fit the existing tools instead of the other way around. This propelled them to create OpenNMS.
OpenNMS is the world’s first fully open source enterprise-grade network service management platform, and hundreds of enterprises are using it every day without a lick of help from their team. That is how much the OpenNMS team has made it easy to work with. And as true open source, it’s 100% free.
Unlike traditional network management products which are very focused on network elements such as interfaces on switches and routers, OpenNMS focuses on the services network resources provide: web pages, database access, DNS, DHCP, etc. (although information on network elements is also available).
We are going to install and configure this wonderful tool and check out what it can do. Before that, let us have a look at what its package hides inside.
Features of OpenNMS
The following are the core features that OpenNMS possesses:
- Scalability: It is built for enterprises and monitors millions of devices from a single instance.
- Extensibility: Uses the flexible and extensible architecture to extend service polling and performance data collection frameworks
- Open Source: Published under the AGPLv3 license, OpenNMS is a fully open source solution.
- Support: Supported by a large community of users and commercially by The OpenNMS Group
We should now be ready to explore OpenNMS on our CentOS 8 box.
Step 1: Update and prepare our server
Before we delve into the deep end of this setup, it is a good idea to start off on a clean and well updated slate. We shall update and install essential tools we need during the entire process.
sudo dnf -y update sudo dnf install -y vim curl wget
OpenNMS is developed using Java, so we need Java installed. Install Java on CentOS 8 using this how to setup Java 11-OpenJDK 11- on RHEL 8 | CentOS 8 guide
Step 2: Install OpenNMS Horizon
After we have covered the base layer ensuring it is ready to welcome the coming packages, we can then continue to install OpenNMS Horizon. We shall first add the OpenNMS official repository then proceed to fetch and install the requisite packages.
Add yum repository and import GPG key
sudo dnf -y install https://yum.opennms.org/repofiles/opennms-repo-stable-rhel8.noarch.rpm sudo rpm --import https://yum.opennms.org/OPENNMS-GPG-KEY
Once the repository has been added, we are ready to pull and install OpenNMS with all of its built-in dependencies
sudo dnf -y install opennms
The command above will automatically install the following packages which makes work easier:
- jicmp6 and jicmp: Java bridge to allow sending ICMP messages from OpenNMS Horizon repository.
- opennms-core: OpenNMS Horizon core services, e.g. Provisiond, Pollerd and Collectd from OpenNMS Horizon repository.
- opennms-webapp-jetty: OpenNMS Horizon web application from OpenNMS Horizon repository
- postgresql: PostgreSQL database server from distribution repository
- postgresql-libs: PostgreSQL database from distribution repository
Step 3: Initialize and setup PostgreSQL
We had mentioned that Postgres database was to be installed automatically in the previous command. Now we should configure it with relevant databases, credentials and also make sure it is running properly.
Initialize the PostgreSQL database
First let us initialize the database by running the command below
sudo postgresql-setup --initdb --unit postgresql
For PostgreSQL to start automatically in case the server is rebooted, run the Systemd command below to enable the database server and start it.
sudo systemctl enable postgresql sudo systemctl start postgresql
Create database credentials
We shall need a user to access OpenNMS database. Create the user with a password and create an opennms database which is owned by the user opennms
$ sudo su postgres bash-4.4$ psql psql (10.14) Type "help" for help. postgres=# createuser -P opennms postgres-# createdb -O opennms opennms postgres-# \q bash-4.4$ exit
Protect the default postres user with a password to add security as shown below:
$ sudo su postgres bash-4.4$ psql postgres=# ALTER USER postgres WITH PASSWORD 'StrongPassword'; ALTER ROLE postgres=# \q bash-4.4$ exit
Change the access policy for PostgreSQL
When you install Postgres, ident is the default method for local IPv6 and IPv4 connections. The ident authentication method works by obtaining the client’s operating system user name from an ident server and using it as the allowed database user name (with an optional user name mapping). This is only supported on TCP/IP connections. The password-based authentication methods are “md5” and “password“. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively.
We are going to change that from ident to MD5-hashed way. Edit the file shown below accordingly
sudo vim /var/lib/pgsql/data/pg_hba.conf
Allow OpenNMS Horizon accessing the database over the local network with a MD5 hashed password
host all all 127.0.0.1/32 md5 #<== host all all ::1/128 md5
After making the changes, restart postgres to apply and persist configuration changes for PostgreSQL
sudo systemctl restart postgresql
Configure database access to OpenNMS Horizon
We have configured our database and we should now allow OpenNMS Horizon to freely connect. Edit the opennms-datasources.xml file as shown below to see the required configurations. It is basically adding the database details we have already set.
$ sudo vim /opt/opennms/etc/opennms-datasources.xml <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="StrongPassword" />
Same details on a screenshot
Step 4: Initialize and start OpenNMS Horizon
Once the database settings are made, we can finally initialize OpenNMS Horizon. Let us add Java settings then proceed to start the application.
Detect of Java environment and persist in /opt/opennms/etc/java.conf
sudo /opt/opennms/bin/runjava -s
Initialize the database and detect system libraries persisted in /opt/opennms/etc/libraries.properties
sudo /opt/opennms/bin/install -dis
Enable OpenNMS Horizon to start automatically on system boot
$ sudo systemctl enable --now opennms $ sudo systemctl status opennms ● opennms.service - OpenNMS server Loaded: loaded (/usr/lib/systemd/system/opennms.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2020-09-23 13:44:38 UTC; 5s ago Process: 1689425 ExecStart=/etc/init.d/opennms -s start (code=exited, status=0/SUCCESS) Main PID: 1690701 (java) Tasks: 36 (limit: 11070) Memory: 162.8M CGroup: /system.slice/opennms.service ├─1690700 /bin/bash /etc/init.d/opennms -s start └─1690701 /usr/lib/jvm/java-11-openjdk-188.8.131.52-0.el8_2.x86_64/bin/java --add-modules=java.base,java.compiler
Since OpenNMS Horizon listens on port 8980, you should consider allowing traffic in and out of that port on your firewall if you have one running. Simply run the commands below.
sudo firewall-cmd --permanent --add-port=8980/tcp sudo firewall-cmd --reload
Step 5: Login and change default password
After starting OpenNMS the web application can be accessed by pointing your browser to http://[IP-or-FQDN-of-your-server]:8980/opennms. The default login user is admin and the password is initialized to admin.
Once you are logged in, you can change the password as follows: In the main navigation menu click on “admin → Change Password → Change Password“. Set as current password admin and set a new password and confirm your newly set password then click “Submit“. After you are done, logout and login with your new password.
Step 6: Add Hosts in OpenNMS
We have finished setting up OpenNMS Horizon and the only thing remaining is to add hosts for us to monitor. To add a host, log into your OpenNMS web console and on the the main navigation menu, manoeuvre as follows: Click “+“.
Since it is a completely new setup, we will need to add a “requisition“. You will see a pop up requesting you to enter a name for the new “requisition“.
A new page with a form will be availed as shown below. Fill in the form then scroll to the bottom of the page and click “Provision“.
A pop up with success message should ensue when you are done clicking Provision.
Once you have added a node, you can check them by clicking on “Info” drop-down menu then choose “Nodes“. You should be able to see the node we just added together with some details it has already deciphered.
OpenNMS has more to offer than has been covered in this guide. You can monitor clients via SNMP, configure minions that return data to the main Horizon via message brokers and so much more. We will cover installation of Minion with Apache Kafka in a later guide. For now, we continue to appreciate your relentless support. For more monitoring guides, check below: