Announcement

How to Install and Configure LibreNMS on Ubuntu 16.04 Server


LibreNMS is an open source autodiscovering 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.

If you are not interested in written instruction then you can watch the below step by step video tutorial.






Features

Automatic discovery: Automatically discover your entire network using CDP, FDP, LLDP, OSPF, BGP, SNMP and ARP.
Customisable alerting: Highly flexible alerting system, notify via email, irc, slack and more.
API Access: A full API to manage, graph and retrieve data from your install.
Billing system: Generate bandwidth bills for ports on your network based on usage or transfer.
Automatic Updates: Stay upto date automatically with bug fixes, new features and more.
Distributed Polling: Horizontal scaling to grow with your network.
iPhone App: Native iPhone App is available which provides core functionality.
Android App: Native Android App is available which provides core functionality.


Authentication methods:

MySQL
HTTP
LDAP
Radius
Active Directory

In this tutorial, we will show you how to install and configure LibreNMS on Ubuntu 16.04 server with Nginx as webserver and MariaDB as database.


Prerequisites

One Ubuntu 16.04 Server with a non-root user having sudo privileges


Installing Required Packages

The first step we must do for installing LibreNMS Monitoring Tools is to install some packages needed on the server.

sudo apt-get update
sudo apt-get install composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php7.0-cli php7.0-curl php7.0-fpm php7.0-gd php7.0-mcrypt php7.0-mysql php7.0-snmp php7.0-xml php7.0-zip python-memcache python-mysqldb rrdtool snmp snmpd whois


Adding librenms user

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


Download LibreNMS

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

Configure MySQL

sudo systemctl restart mysql
sudo mysql -u root -p

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

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

Within the [mysqld] section please add:

innodb_file_per_table=1
sql-mode=""
lower_case_table_names=0

Save and close.


Configure and Start PHP-FPM

Ensure date.timezone is set in php.ini to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid examples are: "America/New_York", "Australia/Brisbane", "Etc/UTC".

sudo nano /etc/php/7.0/fpm/php.ini
sudo nano /etc/php/7.0/cli/php.ini

Uncomment the 'date.time' line and change the value with your system timezone.

date.time = Asia/Pakistan

Save and close.

sudo phpenmod mcrypt
sudo systemctl restart php7.0-fpm

sudo systemctl restart mysql


Configure NGINX

sudo nano /etc/nginx/conf.d/librenms.conf

Add the following config, edit server_name as required:

server {
 listen      80;
 server_name labserver.techsupportpk.com;
 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.0-fpm.sock;
 }
 location ~ /\.ht {
  deny all;
 }
}

Save and close

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


Configure snmpd

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

Edit the text which says RANDOMSTRINGGOESHERE and set your own community string.

com2sec readonly  default         technocracy

Save and close.

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

Configure Cron job

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 permissions

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

Now, we need to allow ssh, http, https and the port used by snmpd 161 udp type from the ufw firewall.

sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw allow 161/udp
sudo ufw enable

Run the 'ufw status' command to see the firewall status.

sudo ufw status


Installing LibreNMS

We need to install LibreNMS through the web browser. Open your web browser, type the LibreNMS domain name 'http://labserver.techsupportpk.com' in the address bar and press Enter.

You will be redirected to the install.php page showing the result of PHP module support checks.

Make sure all status is green as shown below.

Click 'Next Stage' to continue.


Fill all the database info with your own db.

DB User: librenms
DB Pass: password
DB Name: librenms

Click Next Stage


Wait for the installer script to import sample of database to our database - do not close the browser tab during this process.

Once done, click 'Goto Add User'.


Type your admin user, email, and password.

Click 'Add User'.



Click the 'Generate Config' button.


And you will get a config file similar to the one shown below.


Copy the php config script, and return back to your terminal session. Goto the '/opt/librenms' directory and create the 'config.php' file manually.

cd /etc/librenms/
sudo nano config.php

Paste the configuration there, and change the ownership of the file to librenms user and group.

sudo chown librenms:librenms config.php

Return back to your web browser and click the 'Finish Install' button.

You are reached to last page from the librenms web installer as shown below.



Go to the librenms directory and run the validate script.

cd /opt/librenms/
sudo ./validate.php

If your installation is correct, you will get the result as shown below.


You are done.

No comments