Wednesday 21 December 2016

LibreNMS Installation and Configuration in RHEL 7

What is LibreNMS :

LibreNMS is an auto-discovering php/mysql/snmp based network monitoring tool. It's includes support for a wide range of network hardware and operating systems like Cisco, Linux, juniper and many more. LibreNMS is a community-based fork of the latest GPL-Licensed version of Observium.

Features :

  • Automatic Discovery
  • Customisable Alerting
  • API Access
  • Billing System
  • Automatic updates
  • Distributed Polling
Automatic Discovery :

LibreNMS is automatically discovers our entire network using CDP, FDP, LLDP, OSPF, BGP, SNMP and ARP.

Customisable Alerting :

Highly flexible alerting system, notification via email, irc, slack and more.

API Access :

A full API to manage graph and retrieve data from our install.


Billing System :

Generate bandwidth bills for ports on your network based on usage or transfer.

Automatic Updates :

With this option it update automatically and fix the bugs and get new features and more.

Distributed Polling :

Horizontal scaling to grow with your network.

More features 

  • NfSen
  • collectd
  • SmokePing
  • RANCID
  • Oxidized

NfSen :

NfSen is a graphical web based front end for the nfdumb netflow tools.

NfSen allows
  1. Display netflow data, flows, packets and bytes using RRD ( Round Robin Database )
  2. Easily navigate through the netflow data.
  3. Process the netflow data within the specified time span.
  4. Create history as well as continious profiles.
  5. Set alerts, based on various conditions.
  6. Write our own plugin to process netflow data on a regular interval
For more details click here.

Collectd :

Collectd is a daemon which collects system and application performance metrics periodically and provides mechanisms to store the variety of ways.

It gathers metrics from various sources like OS, Applications, Log, and external device and stores this information or make it available over the network. It will help us to monitor systems and find the performance bottlenecks also it predict system load of future.

For more details click here

SmokePing:

SmokePing keeps track of our network latency. Best of breed latency visualization, interactive graph explorer, Wide range of measurement plugins, Master/slave system for distributed measurement. Highly configurable alerting system, Live latency charts with most interesting graphs and free and opensource software written in Perl written by Oetiker, the creator of MRTG and Toolbar. 

RANCID :

RANCID monitors a router's configuratiobn, including software and hardware and uses CVS subversion or git to maintain history of changes.

For more details click here.

Oxidized : 

Oxidized is a network device configuration backup tool. It's a RANCID replacement.
  1. automatically adds/removes threads to meet configured retrieval interval.
  2. restful API to move node immediately to head-of-queue (GET/POST /node/next/[NODE])
  3. syslog udp+file example to catch config change event (ios/junos) and trigger config fetch
  4. will signal ios/junos user who made change, which output modules can use (via POST)
  5. The git output module uses this info - 'git blame' will for each line show who made the change 
  6. restful API to reload list of nodes (GET /reload)
  7. restful API to fetch configurations (/node/fetch/[NODE] or /node/fetch/group/[NODE])
  8. restful API to show list of nodes (GET /nodes)
  9. restful API to show list of version for a node (/node/version[NODE]) and diffs
For more details click here.

Multiple authentication methods :
  • Mysql
  • HTTP
  • LDAP
  • Radius
  • Active Directory

Installation :

For LibreNMS installation we need root privilege.

In rhel 7 have mariadb instead of mysql in official repo. both are same rhel 7 compatible with mariadb only.

Step 1

Install mariaDB :

yum install mariadb-server mariadb

start the service of mariadb 

systemctl start mariadb

systemctl enable mariadb

then login mariadb with root

mysql -u root -p

then create database as below or you can use it with your own

CREATE DATABASE librenms;
GRANT ALL PRIVILEGES ON librenms.*
TO 'librenms'@'localhost'
IDENTIFIED BY '<password>'
;
FLUSH PRIVILEGES;
exit

Step 2

Edit the mariadb configuration and add the following line as below shown.

vi /etc/my.cnf

add the following line as

innodb_file_per_table=1


Now restart the mariadb 

systemctl restart mariadb

Step 3

Need to install necessary packages. We need to install epel-release because lot of packages only available at epel-release only.

php-snmp, jwhois, graphviz, php-mcrypt, fping these are all in eple-release only.

yum install epel-release -y

now install the required packages

yum install php php-cli php-gd php-mysql php-snmp php-pear php-curl httpd net-snmp graphviz graphviz-php mysql ImageMagick jwhois nmap mtr rrdtool MySQL-python net-snmp-utils cronie php-mcrypt fping git

then

pear install Net_IPv4-1.3.4

pear install Net_IPv6-1.2.2b2

make sure the snmpd start and turn on on boot

systemctl enable snmpd

systemctl start snmpd

Step 4

Configuration of snmp on localhost

make a backup of the snmpd.conf file and create new snmpd.conf file as below




# Change RANDOMSTRINGGOESHERE to your preferred SNMP community string
com2sec readonly  default         public

group MyROGroup v2c        readonly
view all    included  .1                               80
access MyROGroup ""      any       noauth    exact  all    none   none

syslocation Rack, Room, Building, City, Country [GPSX,Y]
syscontact Your Name <your@email.address>

#Distro Detection
extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro

rocommunity public 127.0.0.1

save and exit

Step 5

LibreNMS user creation for apache.

useradd librenms -d /opt/librenms -M -r

usermod -a -G librenms apache


make sure httpd on boot

systemctl enable httpd

then change timezone as your current city in php.ini

vi /etc/php.ini


and make sure that allow_url_fopen is enabled like below image


Step 6

now apache configuration for librenms.

add below lines in /etc/http/conf.d/librenms.conf


<VirtualHost *:80>

  DocumentRoot /opt/librenms/html/
  ServerName  librenms.example.com
  CustomLog /opt/librenms/logs/access_log combined
  ErrorLog /opt/librenms/logs/error_log
  AllowEncodedSlashes NoDecode
  <Directory "/opt/librenms/html/">
    AllowOverride All
    Options FollowSymLinks MultiViews
    Require all granted
  </Directory>
</VirtualHost>

and most important we need to remove welcome.conf file in /etc/httpd/conf.d/welcome.conf or rename it.

mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_bkp


Step 7

Download the package from git means clone the package to local

cd /opt

git clone https://github.com/librenms/librenms.git librenms

cd /opt/librenms

prepare for the web interface, need to create some directory and make it own for librenms

mkdir rrd logs

chown -R librenms:librenms /opt/librenms

chmod 775 rrd

most important is disable the selinux or follow the command to allow from selinux.


yum install policycoreutils-python

semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/logs(/.*)?'

semanage fcontext -a -t https_sys_rw_content_t '/opt/librenms/logs(/.*)?'

restorecon -RFvv /opt/librenms/logs/

Set selinux to allow httpd to sendmail

setsebool -P httpd_can_senmail=1

Step 8

start the webserver

systemctl start httpd

now open the url with you browser and provide the required details.

if you face any issue on that close the browser and follow the manual steps that mentioned below.

cp config.php.default config.php

vi config.php

add the following line in last 

$ config['fping'] = "/usr/sbin/fping";

Be sure you have no characters like spaces, tabs etc outside of the <?php?> blocks. If it then graph will be breake.

Now initialize the database

pwd

/opt/librenms

php build-base.php

it will install all the required packages of php for librenms

create admin user with following command

php adduser.php username password 10 emailid

Now validate your installation

php validate.php

this will check all the installation and verify it. if web portal is having issue then this command will gives the error which acquired. if it's gives ok then proceed below.

now add the your local snmp with following command.

php addhost.php localhost public v2c

replace the public with your own community name and v2c to ypur own version.

now discover the local host with following command

php discovery.php -h all

Step 9

The polling method used by librenms is poller-wrapper.py. By default the librenms cronjob runs poller-wrapper.py with 16 threads. The current LibreNMS recommanded to use 4 threads per core. The default if no thread count is 16 threads.

We can change the count using below command.

/opt/librenms/poller-wrapper.py 12 >> /dev/null 2>&1

now create the cronjob

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

Thats all now we can login and start adding the devices for monitoring.......

Permanent hostname setup for RHEL7

Step 1 Set the host name on NMTUI tool like following nmtui set host name   then save and exit Step 2 add the following l...