You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

Introduction

LibreNMS is an auto discovering PHP/MySQL/SNMP based network monitoring which includes support for a wide range of network hardware and operating systems including Cisco, Linux, FreeBSD, Juniper, Brocade, Foundry, HP and many more. To install LibreNMS on Debian 10 Buster, follow the following steps.

Step 1: Install Required Packages

We need to install all dependency packages required by LibreNMS to function.

sudo apt install software-properties-common
sudo apt update && sudo apt -y upgrade
sudo apt install nginx
sudo apt install curl acl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap python-memcache python-mysqldb rrdtool snmp snmpd whois

Step 2: Install PHP and required extensions

Use the guide below to install PHP 7.3 and PHP Extensions on your server

How To Install PHP / PHP on Debian 10 Buster

Step 3: Add librenms user to the system

Run the following commands on your Debian 10 terminal to add librenms user.

sudo useradd librenms -d /opt/librenms -M -r
sudo usermod -aG librenms www-data

Step 4: Clone LibreNMS from git

Let us now download LibreNMS files into our server using git.

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

Step 5: Set Requisite Permissions on LibreNMS Directories

LibreNMS user requires special rights on the directories and files it is going to access. Set them by running the commands below

sudo chown -R librenms:librenms /opt/librenms
sudo chmod 770 /opt/librenms
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/

Step 6: Install PHP dependencies

Run the commands below to install all dependencies required by PHP on your Debian 10 server. This might take a while to complete.

sudo su - librenms
./scripts/composer_wrapper.php install --no-dev
exit

You should see an output similar to the one below

Step 7: Database Configuration

We installed MariaDB in step 1. Let us proceed to create a database for LibreNMS.

Login to your Database

sudo systemctl enable mysql
sudo systemctl restart mysql
sudo mysql -u root -p

Create Database and librenms user

 CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
 CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'SafePassWord'; ## Make it Strong
 GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
 FLUSH PRIVILEGES;
 exit

Open MariaDB file and add the lines below under [mysqld] section

sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf

Add the following under [mysqld]

[mysql]
........
innodb_file_per_table=1
lower_case_table_names=0

Restart MariaDB

sudo systemctl restart mysql

Step 8: Configure PHP-FPM

Let us ensure date.timezone is set in php.ini to a preferred time zone.

sudo vim /etc/php/7.3/fpm/php.ini

Under [Date] uncomment the date.timezone line and add your timezone.

  [Date]
 ; Defines the default timezone used by the date functions
 ; http://php.net/date.timezone
 date.timezone = Africa/Nairobi ## Place your time zone here
sudo vim /etc/php/7.3/cli/php.ini

Like above, under [Date] uncomment the date.timezone line and add your timezone.

 [Date]
 ; Defines the default timezone used by the date functions
 ; http://php.net/date.timezone
 date.timezone = Africa/Nairobi   ## Place your time zone here 

Restart PHP-FPM

sudo systemctl restart php7.3-fpm

Step 9: Configure Nginx Webserver

Since we chose Nginx as our preferred web server, it is time to add configurations so that we start serving LibreNMS pages.

Delete the default page that loads up after fresh installation of Nginx

sudo rm /etc/nginx/sites-enabled/default

Create a config file under conf.d directory and add the following in it

sudo vim /etc/nginx/conf.d/libreconfig.conf
server {
  listen      80;
  server_name example.com;         ## Input your Server name here.
  root        /opt/librenms/html;
  index       index.php;
 charset utf-8;
  gzip on;
  gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; 
  location / {
   try_files $uri $uri/ /index.php?$query_string;
  }
  location /api/v0 {
   try_files $uri $uri/ /api_v0.php?$query_string;
  }
  location ~ .php {
   include fastcgi.conf;
   fastcgi_split_path_info ^(.+.php)(/.+)$;
   fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
  }
  location ~ /.ht {
   deny all;
  }
 }

Restart Nginx

sudo systemctl restart nginx

Step 10: Configure snmp daemon (snmpd)

LibreNMS uses SNMP extensively to collect metrics from remote devices and servers. Copy the sample config file to /etc

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

On the line below:

com2sec readonly  default         RANDOMSTRINGGOESHERE
##Change to for example:
com2sec readonly  default         teststring

Change RANDOMSTRINGGOESHERE to your own community string as demonstrated above.

Pull the file below, make it executable and restart snmp daemon

The file detects which OS and if it is Linux then it will detect which Linux Distribution

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

Step 11: 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

Step 12: Set Cron job

This cron job does a lot of stuff such as checking for updates, autodiscovery of devices among many others.

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

Step 13: LibreNMS Web installer

Now head to the web installer and follow the on-screen instructions.

http:// IP or FQDN /install.php

The web installer might prompt you to create a config.php file in your librenms install location manually, copying the content displayed on-screen to the file. If you have to do this, please remember to set the permissions on config.php after you copied the on-screen contents to the file. Run:

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

Follow the installation process and you can take a look at the images below for guidance.

Input your DB User, DB pass and DB Name

Give it time to import DB

Add a user you will use to login to LibreNMS later.

Generate config

After the config has been generated, please run the following command

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

Finish Installation

Click on the “validate your install and fix any issues” link to finish up

After everything is done, you should see the login page below when you refresh your browser.

Conclusion

Now that we have installed LibreNMS monitoring tool, we still have some work to do. It includes adding devices, creating alerts, creating thresholds, performance tuning and much more. We hope the guide was helpful and we appreciate your visit. We suggest that you have a read of a few LibreNMS docs to get you going with the next steps.

You can also go through the guides below for your enjoyment.

How To Install LibreNMS on CentOS 8 / RHEL 8

Install and Configure Zabbix Server 4.4 on Debian 10 (Buster)

Install LibreNMS Monitoring Tool on CentOS with Letsencrypt and Nginx

How to Install and configure Zabbix agent 4.0 on Ubuntu 18.04 and CentOS 7

Install Zabbix Server on Ubuntu 18.04

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

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF