Changes between Version 1 and Version 2 of Cnbp2019/Agenda/MonitoringLab
- Timestamp:
- Feb 4, 2019, 8:41:40 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Cnbp2019/Agenda/MonitoringLab
v1 v2 16 16 17 17 Within the ` [mysqld]` section please add: 18 {{{ 18 {{{#!sh 19 19 innodb_file_per_table=1 20 20 sql-mode="" … … 26 26 Now you need to create a database for LibreNMS. 27 27 28 {{{ 29 mysql –u root –p28 `mysql –u root –p` 29 {{{#!php 30 30 MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci; 31 31 MariaDB [(none)]> CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'Strongpassword'; … … 39 39 Ubuntu 18.04 has PHP 7.2 in its repositories. Install it by running the commands below on your terminal 40 40 41 {{{ 41 {{{#!sh 42 42 sudo apt-get -y install wget php php-pear php-cgi php-common curl php-curl \ 43 43 php-mbstring php-gd php-mysql php-gettext php-bcmath \ … … 49 49 it should give you a similar output as below 50 50 51 {{{ 52 #php -v 53 51 {{{#!sh 54 52 PHP 7.2.8 (cli) (built: Jul 17 2018 09:50:46) ( NTS ) 55 53 Copyright (c) 1997-2018 The PHP Group … … 57 55 }}} 58 56 59 Configure and Start PHP-FPM 60 Ensure date.timezone is set in php.ini to your preferred time zone: 57 Ensure date.timezone is set in **php.ini** to your preferred time zone: 58 61 59 Edit both files: 62 sudo vim /etc/php/7.2/fpm/php.ini 63 sudo vim /etc/php/7.2/cli/php.ini 64 65 Change date.timezone under [Date] section: 60 61 `sudo vim /etc/php/7.2/fpm/php.ini` 62 and 63 `sudo vim /etc/php/7.2/cli/php.ini` 64 65 Change date.timezone under `[Date]` section: 66 {{{#!php 66 67 [Date] 67 68 ; Defines the default timezone used by the date functions 68 69 ; http://php.net/date.timezone 69 70 date.timezone = Asia/Colombo 71 }}} 72 70 73 Restart php fpm: 71 sudo systemctl restart php7.2-fpm.service 74 75 `sudo systemctl restart php7.2-fpm.service` 76 77 === Installation of NGINX === 72 78 73 79 For this setup, we will use Nginx as a web server for LibreNMS, install it by running: 74 sudo apt-get install nginx 75 76 Step 2: Download and Install LibreNMS 80 81 `sudo apt-get install nginx` 82 83 84 == Installation of LIbreNMS == 85 77 86 We will download and install LibreNMS in this step. If you don’t have git, first install it: 78 $ sudo apt-get install git 79 80 LibreNMS will run under its own user called librenms which we need to add: 87 88 `sudo apt-get install git` 89 90 LibreNMS will run under its own user called **librenms** which we need to add: 91 92 {{{#!sh 81 93 sudo useradd -r -M -d /opt/librenms librenms 82 94 getent passwd librenms 83 84 85 output: 86 95 }}} 96 97 it will giva an output like, 98 {{{#!sh 87 99 librenms:x:997:996::/opt/librenms:/bin/sh 100 }}} 101 88 102 Add this user to web user group www-data 89 sudo usermod -a -G librenms www-data 103 104 `sudo usermod -a -G librenms www-data` 90 105 91 106 When done. proceed to install packages required by LibreNMS 92 107 108 {{{#!sh 93 109 sudo apt-get update 94 110 sudo apt install rrdtool whois fping imagemagick graphviz mtr-tiny \ 95 111 nmap python-mysqldb snmp snmpd python-memcache mtr-tiny acl 112 }}} 96 113 97 114 Clone LibreNMS source code from github: 98 git clone https://github.com/librenms/librenms.git librenms 115 116 `git clone https://github.com/librenms/librenms.git librenms` 99 117 100 118 output: 119 {{{#!sh 101 120 Cloning into 'librenms'... 102 121 remote: Counting objects: 130428, done. … … 106 125 Resolving deltas: 100% (88754/88754), done. 107 126 Checking out files: 100% (8476/8476), done. 127 }}} 108 128 109 129 Move the folder librenms to /opt 110 130 111 sudo mv librenms/ /opt/ 131 `sudo mv librenms/ /opt/` 112 132 113 133 Change permission of the directory: 134 135 {{{#!sh 114 136 sudo chown -R librenms:librenms /opt/librenms/ 115 137 sudo chmod -R 775 /opt/librenms/ 138 }}} 116 139 117 140 Configure snmpd 141 142 {{{#!sh 118 143 sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf 119 144 sudo vim /etc/snmp/snmpd.conf 120 121 Edit the text which says RANDOMSTRINGGOESHERE and set your own community string. 122 145 }}} 146 147 Edit the text which says `RANDOMSTRINGGOESHERE` and set your own community string. 148 149 {{{#!sh 123 150 curl -o distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro 124 151 chmod +x distro 125 152 sudo mv distro /usr/bin/distro 153 }}} 126 154 127 155 Restart snmpd 128 156 129 sudo systemctl restart snmpd 130 131 Create LibreNMS Cron job 132 Run the command below to set cron job: 133 134 sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms 157 `sudo systemctl restart snmpd` 158 159 Create LibreNMS Cron job and run the command below to set cron job: 160 161 ```sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms``` 135 162 Copy logrotate config 136 163 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: 137 164 138 sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms 139 140 Fix LibreNMS Permissions 165 ```sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms``` 166 141 167 Finally, fix all permissions 168 {{{#!sh 142 169 sudo chown -R librenms:librenms /opt/librenms 143 170 sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ 144 171 sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ 145 146 Configure Nginx: 147 Let’s create the VirtualHost definition for Nginx to be used by LibreNMS. 148 sudo vim /etc/nginx/conf.d/librenms.conf 149 172 }}} 173 174 === Configure Nginx:=== 175 176 Let’s create the !VirtualHost definition for Nginx to be used by LibreNMS. 177 `sudo vim /etc/nginx/conf.d/librenms.conf` 178 {{{#!apache 150 179 server { 151 180 listen 80; … … 172 201 } 173 202 } 203 204 }}} 205 174 206 Check syntax: 175 207 176 sudo nginx –t 208 `sudo nginx –t` 177 209 178 210 output: 179 211 {{{#!sh 180 212 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 181 213 nginx: configuration file /etc/nginx/nginx.conf test is successful 182 214 }}} 183 215 if all is okay, restart nginx: 184 216 185 sudo systemctl restart nginx 217 `sudo systemctl restart nginx` 186 218 187 219 188 220 Run composer install: 189 221 222 {{{#!sh 190 223 cd /opt/librenms 191 224 ./scripts/composer_wrapper.php install --no-dev 225 }}} 192 226 193 227 Now open your web browser and start the installer: