Monitor Your Devices Using LibreNMS on Ubuntu 16.04

LibreNMS is a full-featured open source network monitoring system. It uses SNMP to obtain the data from different devices. A variety of devices are supported in LibreNMS such as Cisco, Linux, FreeBSD, Juniper, Brocade, Foundry, HP and many more. It supports multiple authentication mechanisms and supports two-factor authentication. It has a customizable alerting system which can alert the network admin via email, IRC or slack.

Prerequisites

  • A Vultr Ubuntu 16.04 server instance.
  • A sudo user.

For this tutorial, we will use nms.example.com as the domain name pointed towards the Vultr instance. Please make sure to replace all occurrences of the example domain name with the actual one.

Update your base system using the guide How to Update Ubuntu 16.04. Once your system has been updated, proceed to install the dependencies.

Install Nginx and PHP

The front end of LibreNMS is written in PHP, thus we will need to install a web server and PHP. In this tutorial, we will install Nginx along with PHP 7.2 to obtain maximum security and performance.

Install Nginx.

sudo apt -y install nginx

Start Nginx and enable it to start at boot automatically.

sudo systemctl start nginx
sudo systemctl enable nginx

Add and enable the Remi repository, as the default apt repository contains an older version of PHP.

sudo add-apt-repository --yes ppa:ondrej/php
sudo apt update

Install PHP version 7.2 along with the modules required by LibreNMS.

sudo apt -y install php7.2 php7.2-cli php7.2-common php7.2-curl php7.2-fpm php7.2-gd php7.2-mysql php7.2-snmp php7.2-mbstring php7.2-xml php7.2-zip zip unzip

Open the loaded configuration file in an editor.

sudo nano /etc/php/7.2/fpm/php.ini

Find the following lines.

;cgi.fix_pathinfo=1
;date.timezone =

Uncomment and use these values instead, replace Asia/Kolkata with your local timezone.

cgi.fix_pathinfo=0
date.timezone = Asia/Kolkata

You will also need to change the system timezone by running the following command.

sudo ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

Restart PHP-FPM.

sudo systemctl restart php7.2-fpm

Install MariaDB

MariaDB is an open source fork of MySQL. Add the MariaDB repository into your system, as the default Ubuntu repository contains an older version of MariaDB.

sudo apt-key adv --yes --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mariadb.biz.net.id/repo/10.2/ubuntu xenial main'
sudo apt update

Install MariaDB. During installation, the installer will ask for the password of the MySQL root user. Provide a strong password.

sudo apt -y install mariadb-server

Before we start using MariaDB, we will need to tweak the configuration a little bit. Open the configuration file.

sudo nano /etc/mysql/conf.d/mariadb.cnf 

Add the following code to the end of the file.

[mysqld]
innodb_file_per_table=1
sql-mode=""
lower_case_table_names=0

Restart MariaDB and enable it to automatically start at boot time.

sudo systemctl restart mariadb.service 
sudo systemctl enable mariadb.service

Before configuring the database, you will need to secure the MariaDB instance.

sudo mysql_secure_installation

You will be asked for the current MariaDB root password, and then be prompted to change the root password. Since we already set a strong password for the root user during installation, skip it by answering "N". For all other questions, answer "Y". The questions asked are self-explanatory.

Log into the MySQL shell as root.

mysql -u root -p

Provide the password for the MariaDB root user to log in. Run the following queries to create a database and a database user for the LibreNMS installation.

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
EXIT;

You can replace the database name librenms and username librenms according to your choice. Please make sure to change StrongPassword to a very strong password.

Install LibreNMS

Apart from the dependencies above, LibreNMS needs few more dependencies.

sudo apt -y install fping git imagemagick jwhois mtr graphviz nmap python-memcache python-mysqldb rrdtool snmp snmpd whois composer

Add a new unprivileged user for LibreNMS application.

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

LibreNMS can be installed directly by cloning its Github repository.

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

Change the ownership.

sudo chown librenms:librenms -R /opt/librenms

Install the PHP dependencies.

cd /opt/librenms
sudo su librenms -c "composer install"

LibreNMS relies on SNMP for many tasks. Since we have already installed SNMP, copy the example configuration file to its location.

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

Open the configuration file in the editor.

sudo nano /etc/snmp/snmpd.conf

Find this line.

com2sec readonly  default         RANDOMSTRINGGOESHERE

Edit the text RANDOMSTRINGGOESHERE and replace the community string with any string of your choice. For example.

com2sec readonly  default         my-org

Remember the string as it will be required later when we add the first SNMP device.

SNMP also needs information about the distribution version. Download and install the script to find the distribution version.

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

Start the SNMP daemon service and enable it to automatically start at boot time.

sudo systemctl enable snmpd
sudo systemctl restart snmpd

Now you will need to add some crontab entries to run the scheduled tasks. Create a new cron job file.

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

Restart the cron daemon service.

sudo systemctl restart cron

Setup logrotate so that the log files are automatically refreshed over time.

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

Finally, set the appropriate ownership and permissions.

sudo chown -R librenms:www-data /opt/librenms
sudo chmod g+w -R /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs
sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs

SSL and Nginx VHost configurations

Logins and other information sent through the web interface of LibreNMS are not secured if the connection is not encrypted with SSL. We will configure Nginx to use the SSL generated with Let's Encrypt free SSL.

Add the Certbot repository.

sudo add-apt-repository --yes ppa:certbot/certbot
sudo apt-get update

Install Certbot, which is the client application for Let's Encrypt CA.

sudo apt -y install certbot

Note: To obtain certificates from Let's Encrypt CA, the domain for which the certificates are to be generated must be pointed towards the server. If not, make the necessary changes to the DNS records of the domain and wait for the DNS to propagate before making the certificate request again. Certbot checks the domain authority before providing the certificates.

Generate the SSL certificates.

sudo certbot certonly --webroot -w /var/www/html -d nms.example.com

The generated certificates are likely to be stored in the /etc/letsencrypt/live/nms.example.com/ directory. The SSL certificate will be stored as fullchain.pem and private key will be stored as privkey.pem.

Let's Encrypt certificates expire in 90 days, hence it is recommended to set up auto-renewal for the certificates using a cron job.

Open the cron job file.

sudo crontab -e

Add the following line at the end of the file.

30 5 * * 1 /usr/bin/certbot renew --quiet

The above cron job will run every Monday at 5:30 AM local time. If the certificate is due for expiry, it will automatically be renewed.

Create a new virtual host.

sudo nano /etc/nginx/sites-available/librenms

Populate the file.

server {
    listen 80;
    server_name nms.example.com;
    return 301 https://$host$request_uri;
}
server {

    listen 443;
    server_name nms.example.com;

    ssl_certificate           /etc/letsencrypt/live/nms.example.com/fullchain.pem;
    ssl_certificate_key       /etc/letsencrypt/live/nms.example.com/privkey.pem;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    access_log    /opt/librenms/logs/librenms.nginx.access.log;
    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:/run/php/php7.2-fpm.sock;
    }
    location ~ /\.ht {
        deny all;
    }
 }

Replace nms.example.com with your actual domain in the above configuration.

Activate the newly created configuration.

sudo ln -s /etc/nginx/sites-available/librenms /etc/nginx/sites-enabled/librenms

Restart Nginx.

sudo systemctl restart nginx

Installation using WebUI

To finish the installation, open https://nms.example.com on your favorite browser. You will see the requirements are satisfied. Provide your database details and create a new administrative account. Once installed, you will get a message to validate the installation. Click on the link and log in using the administrator account. You should see that everything except the "Poller" has an "Ok" status.

Monitor Your Devices Using LibreNMS on Ubuntu 16.04

Now, click on the link to add a device. On the "Add Device" interface, provide the hostname as the localhost and leave everything as it is. Provide your community string in community field. It must be the exact same string which you have provided in snmpd.conf during the configuration of SNMP.

Monitor Your Devices Using LibreNMS on Ubuntu 16.04

Once the device has been added, you can see the details by going to the "Devices" tab. Similarly, you can add more devices into the LibreNMS application for "around the clock" monitoring.



Leave a Comment

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Aprende cómo instalar Vtiger CRM, una aplicación de gestión de relaciones con el cliente, en CentOS 7 para aumentar tus ventas y mejorar el servicio al cliente.

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Esta guía completa le mostrará cómo configurar un servidor Counter-Strike 1.6 en Linux, optimizando el rendimiento y la seguridad para el mejor juego. Aprende los pasos más recientes aquí.

Cómo instalar LiteCart Shopping Cart Platform en Ubuntu 16.04

Cómo instalar LiteCart Shopping Cart Platform en Ubuntu 16.04

LiteCart es una plataforma de carrito de compras gratuita y de código abierto escrita en PHP, jQuery y HTML 5. Es un software de comercio electrónico simple, liviano y fácil de usar.

Cómo instalar MODX Revolution en un CentOS 7 LAMP VPS

Cómo instalar MODX Revolution en un CentOS 7 LAMP VPS

¿Usando un sistema diferente? MODX Revolution es un sistema de gestión de contenido (CMS) de nivel empresarial rápido, flexible, escalable, gratuito y de código abierto escrito i

Instalación de McMyAdmin en Ubuntu 14.10

Instalación de McMyAdmin en Ubuntu 14.10

McMyAdmin es un panel de control del servidor de Minecraft utilizado para administrar su servidor. Aunque McMyAdmin es gratuito, hay varias ediciones, algunas de las cuales son pai

Configurar un servidor TeamTalk en Linux

Configurar un servidor TeamTalk en Linux

TeamTalk es un sistema de conferencia que permite a los usuarios tener conversaciones de audio / video de alta calidad, chat de texto, transferir archivos y compartir pantallas. Es yo

How to Install and Configure CyberPanel on Your CentOS 7 Server

How to Install and Configure CyberPanel on Your CentOS 7 Server

Using a Different System? Introduction CyberPanel is one of the first control panels on the market that is both open source and uses OpenLiteSpeed. What thi

Instalar Grafana en Ubuntu 16.04 LTS

Instalar Grafana en Ubuntu 16.04 LTS

¿Usando un sistema diferente? Introducción Grafana es un software de código abierto que transforma múltiples feeds de sistemas como Graphite, Telegraf, an

Instalar phpBB con Apache en Ubuntu 16.04

Instalar phpBB con Apache en Ubuntu 16.04

PhpBB es un programa de tablón de anuncios de código abierto. Este artículo le mostrará cómo instalar phpBB en la parte superior de un servidor web Apache en Ubuntu 16.04. Fue escrito

Cómo instalar Foreman en Ubuntu 16.04 LTS

Cómo instalar Foreman en Ubuntu 16.04 LTS

¿Usando un sistema diferente? Foreman es una herramienta gratuita y de código abierto que lo ayuda con la configuración y administración de servidores físicos y virtuales. Forema

Configurar un usuario no root con acceso a Sudo en Ubuntu

Configurar un usuario no root con acceso a Sudo en Ubuntu

Tener un solo usuario, que es root, puede ser peligroso. Así que arreglemos eso. Vultr nos brinda la libertad de hacer lo que queramos con nuestros usuarios y nuestros servidores.

Install eSpeak on CentOS 7

Install eSpeak on CentOS 7

Using a Different System? ESpeak can generate text-to-speech (TTS) audio files. These can be useful for many reasons, such as creating your own Turin

Cómo instalar Thelia 2.3 en CentOS 7

Cómo instalar Thelia 2.3 en CentOS 7

¿Usando un sistema diferente? Thelia es una herramienta de código abierto para crear sitios web de comercio electrónico y administrar contenido en línea, escrito en PHP. Código fuente de Thelia i

Instalación de Fuel CMS en Ubuntu 16.04 LTS

Instalación de Fuel CMS en Ubuntu 16.04 LTS

¿Usando un sistema diferente? Fuel CMS es un sistema de gestión de contenido basado en CodeIgniter. Su código fuente está alojado en GitHub. Esta guía le mostrará cómo t

Cómo instalar Couch CMS 2.0 en un VPS LAMP Debian 9

Cómo instalar Couch CMS 2.0 en un VPS LAMP Debian 9

¿Usando un sistema diferente? Couch CMS es un sistema de gestión de contenido (CMS) simple y flexible, gratuito y de código abierto que permite a los diseñadores web diseñar

Monitoree sus dispositivos usando LibreNMS en CentOS 7

Monitoree sus dispositivos usando LibreNMS en CentOS 7

¿Usando un sistema diferente? LibreNMS es un completo sistema de monitoreo de red de código abierto. Utiliza SNMP para obtener los datos de diferentes dispositivos. Una variedad

Cómo configurar la optimización TCP en Linux

Cómo configurar la optimización TCP en Linux

Introducción ¿Tiene problemas con la conectividad cuando los visitantes de otros países acceden a su sitio web? Preguntándose por qué la velocidad de descarga de su extranjero

Cómo implementar Ghost v0.11 LTS en Ubuntu 16.04

Cómo implementar Ghost v0.11 LTS en Ubuntu 16.04

¿Usando un sistema diferente? Ghost es una plataforma de blogs de código abierto que ha estado ganando popularidad entre los desarrolladores y usuarios comunes desde su 201

Cómo instalar Pip en Linux

Cómo instalar Pip en Linux

Pip es una herramienta para administrar paquetes de Python. El uso de un administrador de paquetes permite una gestión eficiente de su servidor. En este tutorial, explicaré cómo t

Cómo instalar Cacti 1.1 en CentOS 7

Cómo instalar Cacti 1.1 en CentOS 7

Cacti es una herramienta de gráficos y monitoreo de red de código abierto y libre escrita en PHP. Con la ayuda de RRDtool (herramienta de base de datos Round-Robin), Cacti se puede usar t

ZPanel y Sentora en CentOS 6 x64

ZPanel y Sentora en CentOS 6 x64

ZPanel, un panel de control de alojamiento web popular, se bifurcó en 2014 a un nuevo proyecto llamado Sentora. Aprende a instalar Sentora en tu servidor con este tutorial.

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Aprende cómo instalar Vtiger CRM, una aplicación de gestión de relaciones con el cliente, en CentOS 7 para aumentar tus ventas y mejorar el servicio al cliente.

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Esta guía completa le mostrará cómo configurar un servidor Counter-Strike 1.6 en Linux, optimizando el rendimiento y la seguridad para el mejor juego. Aprende los pasos más recientes aquí.

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

Los ataques de ransomware van en aumento, pero ¿puede la IA ayudar a lidiar con el último virus informático? ¿Es la IA la respuesta? Lea aquí, sepa que la IA es una bendición o una perdición

ReactOS: ¿Es este el futuro de Windows?

ReactOS: ¿Es este el futuro de Windows?

ReactOS, un sistema operativo de código abierto y gratuito, está aquí con la última versión. ¿Puede satisfacer las necesidades de los usuarios de Windows de hoy en día y acabar con Microsoft? Averigüemos más sobre este estilo antiguo, pero una experiencia de sistema operativo más nueva.

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Whatsapp finalmente lanzó la aplicación de escritorio para usuarios de Mac y Windows. Ahora puede acceder a Whatsapp desde Windows o Mac fácilmente. Disponible para Windows 8+ y Mac OS 10.9+

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

Lea esto para saber cómo la Inteligencia Artificial se está volviendo popular entre las empresas de pequeña escala y cómo está aumentando las probabilidades de hacerlas crecer y dar ventaja a sus competidores.

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

Recientemente, Apple lanzó macOS Catalina 10.15.4, una actualización complementaria para solucionar problemas, pero parece que la actualización está causando más problemas que conducen al bloqueo de las máquinas Mac. Lee este artículo para obtener más información

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

¿Qué es un sistema de archivos de diario y cómo funciona?

¿Qué es un sistema de archivos de diario y cómo funciona?

Nuestra computadora almacena todos los datos de una manera organizada conocida como sistema de archivos de diario. Es un método eficiente que permite a la computadora buscar y mostrar archivos tan pronto como presiona buscar.