(Last Updated On: March 19, 2019)

Welcome to today’s guide on how to install and configure LibreNMS on RHEL / CentOS 8. LibreNMS is an open source auto-discovering network monitoring tool based on PHP, MySQL, and SNMP.

LibreNMS includes support for a wide range of network hardware and operating systems including Juniper, Cisco, Linux, Foundry, FreeBSD, Brocade, HP, Windows and many more. It is a fork of “Observium” monitoring tool.

Features of LibreNMS

The top features of LibreNMS monitoring tool are:

  • Has Automatic discovery – It will automatically discover your entire network using CDP, FDP, LLDP, OSPF, BGP, SNMP, and ARP
  • API Access – LibreNMS provides a full API to manage, graph and retrieve data from your install.
  • Automatic Updates – With LibreNMS you get to stay up to date automatically with new features and bug fixes.
  • Customisable alerting – Highly flexible alerting system, notify via email, IRC, slack and more.
  • Support for Distributed Polling through horizontal scaling which grows with your network
  • Billing system – Easily generate bandwidth bills for ports on your network based on usage or transfer.
  • Android and iOS application – There is a native iPhone/Android App is available which provides core functionality.
  • Multiple authentication methods: MySQL, HTTP, LDAP, Radius, Active Directory
  • Integration support for NfSencollectdSmokePingRANCIDOxidized

Follow steps below to install and configure LibreNMS on RHEL / CentOS 8. Before you begin this installation, ensure you have EPEL repository installed on RHEL / CentOS 8.

Step 1: Install required dependencies

We always start the installation with dependencies required by the application. Add EPEL repository to RHEL / CentOS 8 using our guide below.

How to Install EPEL Repository on RHEL / CentOS 8

Open your terminal and run the commands below commands to install required dependencies.

sudo dnf -y install yum-utils
sudo dnf -y install zip unzip git cronie wget fping net-snmp net-snmp-utils jwhois mtr rrdtool nmap

Step 2: Install PHP and Apache

Install Apache Web server, PHP and extensions required by LibreNMS.

sudo yum install @httpd @php php-{cli,common,curl,gd,mbstring,mysqlnd,process,snmp,xml,zip}

Start Apache and PHP FPM service.

sudo systemctl enable --now php-fpm httpd

Check services status.

$ sudo systemctl status php-fpm httpd
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2018-12-29 11:30:09 EAT; 9s ago
Main PID: 353 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 11510)
Memory: 25.2M
CGroup: /system.slice/php-fpm.service
├─353 php-fpm: master process (/etc/php-fpm.conf)
├─359 php-fpm: pool www
├─360 php-fpm: pool www
├─361 php-fpm: pool www
├─362 php-fpm: pool www
└─363 php-fpm: pool www
Dec 29 11:30:09 rhel8.local systemd[1]: Starting The PHP FastCGI Process Manager…
Dec 29 11:30:09 rhel8.local systemd[1]: Started The PHP FastCGI Process Manager.
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Sat 2018-12-29 11:30:10 EAT; 8s ago
Docs: man:httpd.service(8)
Main PID: 365 (httpd)
Status: "Started, listening on: port 443, port 80"
Tasks: 213 (limit: 11510)
Memory: 33.4M
CGroup: /system.slice/httpd.service
├─365 /usr/sbin/httpd -DFOREGROUND
├─367 /usr/sbin/httpd -DFOREGROUND
├─368 /usr/sbin/httpd -DFOREGROUND
├─369 /usr/sbin/httpd -DFOREGROUND
└─370 /usr/sbin/httpd -DFOREGROUND
Dec 29 11:30:10 rhel8.local systemd[1]: Starting The Apache HTTP Server…
Dec 29 11:30:10 rhel8.local httpd[365]: Server configured, listening on: port 443, port 80
Dec 29 11:30:10 rhel8.local systemd[1]: Started The Apache HTTP Server.

Verify PHP version and loaded modules.

$ php -v
PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

$ php -m

Set PHP timezone inside /etc/php.ini file.

$ grep date.timezone /etc/php.ini 
; http://php.net/date.timezone
date.timezone = Africa/Nairobi

Allow http and https ports on the firewall.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Ref:

How to Install Apache with mod_ssl & mod_http2 on RHEL 8

How to Install PHP on RHEL / CentOS 8

Step 3: Install and Configure Database Server

Install MariaDB Database server on RHEL / CentOS 8 using the guide below.

You can choose to use MySQL or MariaDB database server. if you don’t have either installed, below guides should be helpful.

How to Install MariaDB on RHEL 8 / CentOS 8

How to Install MySQL 8.0 on RHEL 8 / CentOS 8

After Database server installation, create database and user for LibreNMS Monitoring tool.

$ mysql -u root -p
CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'StrongDBPassword';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
exit

Edit my.cnf file and add below lines within the [mysqld] section:

$ sudo vim /etc/my.cnf.d/mariadb-server.cnf

Within the [mysqld] section please add:

innodb_file_per_table=1
lower_case_table_names=0

Restart mariadb service

sudo systemctl enable mariadb
sudo systemctl restart mariadb

The service status should show running.

$ systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2018-12-29 11:45:07 EAT; 10s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 2340 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 2271 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
Process: 2245 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 2309 (mysqld)
Status: "Taking your SQL requests now…"
Tasks: 30 (limit: 11510)
Memory: 74.9M
CGroup: /system.slice/mariadb.service
└─2309 /usr/libexec/mysqld --basedir=/usr
Dec 29 11:45:06 rhel8.local systemd[1]: Starting MariaDB 10.3 database server…
Dec 29 11:45:06 rhel8.local mysql-prepare-db-dir[2271]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Dec 29 11:45:06 rhel8.local mysql-prepare-db-dir[2271]: If this is not the case, make sure the /var/lib/mysql is empty before running mysql-prepare-db>
Dec 29 11:45:07 rhel8.local mysqld[2309]: 2018-12-29 11:45:07 0 [Note] /usr/libexec/mysqld (mysqld 10.3.10-MariaDB) starting as process 2309 …
Dec 29 11:45:07 rhel8.local mysqld[2309]: 2018-12-29 11:45:07 0 [Warning] Could not increase number of max_open_files to more than 1024 (request: 4182)
Dec 29 11:45:07 rhel8.local mysqld[2309]: 2018-12-29 11:45:07 0 [Warning] Changed limits: max_open_files: 1024 max_connections: 151 (was 151) table_>
Dec 29 11:45:07 rhel8.local systemd[1]: Started MariaDB 10.3 database server.

Step 4: Install and Configure LibreNMS on RHEL / CentOS 8

Add librenms user

sudo useradd librenms -d /opt/librenms -M -r
sudo usermod -a -G librenms apache

Clone LibreNMS project from Github

cd /opt
sudo git clone https://github.com/librenms/librenms.git
sudo chown librenms:librenms -R /opt/librenms

Install PHP dependencies

cd /opt/librenms
./scripts/composer_wrapper.php install --no-dev

A successful install should have output similar to below:

Copy and configure SNMP configuration template:

sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
sudo vim /etc/snmp/snmpd.conf

Set your community string by replacing RANDOMSTRINGGOESHERE

com2sec readonly  default  MyInternalNetwork

Download distribution version identifier script

sudo curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
sudo chmod +x /usr/bin/distro

Then start and enable snmpd service

$ sudo systemctl enable snmpd
$ sudo systemctl restart snmpd
$ sudo systemctl status snmpd
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2018-12-29 12:07:23 EAT; 5s ago
Main PID: 2747 (snmpd)
Tasks: 1 (limit: 11510)
Memory: 5.4M
CGroup: /system.slice/snmpd.service
└─2747 /usr/sbin/snmpd -LS0-6d -f
Dec 29 12:07:23 rhel8.local systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon….
Dec 29 12:07:23 rhel8.local snmpd[2747]: NET-SNMP version 5.8
Dec 29 12:07:23 rhel8.local systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon..

Configure Apache

Create a new Apache configuration file for LibreNMS.

sudo vi /etc/httpd/conf.d/librenms.conf

Add the following config, edit ServerName as required:

<VirtualHost *:80>
  DocumentRoot /opt/librenms/html/
  ServerName  librenms.example.com

  AllowEncodedSlashes NoDecode
  <Directory "/opt/librenms/html/">
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
  </Directory>
</VirtualHost>

Configure SELinux Policy

Allow Apache to serve files on /opt/librenms/html/

sudo semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/logs(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/logs(/.*)?'
sudo restorecon -RFvv /opt/librenms/logs/
sudo semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/rrd(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/rrd(/.*)?'
sudo restorecon -RFvv /opt/librenms/rrd/
sudo semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/storage(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/storage(/.*)?'
sudo restorecon -RFvv /opt/librenms/storage/
sudo semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/bootstrap/cache(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/bootstrap/cache(/.*)?'
sudo restorecon -RFvv /opt/librenms/bootstrap/cache/
sudo setsebool -P httpd_can_sendmail=1

Allow Ping

Create the file http_fping.tt with the following contents.

module http_fping 1.0;

require {
type httpd_t;
class capability net_raw;
class rawip_socket { getopt create setopt write read };
}

#============= httpd_t ==============
allow httpd_t self:capability net_raw;
allow httpd_t self:rawip_socket { getopt create setopt write read };

Then run these commands

sudo checkmodule -M -m -o http_fping.mod http_fping.tt
sudo semodule_package -o http_fping.pp -m http_fping.mod
sudo semodule -i http_fping.pp

If all looks good, restart the httpd service

sudo systemctl restart httpd

Configure cron jobs

sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms

Copy logrotate config

LibreNMS keeps logs in /opt/librenms/logs. Over time these can become large and be rotated out.

To rotate out the old logs you can use the provided logrotate config file:

sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms

Set proper permissions

sudo chown -R librenms:librenms /opt/librenms
setfacl -d -m g::rwx /opt/librenms/logs
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

Start LibreNMS Web Installer

Open http://librenms.example.com/install.php on your web browser to finish the installation.

Confirm that all Pre-Install Checks passes and click “Next Stage”

2. Configure Database credentials as created earlier. It will start to import database schema and populate data.

If import was successful, you should get message like below.

3.On the next page, you’ll be asked to configure admin user account.

4. Next is the generation of the configuration file, you may have to create the file manually with the contents given if it fails to create. The file path should be /opt/librenms/config.php

<?php
## Have a look in defaults.inc.php for examples of settings you can set here. DO NOT EDIT defaults.inc.php!

### Database config
$config['db_host'] = 'localhost';
$config['db_port'] = '3306';
$config['db_user'] = 'librenms';
$config['db_pass'] = 'StrongDBPassword';
$config['db_name'] = 'librenms';
$config['db_socket'] = '';

// This is the user LibreNMS will run as
//Please ensure this user is created and has the correct permissions to your install
$config['user'] = 'librenms';

### Locations - it is recommended to keep the default
#$config['install_dir']  = "/opt/librenms";

### This should *only* be set if you want to *force* a particular hostname/port
### It will prevent the web interface being usable form any other hostname
#$config['base_url']        = "http://librenms.company.com";

### Enable this to use rrdcached. Be sure rrd_dir is within the rrdcached dir
### and that your web server has permission to talk to rrdcached.
#$config['rrdcached']    = "unix:/var/run/rrdcached.sock";

### Default community
$config['snmp']['community'] = array("public");

### Authentication Model
$config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
#$config['http_auth_guest'] = "guest"; # remember to configure this user if you use http-auth

### List of RFC1918 networks to allow scanning-based discovery
#$config['nets'][] = "10.0.0.0/8";
#$config['nets'][] = "172.16.0.0/12";
#$config['nets'][] = "192.168.0.0/16";

# Update configuration
#$config['update_channel'] = 'release';  # uncomment to follow the monthly release channel
#$config['update'] = 0;  # uncomment to completely disable updates

Change ownership of the file to a librenms user:

sudo chown librenms:librenms /opt/librenms/config.php

5. Click “Finish Install” button to complete LibreNMS installation. You should be greeted with an admin login page. Login and select Validate Installation

LibreNMS dashboard should look similar to below.

Read LibreNMS documentation for advanced setup and configurations.

Similar Articles:

How to Install and Configure LibreNMS on Ubuntu 18.04 LTS with Nginx

How To Monitor VMware ESXi Host Using LibreNMS

We also have other monitoring tutorials around Zabbix, Cacti, GrafanaPrometheus, and InfluxDB.