| 1 | = LibreNMS = |
| 2 | |
| 3 | NOTE: These instructions assume you are the root user. If you are not, prepend sudo to the shell commands |
| 4 | |
| 5 | == Installation == |
| 6 | |
| 7 | === Install LibreNMS === |
| 8 | First install required packages. |
| 9 | {{{ |
| 10 | 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 |
| 11 | }}} |
| 12 | give <class password> as databse root password. |
| 13 | |
| 14 | Add librenms user and user's home directory |
| 15 | {{{ |
| 16 | useradd librenms -d /opt/librenms -M -r |
| 17 | usermod -a -G librenms www-data |
| 18 | }}} |
| 19 | |
| 20 | Install LibreNMS |
| 21 | {{{ |
| 22 | cd /opt |
| 23 | git clone https://github.com/librenms/librenms.git librenms |
| 24 | }}} |
| 25 | |
| 26 | === Database Configuration === |
| 27 | |
| 28 | Configure MySQL |
| 29 | {{{ |
| 30 | systemctl restart mysql |
| 31 | mysql -uroot -p |
| 32 | }}} |
| 33 | |
| 34 | Create '''librenms''' database and '''librenms''' database user. grant all privileges to the created user. |
| 35 | {{{ |
| 36 | CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 37 | CREATE USER 'librenms'@'localhost' IDENTIFIED BY '<class password>'; |
| 38 | GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost'; |
| 39 | FLUSH PRIVILEGES; |
| 40 | }}} |
| 41 | |
| 42 | exit mysql |
| 43 | {{{ |
| 44 | exit |
| 45 | }}} |
| 46 | |
| 47 | We need to change some mysql server settings. To do that edit '''50-server.cnf''' file |
| 48 | {{{ |
| 49 | vi /etc/mysql/mariadb.conf.d/50-server.cnf |
| 50 | }}} |
| 51 | |
| 52 | Add the following llines within the '''[mysqld]''' section |
| 53 | {{{ |
| 54 | innodb_file_per_table=1 |
| 55 | sql-mode="" |
| 56 | lower_case_table_names=0 |
| 57 | }}} |
| 58 | |
| 59 | Restart the mysql server |
| 60 | {{{ |
| 61 | systemctl restart mysql |
| 62 | }}} |
| 63 | |
| 64 | === Web server Configuration === |
| 65 | |
| 66 | ==== Configure PHP ==== |
| 67 | |
| 68 | To set the correct time zone edit '''php.ini''' |
| 69 | {{{ |
| 70 | vi /etc/php/7.0/apache2/php.ini |
| 71 | }}} |
| 72 | |
| 73 | Find the line ''';date.timezone''' and change the line as follows |
| 74 | {{{ |
| 75 | date.timezone = Asia/Colombo |
| 76 | }}} |
| 77 | |
| 78 | Do the same to the '''vi /etc/php/7.0/cli/php.ini''' |
| 79 | |
| 80 | Enable php modules in apache |
| 81 | {{{ |
| 82 | a2enmod php7.0 |
| 83 | a2dismod mpm_event |
| 84 | a2enmod mpm_prefork |
| 85 | phpenmod mcrypt |
| 86 | }}} |
| 87 | |
| 88 | ==== Configure Apache ==== |
| 89 | |
| 90 | Create '''librenms.conf''' to enable the site |
| 91 | {{{ |
| 92 | vi /etc/apache2/sites-available/librenms.conf |
| 93 | }}} |
| 94 | |
| 95 | Add the following lines: |
| 96 | {{{ |
| 97 | <VirtualHost *:80> |
| 98 | DocumentRoot /opt/librenms/html/ |
| 99 | CustomLog /opt/librenms/logs/access_log combined |
| 100 | ErrorLog /opt/librenms/logs/error_log |
| 101 | AllowEncodedSlashes NoDecode |
| 102 | <Directory "/opt/librenms/html/"> |
| 103 | Require all granted |
| 104 | AllowOverride All |
| 105 | Options FollowSymLinks MultiViews |
| 106 | </Directory> |
| 107 | </VirtualHost> |
| 108 | }}} |
| 109 | |
| 110 | Enable the librenms site and restart apache server |
| 111 | {{{ |
| 112 | a2ensite librenms.conf |
| 113 | a2enmod rewrite |
| 114 | systemctl restart apache2 |
| 115 | }}} |
| 116 | |
| 117 | === Configure snmpd === |
| 118 | |
| 119 | Create the snmpd configuration file |
| 120 | {{{ |
| 121 | cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf |
| 122 | vi /etc/snmp/snmpd.conf |
| 123 | }}} |
| 124 | |
| 125 | Edit the text which says '''RANDOMSTRINGGOESHERE''' and set your own community string. |
| 126 | |
| 127 | Install the libreNMS agent and restart snmpd |
| 128 | {{{ |
| 129 | curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro |
| 130 | chmod +x /usr/bin/distro |
| 131 | systemctl restart snmpd |
| 132 | }}} |
| 133 | |
| 134 | === Cron job === |
| 135 | {{{ |
| 136 | cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms |
| 137 | }}} |
| 138 | |
| 139 | Copy logrotate config |
| 140 | |
| 141 | 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: |
| 142 | {{{ |
| 143 | cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms |
| 144 | }}} |
| 145 | |
| 146 | === Set permissions === |
| 147 | {{{ |
| 148 | chown -R librenms:librenms /opt/librenms |
| 149 | setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs |
| 150 | setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs |
| 151 | }}} |