= 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 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 ''; 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: {{{ DocumentRoot /opt/librenms/html/ CustomLog /opt/librenms/logs/access_log combined ErrorLog /opt/librenms/logs/error_log AllowEncodedSlashes NoDecode Require all granted AllowOverride All Options FollowSymLinks MultiViews }}} 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 }}} === Web Installer === You can choose either a web configuration or manual configuration at the command line. We're going to use the Web installer, which is by far the easiest, but we'll include the manual configuration as a reference at the end of this document. At this stage you can launch the web installer by going to '''http:///install.php''' Follow the onscreen instructions. Stage 0 is a summary of the PHP modules installed, normally you should just click on ''Next Stage'' Stage 1 prompts you for the database settings. Enter - DB Host: '''localhost''' - DB User: '''librenms''' - DB Pass: - DB Name: '''librenms''' Stage 2 is the DB creating itself - it should finish correctly, and you simply click on ''Goto Add User'' at the bottom Stage 3: enter following username, Password and e-mail address. This will become the login you use to access the web interface. - Username : '''admin''' - Password : < class password > - e-mail address : Stage 4 should show you the successful user creation, click on ''Generate Config'' Stage 5: the interface should show, at this point: The config file has been created You can now click ''Finish install''.