Changes between Version 1 and Version 2 of Cnbp2019/Agenda/MonitoringLab


Ignore:
Timestamp:
Feb 4, 2019, 8:41:40 AM (5 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Cnbp2019/Agenda/MonitoringLab

    v1 v2  
    1616
    1717Within the ` [mysqld]` section please add:
    18 {{{
     18{{{#!sh
    1919innodb_file_per_table=1
    2020sql-mode=""
     
    2626Now you need to create a database for LibreNMS.
    2727
    28 {{{
    29 mysql –u root –p
     28`mysql –u root –p`
     29{{{#!php
    3030MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    3131MariaDB [(none)]> CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'Strongpassword';
     
    3939Ubuntu 18.04 has PHP 7.2 in its repositories. Install it by running the commands below on your terminal
    4040
    41 {{{
     41{{{#!sh
    4242sudo apt-get -y install wget php php-pear php-cgi php-common curl php-curl \
    4343php-mbstring php-gd php-mysql php-gettext php-bcmath \
     
    4949it should give you a similar output as below
    5050
    51 {{{
    52 #php -v
    53 
     51{{{#!sh
    5452PHP 7.2.8 (cli) (built: Jul 17 2018 09:50:46) ( NTS )
    5553Copyright (c) 1997-2018 The PHP Group
     
    5755}}}
    5856
    59 Configure and Start PHP-FPM
    60 Ensure date.timezone is set in php.ini to your preferred time zone:
     57Ensure date.timezone is set in **php.ini** to your preferred time zone:
     58
    6159Edit 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`
     62and
     63`sudo vim /etc/php/7.2/cli/php.ini`
     64
     65Change date.timezone under `[Date]` section:
     66{{{#!php
    6667[Date]
    6768; Defines the default timezone used by the date functions
    6869; http://php.net/date.timezone
    6970date.timezone = Asia/Colombo
     71}}}
     72
    7073Restart php fpm:
    71 sudo systemctl restart php7.2-fpm.service
     74
     75`sudo systemctl restart php7.2-fpm.service`
     76
     77=== Installation of NGINX ===
    7278
    7379For 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
    7786We 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
     90LibreNMS will run under its own user called **librenms** which we need to add:
     91
     92{{{#!sh
    8193sudo useradd -r -M -d /opt/librenms librenms
    8294getent passwd librenms
    83 
    84 
    85 output:
    86 
     95}}}
     96
     97it will giva an output like,
     98{{{#!sh
    8799librenms:x:997:996::/opt/librenms:/bin/sh
     100}}}
     101
    88102Add 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`
    90105
    91106When done. proceed to install packages required by LibreNMS
    92107
     108{{{#!sh
    93109sudo apt-get update
    94110sudo apt install rrdtool whois fping imagemagick graphviz  mtr-tiny \
    95111nmap python-mysqldb snmp snmpd python-memcache mtr-tiny acl
     112}}}
    96113
    97114Clone 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`
    99117
    100118output:
     119{{{#!sh
    101120Cloning into 'librenms'...
    102121remote: Counting objects: 130428, done.
     
    106125Resolving deltas: 100% (88754/88754), done.
    107126Checking out files: 100% (8476/8476), done.
     127}}}
    108128
    109129Move the folder librenms to /opt
    110130
    111 sudo mv librenms/ /opt/
     131`sudo mv librenms/ /opt/`
    112132
    113133Change permission of the directory:
     134
     135{{{#!sh
    114136sudo chown -R librenms:librenms /opt/librenms/
    115137sudo chmod -R 775 /opt/librenms/
     138}}}
    116139
    117140Configure snmpd
     141
     142{{{#!sh
    118143sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
    119144sudo vim /etc/snmp/snmpd.conf
    120 
    121 Edit the text which says RANDOMSTRINGGOESHERE and set your own community string.
    122 
     145}}}
     146
     147Edit the text which says `RANDOMSTRINGGOESHERE` and set your own community string.
     148
     149{{{#!sh
    123150curl -o distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
    124151chmod +x distro
    125152sudo mv distro  /usr/bin/distro
     153}}}
    126154
    127155Restart snmpd
    128156
    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
     159Create 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```
    135162Copy logrotate config
    136163LibreNMS 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:
    137164
    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
    141167Finally, fix all permissions
     168{{{#!sh
    142169sudo chown -R librenms:librenms /opt/librenms
    143170sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
    144171sudo 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
     176Let’s create the !VirtualHost definition for Nginx to be used by LibreNMS.
     177`sudo vim /etc/nginx/conf.d/librenms.conf`
     178{{{#!apache
    150179server {
    151180 listen      80;
     
    172201 }
    173202}
     203
     204}}}
     205
    174206Check syntax:
    175207
    176 sudo nginx –t
     208`sudo nginx –t`
    177209
    178210output:
    179 
     211{{{#!sh
    180212nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    181213nginx: configuration file /etc/nginx/nginx.conf test is successful
    182 
     214}}}
    183215if all is okay, restart nginx:
    184216
    185 sudo systemctl restart nginx
     217`sudo systemctl restart nginx`
    186218
    187219
    188220Run composer install:
    189221
     222{{{#!sh
    190223cd /opt/librenms
    191224./scripts/composer_wrapper.php install --no-dev
     225}}}
    192226
    193227Now open your web browser and start the installer: