Version 1 (modified by 7 years ago) ( diff ) | ,
---|
LibreNMS
NOTE: These instructions assume you are the root user. If you are not, prepend sudo to the shell commands
Installation
Install LibreNMS
First install required packages.
apt-get install apache2 composer fping git graphviz imagemagick libapache2-mod-php7.0 mariadb-client mariadb-server mtr-tiny nmap php7.0-cli php7.0-curl php7.0-gd php7.0-json php7.0-mcrypt php7.0-mysql php7.0-snmp php7.0-xml php7.0-zip python-memcache python-mysqldb rrdtool snmp snmpd whois
give <class password> as databse root password.
Add librenms user and user's home directory
useradd librenms -d /opt/librenms -M -r usermod -a -G librenms www-data
Install LibreNMS
cd /opt git clone https://github.com/librenms/librenms.git librenms
Database Configuration
Configure MySQL
systemctl restart mysql mysql -uroot -p
Create librenms database and librenms database user. grant all privileges to the created user.
CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci; CREATE USER 'librenms'@'localhost' IDENTIFIED BY '<class password>'; GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost'; FLUSH PRIVILEGES;
exit mysql
exit
We need to change some mysql server settings. To do that edit 50-server.cnf file
vi /etc/mysql/mariadb.conf.d/50-server.cnf
Add the following llines within the [mysqld] section
innodb_file_per_table=1 sql-mode="" lower_case_table_names=0
Restart the mysql server
systemctl restart mysql
Web server Configuration
Configure PHP
To set the correct time zone edit php.ini
vi /etc/php/7.0/apache2/php.ini
Find the line ;date.timezone and change the line as follows
date.timezone = Asia/Colombo
Do the same to the vi /etc/php/7.0/cli/php.ini
Enable php modules in apache
a2enmod php7.0 a2dismod mpm_event a2enmod mpm_prefork phpenmod mcrypt
Configure Apache
Create librenms.conf to enable the site
vi /etc/apache2/sites-available/librenms.conf
Add the following lines:
<VirtualHost *:80> DocumentRoot /opt/librenms/html/ 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>
Enable the librenms site and restart apache server
a2ensite librenms.conf a2enmod rewrite systemctl restart apache2
Configure snmpd
Create the snmpd configuration file
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf vi /etc/snmp/snmpd.conf
Edit the text which says RANDOMSTRINGGOESHERE and set your own community string.
Install the libreNMS agent and restart snmpd
curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro chmod +x /usr/bin/distro systemctl restart snmpd
Cron job
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:
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Set permissions
chown -R librenms:librenms /opt/librenms setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs