How to install LibreNMS in Ubuntu

To install LibreNMS in Ubuntu

LibreNMS is a network monitoring tool that supports wide range of network hardware and operating systems. Installation of LibreNMS in Ubuntu is explained in this manual.

Features

  • Automatic discovery
  • Customizable alerting
  • Distributed Polling
  • Plugin system

To install LibreNMS

Run the following command to install the mysql-server.

root@linuxhelp:/home/user1# apt-get install mariadb-server 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
.
.
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...


Start the mysql service by running the following command.

root@linuxhelp:/home/user1# service mysql start 
Configure the mysql
root@linuxhelp:/home/user1# mysql_secure_installation 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
.
.
.
All done!  If you' ve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!


Login to mysql server and create database as shown below.

root@linuxhelp:/home/user1# mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with   or g.
Your MariaDB connection id is 50
Server version: 10.0.27-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.
MariaDB [(none)]>  CREATE DATABASE librenms 
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]>  GRANT ALL PRIVILEGES ON librenms.* TO ' librenms' @' localhost'  IDENTIFIED BY ' 123'  
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>  FLUSH PRIVILEGES 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>  exit
Bye


Open and edit the mysql configuration file by utilizing the following command.

root@linuxhelp:/home/user1# nano /etc/mysql/mariadb.conf.d/50-server.cnf 
innodb_file_per_table=1
sql-mode=" " 

Add the above lines inside the mysqld section

Then restart the mysql service with the following command.

root@linuxhelp:/home/user1# service mysql restart 


Next install the other dependency packages that are required for the libreNMS.

root@linuxhelp:/home/user1# apt-get install libapache2-mod-php7.0 php7.0-cli php7.0-mysql php7.0-gd php7.0-snmp php-pear php7.0-curl snmp graphviz php7.0-mcrypt php7.0-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git 
Reading package lists... Done
Building dependency tree       
.
.
.
rocessing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Processing triggers for libapache2-mod-php7.0 (7.0.8-0ubuntu0.16.04.2) ...

Then edit the PHP configuration for setting the timezone.


In /etc/php/7.0/apache2/php.ini and /etc/php/7.0/cli/php.ini, ensure date.timezone is set to your preferred time zone.

After setting the time zone, enable the installed packages.

root@linuxhelp:/home/user1# a2enmod php7.0 
Considering conflict php5 for php7.0:
Module php7.0 already enabled
root@linuxhelp:/home/user1# a2dismod mpm_event 
Module mpm_event already disabled
root@linuxhelp:/home/user1# a2enmod mpm_prefork 
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
root@linuxhelp:/home/user1# phpenmod mcrypt 

To create the libreNMS user

Run the following command to create the LibreNMS user.

root@linuxhelp:/home/user1# useradd librenms -d /opt/librenms -M -r
root@linuxhelp:/home/user1# usermod -a -G librenms www-data 


Download and extract the LibreNMS package by using the following command.

root@linuxhelp:/home/user1# cd /opt/
root@linuxhelp:/opt# git clone https://github.com/librenms/librenms.git librenms 
Cloning into ' librenms' ...
remote: Counting objects: 94203, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 94203 (delta 0), reused 0 (delta 0), pack-reused 94199
Receiving objects: 100% (94203/94203), 73.26 MiB | 339.00 KiB/s, done.
Resolving deltas: 100% (64337/64337), done.
Checking connectivity... done.


To make web UI ready for LibreNMS installation, do as directed.

root@linuxhelp:/opt# cd librenms/
root@linuxhelp:/opt/librenms# mkdir rrd logs
root@linuxhelp:/opt/librenms# chmod 775 rrd 


Now create a virtual host file for Apache configuration by using the following command and add the following lines into it.

root@linuxhelp:/opt/librenms# nano /etc/apache2/sites-available/librenms.conf 
< VirtualHost *:80> 
  DocumentRoot /opt/librenms/html/
  ServerName  linuxhelp
  CustomLog /opt/librenms/logs/access_log combined
  ErrorLog /opt/librenms/logs/error_log
  AllowEncodedSlashes NoDecode
  < Directory " /opt/librenms/html/" > 
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
   < /Directory> 
< /VirtualHost> 

Once the configuration is done, disable the default config file and then enable the librenms.conf file.

root@linuxhelp:/opt/librenms# a2dissite 000-default.conf
root@linuxhelp:/opt/librenms# a2ensite librenms.conf 
Enabling site librenms. 


To activate the new configuration, rewrite and restart the service of apache2.

root@linuxhelp:/opt/librenms# service apache2 reload
root@linuxhelp:/opt/librenms# a2enmod rewrite 
Enabling module rewrite.
root@linuxhelp:/opt/librenms# service apache2 restart 


Open the browser and navigate to http:/< IP_address> /install.php

Set the Database and click Next to proceed further.

Then click on Goto Add user.

Fill the user details and click Add user.



Create a config.php file and paste configuration. Add the following line at the end of the file and save it.

[root@linuxhelp librenms]# php addhost.php localhost public v2c 
Added device localhost (1)
Discover localhost:
[root@linuxhelp librenms]# php discovery.php -h all 
LibreNMS Discovery
Version info:
.
.
.
#### Unload disco module ntp ####
Discovered in 1.781 seconds
MySQL: Cell[1/0s] Row[10/0.01s] Rows[36/0.03s] Column[0/0s] Update[2/0.01s] Insert[2/0.02s] Delete[0/0s]
Create cronjob


By default, the LibreNMS cronjob runs poller-wrapper.py with 16 threads. The current LibreNMS recommendation is to use 4 threads per core. The default if no thread count is 16 threads.
If the thread count needs to be changed, edit the cron file. Just add a number after poller-wrapper.py,

[root@linuxhelp librenms]# /opt/librenms/poller-wrapper.py 12 > >  /dev/null 2> & 1
[root@linuxhelp librenms]# cp librenms.nonroot.cron /etc/cron.d/librenms 


Installation is successfully completed, refresh the page in the browser to get the login page.


To add device, enter the Hostname, SNMP version, Port association mode.


Navigate to Overview &rarr Plugins &rarr Plugin Admin

To know more about LibreNMS, click LibreNMS.

Comment
bentel263
May 09 2020
Hi. Im stuck here, Im getting error saying unable to locate packages
apt-get install libapache2-mod-php7.0 php7.0-cli php7.0-mysql php7.0-gd php7.0-snmp php-pear php7.0-curl snmp graphviz php7.0-mcrypt php7.0-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git
jayjzz
Jun 04 2017
I'm stuck, can't seem to find this to edit it /etc/mysql/mariadb.conf.d/50-server.cnf - do I copy my.cnf to this?
jagannatharumugam
Mar 31 2017
Hello, MmMMMMthatsalotofMs has pointed out the issue pretty well in his comment. By default it will load the 000-default.conf file, So jus disable this file and you need to enable the librenms.conf file. To disable, # a2dissite 000-default.conf To enable, # a2enmod librenms.conf Now restart the apache to take effect.
MmMMMMthatsalotofMs
Mar 30 2017
I to cannot get past [IP ADDRESS]/install.php One thing to note is that this is an AWS instance (port 80 inbound is whitelisted, though).
evanjayretuerto
Mar 29 2017
Not Found The requested URL /phpmyadmin was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80
Add a comment
FAQ
Q
What are the main features in LibreNMS?
A
The main features are LibreNMS.
Automatic discovery
Customizable alerting
Distributed Polling
Plugin system
Q
What's libreNMS?
A
LibreNMS is a network monitoring tool that supports wide range of network hardware and operating systems.
Q
Can I customize the alert in libreNMS?
A
yes you can customize alerts depends on your needs
Q
Do in need MariaDB - client for libreNMS?
A
No, the server installation is enough i9n libreNMS.
Q
How long it takes to install in libreNMS?
A
It depends on system configuration but it wont take much time to change in libreNMS.